[MM-29845] Add a new handler to allow authentication via CWS API Key (#16319)
* Add a new handler to allow authentication via CWS API Key * Make error better * Add tests and cases for new handler functions * Move some code around * Add test for GetCloudSession function * unset the env after test completion * Remove white space * Change Info to Warn Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -26,6 +26,7 @@ func TestParseAuthTokenFromRequest(t *testing.T) {
|
||||
{"BEARER mytoken", "", "", "mytoken", TokenLocationHeader},
|
||||
{"", "mytoken", "", "mytoken", TokenLocationCookie},
|
||||
{"", "", "mytoken", "mytoken", TokenLocationQueryString},
|
||||
{"mytoken", "", "", "mytoken", TokenLocationCloudHeader},
|
||||
}
|
||||
|
||||
for testnum, tc := range cases {
|
||||
@@ -34,10 +35,12 @@ func TestParseAuthTokenFromRequest(t *testing.T) {
|
||||
pathname += "?access_token=" + tc.query
|
||||
}
|
||||
req := httptest.NewRequest("GET", pathname, nil)
|
||||
if tc.header != "" {
|
||||
switch tc.expectedLocation {
|
||||
case TokenLocationHeader:
|
||||
req.Header.Add(model.HEADER_AUTH, tc.header)
|
||||
}
|
||||
if tc.cookie != "" {
|
||||
case TokenLocationCloudHeader:
|
||||
req.Header.Add(model.HEADER_CLOUD_TOKEN, tc.header)
|
||||
case TokenLocationCookie:
|
||||
req.AddCookie(&http.Cookie{
|
||||
Name: model.SESSION_COOKIE_TOKEN,
|
||||
Value: tc.cookie,
|
||||
|
||||
Ссылка в новой задаче
Block a user