From 91af1de9af4b02000b8879627abfcd04a4c120e1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 12:56:53 +0200 Subject: [PATCH 1/6] registryurl: 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 --- registryurl/parse_test.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/registryurl/parse_test.go b/registryurl/parse_test.go index b5c161d0..9710dc1e 100644 --- a/registryurl/parse_test.go +++ b/registryurl/parse_test.go @@ -14,39 +14,39 @@ func TestHelperParseURL(t *testing.T) { err error }{ { - url: "foobar.docker.io", - expectedURL: "//foobar.docker.io", + url: "foobar.example.com", + expectedURL: "//foobar.example.com", }, { - url: "foobar.docker.io:2376", - expectedURL: "//foobar.docker.io:2376", + url: "foobar.example.com:2376", + expectedURL: "//foobar.example.com:2376", }, { - url: "//foobar.docker.io:2376", - expectedURL: "//foobar.docker.io:2376", + url: "//foobar.example.com:2376", + expectedURL: "//foobar.example.com:2376", }, { - url: "http://foobar.docker.io:2376", - expectedURL: "http://foobar.docker.io:2376", + url: "http://foobar.example.com:2376", + expectedURL: "http://foobar.example.com:2376", }, { - url: "https://foobar.docker.io:2376", - expectedURL: "https://foobar.docker.io:2376", + url: "https://foobar.example.com:2376", + expectedURL: "https://foobar.example.com:2376", }, { - url: "https://foobar.docker.io:2376/some/path", - expectedURL: "https://foobar.docker.io:2376/some/path", + url: "https://foobar.example.com:2376/some/path", + expectedURL: "https://foobar.example.com:2376/some/path", }, { - url: "https://foobar.docker.io:2376/some/other/path?foo=bar", - expectedURL: "https://foobar.docker.io:2376/some/other/path", + url: "https://foobar.example.com:2376/some/other/path?foo=bar", + expectedURL: "https://foobar.example.com:2376/some/other/path", }, { - url: "/foobar.docker.io", + url: "/foobar.example.com", err: errors.New("no hostname in URL"), }, { - url: "ftp://foobar.docker.io:2376", + url: "ftp://foobar.example.com:2376", err: errors.New("unsupported scheme: ftp"), }, } From 13475b4387bc2dea0df6adf82ce380faa3585e16 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 12:57:18 +0200 Subject: [PATCH 2/6] credentials: 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 --- credentials/credentials_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/credentials/credentials_test.go b/credentials/credentials_test.go index 3c815eb9..12a35c51 100644 --- a/credentials/credentials_test.go +++ b/credentials/credentials_test.go @@ -42,7 +42,7 @@ func (m *memoryStore) List() (map[string]string, error) { } func TestStore(t *testing.T) { - const serverURL = "https://index.docker.io/v1/" + const serverURL = "https://registry.example.com/v1/" creds := &Credentials{ ServerURL: serverURL, Username: "foo", @@ -95,7 +95,7 @@ func TestStoreMissingServerURL(t *testing.T) { func TestStoreMissingUsername(t *testing.T) { creds := &Credentials{ - ServerURL: "https://index.docker.io/v1/", + ServerURL: "https://registry.example.com/v1/", Username: "", Secret: "bar", } @@ -114,7 +114,7 @@ func TestStoreMissingUsername(t *testing.T) { } func TestGet(t *testing.T) { - const serverURL = "https://index.docker.io/v1/" + const serverURL = "https://registry.example.com/v1/" creds := &Credentials{ ServerURL: serverURL, Username: "foo", @@ -156,7 +156,7 @@ func TestGet(t *testing.T) { } func TestGetMissingServerURL(t *testing.T) { - const serverURL = "https://index.docker.io/v1/" + const serverURL = "https://registry.example.com/v1/" creds := &Credentials{ ServerURL: serverURL, Username: "foo", @@ -182,7 +182,7 @@ func TestGetMissingServerURL(t *testing.T) { } func TestErase(t *testing.T) { - const serverURL = "https://index.docker.io/v1/" + const serverURL = "https://registry.example.com/v1/" creds := &Credentials{ ServerURL: serverURL, Username: "foo", @@ -211,7 +211,7 @@ func TestErase(t *testing.T) { } func TestEraseMissingServerURL(t *testing.T) { - const serverURL = "https://index.docker.io/v1/" + const serverURL = "https://registry.example.com/v1/" creds := &Credentials{ ServerURL: serverURL, Username: "foo", From 7d66ae02a6dda555d2b59c395556c3e33e66e066 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 13:09:22 +0200 Subject: [PATCH 3/6] 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 --- osxkeychain/osxkeychain_test.go | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/osxkeychain/osxkeychain_test.go b/osxkeychain/osxkeychain_test.go index 447c1452..c82c6490 100644 --- a/osxkeychain/osxkeychain_test.go +++ b/osxkeychain/osxkeychain_test.go @@ -11,12 +11,12 @@ import ( func TestOSXKeychainHelper(t *testing.T) { creds := &credentials.Credentials{ - ServerURL: "https://foobar.docker.io:2376/v1", + ServerURL: "https://foobar.example.com:2376/v1", Username: "foobar", Secret: "foobarbaz", } creds1 := &credentials.Credentials{ - ServerURL: "https://foobar.docker.io:2376/v2", + ServerURL: "https://foobar.example.com:2376/v2", Username: "foobarbaz", Secret: "foobar", } @@ -68,18 +68,18 @@ func TestOSXKeychainHelperRetrieveAliases(t *testing.T) { }{ { doc: "stored with port, retrieved without", - storeURL: "https://foobar.docker.io:2376", - readURL: "https://foobar.docker.io", + storeURL: "https://foobar.example.com:2376", + readURL: "https://foobar.example.com", }, { doc: "stored as https, retrieved without scheme", - storeURL: "https://foobar.docker.io:2376", - readURL: "foobar.docker.io", + storeURL: "https://foobar.example.com:2376", + readURL: "foobar.example.com", }, { doc: "stored with path, retrieved without", - storeURL: "https://foobar.docker.io:1234/one/two", - readURL: "https://foobar.docker.io:1234", + storeURL: "https://foobar.example.com:1234/one/two", + readURL: "https://foobar.example.com:1234", }, } @@ -126,35 +126,35 @@ func TestOSXKeychainHelperRetrieveStrict(t *testing.T) { }{ { doc: "stored as https, retrieved using http", - storeURL: "https://foobar.docker.io:2376", - readURL: "http://foobar.docker.io:2376", + storeURL: "https://foobar.example.com:2376", + readURL: "http://foobar.example.com:2376", }, { doc: "stored as http, retrieved using https", - storeURL: "http://foobar.docker.io:2376", - readURL: "https://foobar.docker.io:2376", + storeURL: "http://foobar.example.com:2376", + readURL: "https://foobar.example.com:2376", }, { // stored as http, retrieved without a scheme specified (hence, using the default https://) doc: "stored as http, retrieved without scheme", - storeURL: "http://foobar.docker.io", - readURL: "foobar.docker.io:5678", + storeURL: "http://foobar.example.com", + readURL: "foobar.example.com:5678", }, { doc: "non-matching ports", - storeURL: "https://foobar.docker.io:1234", - readURL: "https://foobar.docker.io:5678", + storeURL: "https://foobar.example.com:1234", + readURL: "https://foobar.example.com:5678", }, // TODO: is this desired behavior? The other way round does work // { // doc: "non-matching ports (stored without port)", - // storeURL: "https://foobar.docker.io", - // readURL: "https://foobar.docker.io:5678", + // storeURL: "https://foobar.example.com", + // readURL: "https://foobar.example.com:5678", // }, { doc: "non-matching paths", - storeURL: "https://foobar.docker.io:1234/one/two", - readURL: "https://foobar.docker.io:1234/five/six", + storeURL: "https://foobar.example.com:1234/one/two", + readURL: "https://foobar.example.com:1234/five/six", }, } @@ -197,14 +197,14 @@ func TestOSXKeychainHelperStoreRetrieve(t *testing.T) { tests := []struct { url string }{ - {url: "foobar.docker.io"}, - {url: "foobar.docker.io:2376"}, - {url: "//foobar.docker.io:2376"}, - {url: "https://foobar.docker.io:2376"}, - {url: "http://foobar.docker.io:2376"}, - {url: "https://foobar.docker.io:2376/some/path"}, - {url: "https://foobar.docker.io:2376/some/other/path"}, - {url: "https://foobar.docker.io:2376/some/other/path?foo=bar"}, + {url: "foobar.example.com"}, + {url: "foobar.example.com:2376"}, + {url: "//foobar.example.com:2376"}, + {url: "https://foobar.example.com:2376"}, + {url: "http://foobar.example.com:2376"}, + {url: "https://foobar.example.com:2376/some/path"}, + {url: "https://foobar.example.com:2376/some/other/path"}, + {url: "https://foobar.example.com:2376/some/other/path?foo=bar"}, } helper := Osxkeychain{} From 10508483577bd6c2b26fb666a1d20a66f8a82669 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 13:12:19 +0200 Subject: [PATCH 4/6] client: 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 --- client/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index ebb2a6ba..0db20057 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -11,11 +11,11 @@ import ( ) const ( - validServerAddress = "https://index.docker.io/v1" + validServerAddress = "https://registry.example.com/v1" validUsername = "linus" validServerAddress2 = "https://example.com:5002" invalidServerAddress = "https://foobar.example.com" - missingCredsAddress = "https://missing.docker.io/v1" + missingCredsAddress = "https://missing.example.com/v1" ) var errProgramExited = fmt.Errorf("exited 1") From ffb3232f6ce8ee82bdd1188e2427ad29a6bce493 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 13:12:43 +0200 Subject: [PATCH 5/6] pass: 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 --- pass/pass_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pass/pass_test.go b/pass/pass_test.go index 8ab10f59..47e5e902 100644 --- a/pass/pass_test.go +++ b/pass/pass_test.go @@ -11,7 +11,7 @@ import ( func TestPassHelper(t *testing.T) { creds := &credentials.Credentials{ - ServerURL: "https://foobar.docker.io:2376/v1", + ServerURL: "https://foobar.example.com:2376/v1", Username: "nothing", Secret: "isthebestmeshuggahalbum", } @@ -54,12 +54,12 @@ func TestPassHelperCheckInit(t *testing.T) { func TestPassHelperList(t *testing.T) { creds := []*credentials.Credentials{ { - ServerURL: "https://foobar.docker.io:2376/v1", + ServerURL: "https://foobar.example.com:2376/v1", Username: "foo", Secret: "isthebestmeshuggahalbum", }, { - ServerURL: "https://foobar.docker.io:2375/v1", + ServerURL: "https://foobar.example.com:2375/v1", Username: "bar", Secret: "isthebestmeshuggahalbum", }, From a90e3fa153553f3d892c3f56f95ac3240d308366 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 27 May 2023 13:13:04 +0200 Subject: [PATCH 6/6] secretservice: 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 --- secretservice/secretservice_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/secretservice/secretservice_test.go b/secretservice/secretservice_test.go index 7609d656..21da1042 100644 --- a/secretservice/secretservice_test.go +++ b/secretservice/secretservice_test.go @@ -13,7 +13,7 @@ func TestSecretServiceHelper(t *testing.T) { t.Skip("test requires gnome-keyring but travis CI doesn't have it") creds := &credentials.Credentials{ - ServerURL: "https://foobar.docker.io:2376/v1", + ServerURL: "https://foobar.example.com:2376/v1", Username: "foobar", Secret: "foobarbaz", }