-
Notifications
You must be signed in to change notification settings - Fork 232
pkg/git: AuthOptions.Validate() test improvements #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,14 @@ func TestAuthOptions_Validate(t *testing.T) { | |
| }, | ||
| wantErr: "invalid 'http' auth option: 'password' requires 'username' to be set", | ||
| }, | ||
| { | ||
| name: "Valid HTTP transport", | ||
| opts: AuthOptions{ | ||
| Transport: HTTP, | ||
| Username: "example", | ||
| Password: "foo", | ||
| }, | ||
| }, | ||
| { | ||
| name: "HTTPS transport with password requires user", | ||
| opts: AuthOptions{ | ||
|
|
@@ -84,6 +92,20 @@ func TestAuthOptions_Validate(t *testing.T) { | |
| }, | ||
| wantErr: "invalid 'https' auth option: 'password' requires 'username' to be set", | ||
| }, | ||
| { | ||
| name: "Valid HTTPS transport", | ||
| opts: AuthOptions{ | ||
| Transport: HTTPS, | ||
| Username: "example", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving one of these (HTTP or HTTPS test) would cover an additional test case: HTTP/S transport definition without any config, which should be valid as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. Thanks. |
||
| Password: "foo", | ||
| }, | ||
| }, | ||
| { | ||
| name: "Valid HTTPS without any config", | ||
| opts: AuthOptions{ | ||
| Transport: HTTPS, | ||
| }, | ||
| }, | ||
| { | ||
| name: "SSH transport requires identity", | ||
| opts: AuthOptions{ | ||
|
|
@@ -121,6 +143,27 @@ func TestAuthOptions_Validate(t *testing.T) { | |
| opts: AuthOptions{}, | ||
| wantErr: "no transport type set", | ||
| }, | ||
| { | ||
| name: "Valid SSH transport", | ||
| opts: AuthOptions{ | ||
| Transport: SSH, | ||
| Identity: []byte(privateKeyPassphraseFixture), | ||
| Password: "foobar", | ||
| KnownHosts: []byte(knownHostsFixture), | ||
| }, | ||
| }, | ||
| { | ||
| name: "No transport", | ||
| opts: AuthOptions{}, | ||
| wantErr: "no transport type set", | ||
| }, | ||
| { | ||
| name: "Unknown transport", | ||
| opts: AuthOptions{ | ||
| Transport: "foo", | ||
| }, | ||
| wantErr: "unknown transport 'foo'", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.