forked from notaryproject/notation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sylvia Lei <[email protected]>
- Loading branch information
Showing
15 changed files
with
203 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"oras.land/oras-go/v2/registry/remote/auth" | ||
) | ||
|
||
func TestSecureFlagOpts_Credential(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
opts *SecureFlagOpts | ||
want auth.Credential | ||
}{ | ||
{ | ||
name: "Username and password", | ||
opts: &SecureFlagOpts{ | ||
Username: "username", | ||
Password: "password", | ||
}, | ||
want: auth.Credential{ | ||
Username: "username", | ||
Password: "password", | ||
}, | ||
}, | ||
{ | ||
name: "Username only", | ||
opts: &SecureFlagOpts{ | ||
Username: "username", | ||
}, | ||
want: auth.Credential{ | ||
Username: "username", | ||
}, | ||
}, | ||
{ | ||
name: "Password only", | ||
opts: &SecureFlagOpts{ | ||
Password: "token", | ||
}, | ||
want: auth.Credential{ | ||
RefreshToken: "token", | ||
}, | ||
}, | ||
{ | ||
name: "Empty username and password", | ||
opts: &SecureFlagOpts{ | ||
Username: "", | ||
Password: "", | ||
}, | ||
want: auth.EmptyCredential, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.opts.Credential(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("SecureFlagOpts.Credential() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.