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

Merge pull request #294 from thaJeztah/use_designated_domains_step1

use designated domains in tests (RFC2606) (step 1)
This commit is contained in:
Sebastiaan van Stijn
2023-06-27 13:48:45 +02:00
committed by GitHub
6 changed files with 56 additions and 56 deletions
+2 -2
View File
@@ -11,11 +11,11 @@ import (
) )
const ( const (
validServerAddress = "https://index.docker.io/v1" validServerAddress = "https://registry.example.com/v1"
validUsername = "linus" validUsername = "linus"
validServerAddress2 = "https://example.com:5002" validServerAddress2 = "https://example.com:5002"
invalidServerAddress = "https://foobar.example.com" invalidServerAddress = "https://foobar.example.com"
missingCredsAddress = "https://missing.docker.io/v1" missingCredsAddress = "https://missing.example.com/v1"
) )
var errProgramExited = fmt.Errorf("exited 1") var errProgramExited = fmt.Errorf("exited 1")
+6 -6
View File
@@ -42,7 +42,7 @@ func (m *memoryStore) List() (map[string]string, error) {
} }
func TestStore(t *testing.T) { func TestStore(t *testing.T) {
const serverURL = "https://index.docker.io/v1/" const serverURL = "https://registry.example.com/v1/"
creds := &Credentials{ creds := &Credentials{
ServerURL: serverURL, ServerURL: serverURL,
Username: "foo", Username: "foo",
@@ -95,7 +95,7 @@ func TestStoreMissingServerURL(t *testing.T) {
func TestStoreMissingUsername(t *testing.T) { func TestStoreMissingUsername(t *testing.T) {
creds := &Credentials{ creds := &Credentials{
ServerURL: "https://index.docker.io/v1/", ServerURL: "https://registry.example.com/v1/",
Username: "", Username: "",
Secret: "bar", Secret: "bar",
} }
@@ -114,7 +114,7 @@ func TestStoreMissingUsername(t *testing.T) {
} }
func TestGet(t *testing.T) { func TestGet(t *testing.T) {
const serverURL = "https://index.docker.io/v1/" const serverURL = "https://registry.example.com/v1/"
creds := &Credentials{ creds := &Credentials{
ServerURL: serverURL, ServerURL: serverURL,
Username: "foo", Username: "foo",
@@ -156,7 +156,7 @@ func TestGet(t *testing.T) {
} }
func TestGetMissingServerURL(t *testing.T) { func TestGetMissingServerURL(t *testing.T) {
const serverURL = "https://index.docker.io/v1/" const serverURL = "https://registry.example.com/v1/"
creds := &Credentials{ creds := &Credentials{
ServerURL: serverURL, ServerURL: serverURL,
Username: "foo", Username: "foo",
@@ -182,7 +182,7 @@ func TestGetMissingServerURL(t *testing.T) {
} }
func TestErase(t *testing.T) { func TestErase(t *testing.T) {
const serverURL = "https://index.docker.io/v1/" const serverURL = "https://registry.example.com/v1/"
creds := &Credentials{ creds := &Credentials{
ServerURL: serverURL, ServerURL: serverURL,
Username: "foo", Username: "foo",
@@ -211,7 +211,7 @@ func TestErase(t *testing.T) {
} }
func TestEraseMissingServerURL(t *testing.T) { func TestEraseMissingServerURL(t *testing.T) {
const serverURL = "https://index.docker.io/v1/" const serverURL = "https://registry.example.com/v1/"
creds := &Credentials{ creds := &Credentials{
ServerURL: serverURL, ServerURL: serverURL,
Username: "foo", Username: "foo",
+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{}
+3 -3
View File
@@ -11,7 +11,7 @@ import (
func TestPassHelper(t *testing.T) { func TestPassHelper(t *testing.T) {
creds := &credentials.Credentials{ creds := &credentials.Credentials{
ServerURL: "https://foobar.docker.io:2376/v1", ServerURL: "https://foobar.example.com:2376/v1",
Username: "nothing", Username: "nothing",
Secret: "isthebestmeshuggahalbum", Secret: "isthebestmeshuggahalbum",
} }
@@ -54,12 +54,12 @@ func TestPassHelperCheckInit(t *testing.T) {
func TestPassHelperList(t *testing.T) { func TestPassHelperList(t *testing.T) {
creds := []*credentials.Credentials{ creds := []*credentials.Credentials{
{ {
ServerURL: "https://foobar.docker.io:2376/v1", ServerURL: "https://foobar.example.com:2376/v1",
Username: "foo", Username: "foo",
Secret: "isthebestmeshuggahalbum", Secret: "isthebestmeshuggahalbum",
}, },
{ {
ServerURL: "https://foobar.docker.io:2375/v1", ServerURL: "https://foobar.example.com:2375/v1",
Username: "bar", Username: "bar",
Secret: "isthebestmeshuggahalbum", Secret: "isthebestmeshuggahalbum",
}, },
+16 -16
View File
@@ -14,39 +14,39 @@ func TestHelperParseURL(t *testing.T) {
err error err error
}{ }{
{ {
url: "foobar.docker.io", url: "foobar.example.com",
expectedURL: "//foobar.docker.io", expectedURL: "//foobar.example.com",
}, },
{ {
url: "foobar.docker.io:2376", url: "foobar.example.com:2376",
expectedURL: "//foobar.docker.io:2376", expectedURL: "//foobar.example.com:2376",
}, },
{ {
url: "//foobar.docker.io:2376", url: "//foobar.example.com:2376",
expectedURL: "//foobar.docker.io:2376", expectedURL: "//foobar.example.com:2376",
}, },
{ {
url: "http://foobar.docker.io:2376", url: "http://foobar.example.com:2376",
expectedURL: "http://foobar.docker.io:2376", expectedURL: "http://foobar.example.com:2376",
}, },
{ {
url: "https://foobar.docker.io:2376", url: "https://foobar.example.com:2376",
expectedURL: "https://foobar.docker.io:2376", expectedURL: "https://foobar.example.com:2376",
}, },
{ {
url: "https://foobar.docker.io:2376/some/path", url: "https://foobar.example.com:2376/some/path",
expectedURL: "https://foobar.docker.io:2376/some/path", expectedURL: "https://foobar.example.com:2376/some/path",
}, },
{ {
url: "https://foobar.docker.io:2376/some/other/path?foo=bar", url: "https://foobar.example.com:2376/some/other/path?foo=bar",
expectedURL: "https://foobar.docker.io:2376/some/other/path", expectedURL: "https://foobar.example.com:2376/some/other/path",
}, },
{ {
url: "/foobar.docker.io", url: "/foobar.example.com",
err: errors.New("no hostname in URL"), 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"), err: errors.New("unsupported scheme: ftp"),
}, },
} }
+1 -1
View File
@@ -13,7 +13,7 @@ func TestSecretServiceHelper(t *testing.T) {
t.Skip("test requires gnome-keyring but travis CI doesn't have it") t.Skip("test requires gnome-keyring but travis CI doesn't have it")
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",
} }