diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-24 09:00:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 09:00:05 -0700 |
commit | 2a2af0e390e0323e02919598881783f38131b5ee (patch) | |
tree | e8e9dc4e3d7aecb93f0b67b1f6dcf238af7deadb /api/oauth_test.go | |
parent | 673df81669ebb1f8ec278f3cb86fadcc09f5d030 (diff) | |
download | chat-2a2af0e390e0323e02919598881783f38131b5ee.tar.gz chat-2a2af0e390e0323e02919598881783f38131b5ee.tar.bz2 chat-2a2af0e390e0323e02919598881783f38131b5ee.zip |
eliminate more utils.Cfg references (#7701)
Diffstat (limited to 'api/oauth_test.go')
-rw-r--r-- | api/oauth_test.go | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/api/oauth_test.go b/api/oauth_test.go index 1510e3520..0b18a4e47 100644 --- a/api/oauth_test.go +++ b/api/oauth_test.go @@ -489,74 +489,6 @@ func TestOAuthDeleteApp(t *testing.T) { } } -/*func TestOAuthAuthorize(t *testing.T) { - if testing.Short() { - t.SkipNow() - } - - th := Setup().InitBasic() - Client := th.BasicClient - - enableOAuth := utils.Cfg.ServiceSettings.EnableOAuthServiceProvider - adminOnly := *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations - defer func() { - utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuth - *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly - utils.SetDefaultRolesBasedOnConfig() - }() - utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = false - *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false - utils.SetDefaultRolesBasedOnConfig() - - if !utils.Cfg.ServiceSettings.EnableOAuthServiceProvider { - if r, err := HttpGet(Client.Url+"/oauth/authorize", Client.HttpClient, "", true); err == nil { - t.Fatal("should have failed - oauth providing turned off") - closeBody(r) - } - } - - utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true - if r, err := HttpGet(Client.Url+"/oauth/authorize", Client.HttpClient, "", true); err == nil { - t.Fatal("should have failed - scope not provided") - closeBody(r) - } - - if r, err := HttpGet(Client.Url+"/oauth/authorize?client_id=bad&&redirect_uri=http://example.com&response_type="+model.AUTHCODE_RESPONSE_TYPE, Client.HttpClient, "", true); err == nil { - t.Fatal("should have failed - scope not provided") - closeBody(r) - } - - // register an app to authorize it - oauthApp := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://example.com"}} - oauthApp = Client.Must(Client.RegisterApp(oauthApp)).Data.(*model.OAuthApp) - if r, err := HttpGet(Client.Url+"/oauth/authorize?client_id="+oauthApp.Id+"&&redirect_uri=http://example.com&response_type="+model.AUTHCODE_RESPONSE_TYPE, Client.HttpClient, "", true); err == nil { - t.Fatal("should have failed - user not logged") - closeBody(r) - } - - authToken := Client.AuthType + " " + Client.AuthToken - if _, err := HttpGet(Client.Url+"/oauth/authorize?client_id="+oauthApp.Id+"&redirect_uri=http://bad-redirect.com&response_type="+model.AUTHCODE_RESPONSE_TYPE, Client.HttpClient, authToken, true); err == nil { - t.Fatal("should have failed - bad redirect uri") - } - - if _, err := HttpGet(Client.Url+"/oauth/authorize?client_id="+oauthApp.Id+"&redirect_uri=https://example.com&response_type="+model.AUTHCODE_RESPONSE_TYPE, Client.HttpClient, authToken, true); err != nil { - t.Fatal(err) - } - - // lets authorize the app - if _, err := Client.AllowOAuth(model.AUTHCODE_RESPONSE_TYPE, oauthApp.Id, oauthApp.CallbackUrls[0], "user", ""); err != nil { - t.Fatal(err) - } - - if r, err := HttpGet(Client.Url+"/oauth/authorize?client_id="+oauthApp.Id+"&&redirect_uri="+oauthApp.CallbackUrls[0]+"&response_type="+model.AUTHCODE_RESPONSE_TYPE, - Client.HttpClient, authToken, true); err != nil { - // it will return an error as there is no connection to https://nowhere.com - if r != nil { - closeBody(r) - } - } -}*/ - func TestOAuthAccessToken(t *testing.T) { if testing.Short() { t.SkipNow() |