summaryrefslogtreecommitdiffstats
path: root/api/oauth_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-02 03:50:56 -0500
committerGeorge Goldberg <george@gberg.me>2017-10-02 09:50:56 +0100
commit9bc7af0c5704bbf73f8240b4569d5ea215352e39 (patch)
treeb17ddafc83ab43ccdce2116e83358299a08a50a6 /api/oauth_test.go
parentb84736e9b6401df0c6eeab9950bef09458a6aefd (diff)
downloadchat-9bc7af0c5704bbf73f8240b4569d5ea215352e39.tar.gz
chat-9bc7af0c5704bbf73f8240b4569d5ea215352e39.tar.bz2
chat-9bc7af0c5704bbf73f8240b4569d5ea215352e39.zip
Don't use global app for api / api4 tests (#7528)
* don't use global app for api / api4 tests * put sleep back. we're gonna have to do some goroutine wrangling * fix oauth test config assumptions * jobs package, i'm comin' for you next * app test fix * try increasing sleep a little
Diffstat (limited to 'api/oauth_test.go')
-rw-r--r--api/oauth_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/oauth_test.go b/api/oauth_test.go
index 317478b0a..0e952768e 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -19,6 +19,8 @@ import (
func TestOAuthRegisterApp(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
oauthApp := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}, IsTrusted: true}
@@ -108,6 +110,8 @@ func TestOAuthRegisterApp(t *testing.T) {
func TestOAuthAllow(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -193,6 +197,8 @@ func TestOAuthAllow(t *testing.T) {
func TestOAuthGetAppsByUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -263,6 +269,8 @@ func TestOAuthGetAppsByUser(t *testing.T) {
func TestOAuthGetAppInfo(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -291,6 +299,8 @@ func TestOAuthGetAppInfo(t *testing.T) {
func TestOAuthGetAuthorizedApps(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -324,6 +334,8 @@ func TestOAuthGetAuthorizedApps(t *testing.T) {
func TestOAuthDeauthorizeApp(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -375,6 +387,8 @@ func TestOAuthDeauthorizeApp(t *testing.T) {
func TestOAuthRegenerateAppSecret(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -416,6 +430,8 @@ func TestOAuthRegenerateAppSecret(t *testing.T) {
func TestOAuthDeleteApp(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.BasicClient
AdminClient := th.SystemAdminClient
@@ -547,6 +563,8 @@ func TestOAuthAccessToken(t *testing.T) {
}
th := Setup().InitBasic()
+ defer th.TearDown()
+
Client := th.BasicClient
enableOAuth := utils.Cfg.ServiceSettings.EnableOAuthServiceProvider
@@ -764,6 +782,8 @@ func TestOAuthComplete(t *testing.T) {
}
th := Setup().InitBasic()
+ defer th.TearDown()
+
Client := th.BasicClient
if r, err := HttpGet(Client.Url+"/login/gitlab/complete", Client.HttpClient, "", true); err == nil {
@@ -806,6 +826,14 @@ func TestOAuthComplete(t *testing.T) {
// We are going to use mattermost as the provider emulating gitlab
utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
+ adminOnly := *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
+ defer func() {
+ *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly
+ utils.SetDefaultRolesBasedOnConfig()
+ }()
+ *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
+ utils.SetDefaultRolesBasedOnConfig()
+
oauthApp := &model.OAuthApp{
Name: "TestApp5" + model.NewId(),
Homepage: "https://nowhere.com",