1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

osxkeychain: use designated domains in tests (RFC2606)

Update domains used in tests to used domains that are designated for this
purpose as described in [RFC2606, section 3][1]

[1]: https://www.rfc-editor.org/rfc/rfc2606.html#section-3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-05-27 13:09:22 +02:00
parent 13475b4387
commit 7d66ae02a6
+28 -28
View File
@@ -11,12 +11,12 @@ import (
func TestOSXKeychainHelper(t *testing.T) { func TestOSXKeychainHelper(t *testing.T) {
creds := &credentials.Credentials{ creds := &credentials.Credentials{
ServerURL: "https://foobar.docker.io:2376/v1", ServerURL: "https://foobar.example.com:2376/v1",
Username: "foobar", Username: "foobar",
Secret: "foobarbaz", Secret: "foobarbaz",
} }
creds1 := &credentials.Credentials{ creds1 := &credentials.Credentials{
ServerURL: "https://foobar.docker.io:2376/v2", ServerURL: "https://foobar.example.com:2376/v2",
Username: "foobarbaz", Username: "foobarbaz",
Secret: "foobar", Secret: "foobar",
} }
@@ -68,18 +68,18 @@ func TestOSXKeychainHelperRetrieveAliases(t *testing.T) {
}{ }{
{ {
doc: "stored with port, retrieved without", doc: "stored with port, retrieved without",
storeURL: "https://foobar.docker.io:2376", storeURL: "https://foobar.example.com:2376",
readURL: "https://foobar.docker.io", readURL: "https://foobar.example.com",
}, },
{ {
doc: "stored as https, retrieved without scheme", doc: "stored as https, retrieved without scheme",
storeURL: "https://foobar.docker.io:2376", storeURL: "https://foobar.example.com:2376",
readURL: "foobar.docker.io", readURL: "foobar.example.com",
}, },
{ {
doc: "stored with path, retrieved without", doc: "stored with path, retrieved without",
storeURL: "https://foobar.docker.io:1234/one/two", storeURL: "https://foobar.example.com:1234/one/two",
readURL: "https://foobar.docker.io:1234", readURL: "https://foobar.example.com:1234",
}, },
} }
@@ -126,35 +126,35 @@ func TestOSXKeychainHelperRetrieveStrict(t *testing.T) {
}{ }{
{ {
doc: "stored as https, retrieved using http", doc: "stored as https, retrieved using http",
storeURL: "https://foobar.docker.io:2376", storeURL: "https://foobar.example.com:2376",
readURL: "http://foobar.docker.io:2376", readURL: "http://foobar.example.com:2376",
}, },
{ {
doc: "stored as http, retrieved using https", doc: "stored as http, retrieved using https",
storeURL: "http://foobar.docker.io:2376", storeURL: "http://foobar.example.com:2376",
readURL: "https://foobar.docker.io:2376", readURL: "https://foobar.example.com:2376",
}, },
{ {
// stored as http, retrieved without a scheme specified (hence, using the default https://) // stored as http, retrieved without a scheme specified (hence, using the default https://)
doc: "stored as http, retrieved without scheme", doc: "stored as http, retrieved without scheme",
storeURL: "http://foobar.docker.io", storeURL: "http://foobar.example.com",
readURL: "foobar.docker.io:5678", readURL: "foobar.example.com:5678",
}, },
{ {
doc: "non-matching ports", doc: "non-matching ports",
storeURL: "https://foobar.docker.io:1234", storeURL: "https://foobar.example.com:1234",
readURL: "https://foobar.docker.io:5678", readURL: "https://foobar.example.com:5678",
}, },
// TODO: is this desired behavior? The other way round does work // TODO: is this desired behavior? The other way round does work
// { // {
// doc: "non-matching ports (stored without port)", // doc: "non-matching ports (stored without port)",
// storeURL: "https://foobar.docker.io", // storeURL: "https://foobar.example.com",
// readURL: "https://foobar.docker.io:5678", // readURL: "https://foobar.example.com:5678",
// }, // },
{ {
doc: "non-matching paths", doc: "non-matching paths",
storeURL: "https://foobar.docker.io:1234/one/two", storeURL: "https://foobar.example.com:1234/one/two",
readURL: "https://foobar.docker.io:1234/five/six", readURL: "https://foobar.example.com:1234/five/six",
}, },
} }
@@ -197,14 +197,14 @@ func TestOSXKeychainHelperStoreRetrieve(t *testing.T) {
tests := []struct { tests := []struct {
url string url string
}{ }{
{url: "foobar.docker.io"}, {url: "foobar.example.com"},
{url: "foobar.docker.io:2376"}, {url: "foobar.example.com:2376"},
{url: "//foobar.docker.io:2376"}, {url: "//foobar.example.com:2376"},
{url: "https://foobar.docker.io:2376"}, {url: "https://foobar.example.com:2376"},
{url: "http://foobar.docker.io:2376"}, {url: "http://foobar.example.com:2376"},
{url: "https://foobar.docker.io:2376/some/path"}, {url: "https://foobar.example.com:2376/some/path"},
{url: "https://foobar.docker.io:2376/some/other/path"}, {url: "https://foobar.example.com:2376/some/other/path"},
{url: "https://foobar.docker.io:2376/some/other/path?foo=bar"}, {url: "https://foobar.example.com:2376/some/other/path?foo=bar"},
} }
helper := Osxkeychain{} helper := Osxkeychain{}