-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject multiple auth schemes at the same time
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -450,6 +450,39 @@ func TestBuildNotifierConfig(t *testing.T) { | |
}, | ||
err: errors.New("parse \"http://example.local\\x7f\": net/url: invalid control character in URL"), | ||
}, | ||
{ | ||
name: "basic auth and oauth provided at the same time", | ||
cfg: &Config{ | ||
AlertmanagerURL: "http://alertmanager.default.svc.cluster.local/alertmanager", | ||
Notifier: NotifierConfig{ | ||
BasicAuth: util.BasicAuth{ | ||
Username: "test-user", | ||
}, | ||
OAuth2: OAuth2Config{ | ||
ClientID: "oauth2-client-id", | ||
ClientSecret: flagext.SecretWithValue("test"), | ||
TokenURL: "https://oauth2-token-endpoint.local/token", | ||
Scopes: flagext.StringSlice([]string{"action-1", "action-2"}), | ||
}, | ||
}, | ||
}, | ||
err: errRulerSimultaneousBasicAuthAndOAuth, | ||
}, | ||
{ | ||
name: "basic auth via URL and oauth provided at the same time", | ||
cfg: &Config{ | ||
AlertmanagerURL: "http://marco:[email protected]/alertmanager", | ||
Notifier: NotifierConfig{ | ||
OAuth2: OAuth2Config{ | ||
ClientID: "oauth2-client-id", | ||
ClientSecret: flagext.SecretWithValue("test"), | ||
TokenURL: "https://oauth2-token-endpoint.local/token", | ||
Scopes: flagext.StringSlice([]string{"action-1", "action-2"}), | ||
}, | ||
}, | ||
}, | ||
err: errRulerSimultaneousBasicAuthAndOAuth, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|