From 2a2af0e390e0323e02919598881783f38131b5ee Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 24 Oct 2017 09:00:05 -0700 Subject: eliminate more utils.Cfg references (#7701) --- api/oauth_test.go | 68 ------------------------------------------------------- 1 file changed, 68 deletions(-) (limited to 'api/oauth_test.go') 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() -- cgit v1.2.3-1-g7c22