eliminate more utils.Cfg references (#7701)

Этот коммит содержится в:
Chris
2017-10-24 09:00:05 -07:00
коммит произвёл GitHub
родитель 673df81669
Коммит 2a2af0e390
14 изменённых файлов: 59 добавлений и 288 удалений

Просмотреть файл

@@ -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()