Add test case to cover non-empty auth entry

Signed-off-by: Jon Johnson <jonjohnson@google.com>
(cherry picked from commit 415f608620)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Jon Johnson 2019-10-02 12:41:50 -07:00 committed by Sebastiaan van Stijn
parent a1c4a0f9e8
commit 41b01f1319
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 23 additions and 15 deletions

View File

@ -389,23 +389,31 @@ func TestLoadFromReaderWithUsernamePassword(t *testing.T) {
Username: "user",
Password: "pass",
}
cf := ConfigFile{
AuthConfigs: map[string]types.AuthConfig{
"example.com/foo": want,
for _, tc := range []types.AuthConfig{
want,
types.AuthConfig{
Auth: encodeAuth(&want),
},
} {
cf := ConfigFile{
AuthConfigs: map[string]types.AuthConfig{
"example.com/foo": tc,
},
}
b, err := json.Marshal(cf)
assert.NilError(t, err)
err = configFile.LoadFromReader(bytes.NewReader(b))
assert.NilError(t, err)
got, err := configFile.GetAuthConfig("example.com/foo")
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(want.Username, got.Username))
assert.Check(t, is.DeepEqual(want.Password, got.Password))
}
b, err := json.Marshal(cf)
assert.NilError(t, err)
err = configFile.LoadFromReader(bytes.NewReader(b))
assert.NilError(t, err)
got, err := configFile.GetAuthConfig("example.com/foo")
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(want.Username, got.Username))
assert.Check(t, is.DeepEqual(want.Password, got.Password))
}
func TestCheckKubernetesConfigurationRaiseAnErrorOnInvalidValue(t *testing.T) {