@@ -47,8 +47,10 @@ func (m *mockCommand) Output() ([]byte, error) {
4747 }
4848 case "get" :
4949 switch inS {
50- case validServerAddress , validServerAddress2 :
51- return []byte (`{"Username": "foo", "Password": "bar"}` ), nil
50+ case validServerAddress :
51+ return []byte (`{"Username": "foo", "Secret": "bar"}` ), nil
52+ case validServerAddress2 :
53+ return []byte (`{"Username": "<token>", "Secret": "abcd1234"}` ), nil
5254 case missingCredsAddress :
5355 return []byte (errCredentialsNotFound .Error ()), errCommandExited
5456 case invalidServerAddress :
@@ -118,6 +120,9 @@ func TestNativeStoreAddCredentials(t *testing.T) {
118120 if a .Password != "" {
119121 t .Fatalf ("expected password to be empty, got %s" , a .Password )
120122 }
123+ if a .IdentityToken != "" {
124+ t .Fatalf ("expected identity token to be empty, got %s" , a .IdentityToken )
125+ }
121126 if a .
Email != "[email protected] " {
122127 t .
Fatalf (
"expected email `[email protected] `, got %s" ,
a .
Email )
123128 }
@@ -174,11 +179,45 @@ func TestNativeStoreGet(t *testing.T) {
174179 if a .Password != "bar" {
175180 t .Fatalf ("expected password `bar`, got %s" , a .Password )
176181 }
182+ if a .IdentityToken != "" {
183+ t .Fatalf ("expected identity token to be empty, got %s" , a .IdentityToken )
184+ }
177185 if a .
Email != "[email protected] " {
178186 t .
Fatalf (
"expected email `[email protected] `, got %s" ,
a .
Email )
179187 }
180188}
181189
190+ func TestNativeStoreGetIdentityToken (t * testing.T ) {
191+ f := newConfigFile (map [string ]types.AuthConfig {
192+ validServerAddress2 : {
193+ 194+ },
195+ })
196+ f .CredentialsStore = "mock"
197+
198+ s := & nativeStore {
199+ commandFn : mockCommandFn ,
200+ fileStore : NewFileStore (f ),
201+ }
202+ a , err := s .Get (validServerAddress2 )
203+ if err != nil {
204+ t .Fatal (err )
205+ }
206+
207+ if a .Username != "" {
208+ t .Fatalf ("expected username to be empty, got %s" , a .Username )
209+ }
210+ if a .Password != "" {
211+ t .Fatalf ("expected password to be empty, got %s" , a .Password )
212+ }
213+ if a .IdentityToken != "abcd1234" {
214+ t .Fatalf ("expected identity token `abcd1234`, got %s" , a .IdentityToken )
215+ }
216+ if a .
Email != "[email protected] " {
217+ t .
Fatalf (
"expected email `[email protected] `, got %s" ,
a .
Email )
218+ }
219+ }
220+
182221func TestNativeStoreGetAll (t * testing.T ) {
183222 f := newConfigFile (map [string ]types.AuthConfig {
184223 validServerAddress : {
@@ -209,14 +248,20 @@ func TestNativeStoreGetAll(t *testing.T) {
209248 if as [validServerAddress ].Password != "bar" {
210249 t .Fatalf ("expected password `bar` for %s, got %s" , validServerAddress , as [validServerAddress ].Password )
211250 }
251+ if as [validServerAddress ].IdentityToken != "" {
252+ t .Fatalf ("expected identity to be empty for %s, got %s" , validServerAddress , as [validServerAddress ].IdentityToken )
253+ }
212254 if as [
validServerAddress ].
Email != "[email protected] " {
213255 t .
Fatalf (
"expected email `[email protected] ` for %s, got %s" ,
validServerAddress ,
as [
validServerAddress ].
Email )
214256 }
215- if as [validServerAddress2 ].Username != "foo" {
216- t .Fatalf ("expected username `foo` for %s, got %s" , validServerAddress2 , as [validServerAddress2 ].Username )
257+ if as [validServerAddress2 ].Username != "" {
258+ t .Fatalf ("expected username to be empty for %s, got %s" , validServerAddress2 , as [validServerAddress2 ].Username )
259+ }
260+ if as [validServerAddress2 ].Password != "" {
261+ t .Fatalf ("expected password to be empty for %s, got %s" , validServerAddress2 , as [validServerAddress2 ].Password )
217262 }
218- if as [validServerAddress2 ].Password != "bar " {
219- t .Fatalf ("expected password `bar ` for %s, got %s" , validServerAddress2 , as [validServerAddress2 ].Password )
263+ if as [validServerAddress2 ].IdentityToken != "abcd1234 " {
264+ t .Fatalf ("expected identity token `abcd1324 ` for %s, got %s" , validServerAddress2 , as [validServerAddress2 ].IdentityToken )
220265 }
221266 if as [
validServerAddress2 ].
Email != "[email protected] " {
222267 t .
Fatalf (
"expected email `[email protected] ` for %s, got %s" ,
validServerAddress2 ,
as [
validServerAddress2 ].
Email )
0 commit comments