Skip to content

Commit

Permalink
Merge pull request #4655 from StealthyCoder/4653-fix-credential-helper
Browse files Browse the repository at this point in the history
Fix setting ServerAddress property in NativeStore
  • Loading branch information
thaJeztah authored Nov 13, 2023
2 parents 1862725 + b24e7f8 commit 2b521e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cli/config/credentials/native_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (c *nativeStore) Get(serverAddress string) (types.AuthConfig, error) {
auth.Username = creds.Username
auth.IdentityToken = creds.IdentityToken
auth.Password = creds.Password
auth.ServerAddress = creds.ServerAddress

return auth, nil
}
Expand All @@ -76,6 +77,9 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
ac.Username = creds.Username
ac.Password = creds.Password
ac.IdentityToken = creds.IdentityToken
if ac.ServerAddress == "" {
ac.ServerAddress = creds.ServerAddress
}
authConfigs[registry] = ac
}

Expand Down
8 changes: 5 additions & 3 deletions cli/config/credentials/native_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ func TestNativeStoreGet(t *testing.T) {
assert.NilError(t, err)

expected := types.AuthConfig{
Username: "foo",
Password: "bar",
Email: "[email protected]",
Username: "foo",
Password: "bar",
Email: "[email protected]",
ServerAddress: validServerAddress,
}
assert.Check(t, is.DeepEqual(expected, actual))
}
Expand All @@ -169,6 +170,7 @@ func TestNativeStoreGetIdentityToken(t *testing.T) {
expected := types.AuthConfig{
IdentityToken: "abcd1234",
Email: "[email protected]",
ServerAddress: validServerAddress2,
}
assert.Check(t, is.DeepEqual(expected, actual))
}
Expand Down

0 comments on commit 2b521e4

Please sign in to comment.