summaryrefslogtreecommitdiffstats
path: root/api/admin_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/admin_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/admin_test.go')
-rw-r--r--api/admin_test.go30
1 files changed, 28 insertions, 2 deletions
diff --git a/api/admin_test.go b/api/admin_test.go
index 8263ac038..dadc96c7d 100644
--- a/api/admin_test.go
+++ b/api/admin_test.go
@@ -8,13 +8,19 @@ import (
"strings"
"testing"
+ "github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
)
+func init() {
+ app.UseGlobalApp = false
+}
+
func TestGetLogs(t *testing.T) {
th := Setup().InitSystemAdmin().InitBasic()
+ defer th.TearDown()
if _, err := th.BasicClient.GetLogs(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -32,6 +38,7 @@ func TestGetClusterInfos(t *testing.T) {
t.SkipNow()
}
th := Setup().InitSystemAdmin().InitBasic()
+ defer th.TearDown()
if _, err := th.BasicClient.GetClusterStatus(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -44,6 +51,7 @@ func TestGetClusterInfos(t *testing.T) {
func TestGetAllAudits(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.GetAllAudits(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -58,6 +66,7 @@ func TestGetAllAudits(t *testing.T) {
func TestGetConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.GetConfig(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -104,6 +113,7 @@ func TestGetConfig(t *testing.T) {
func TestReloadConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.ReloadConfig(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -119,6 +129,7 @@ func TestReloadConfig(t *testing.T) {
func TestInvalidateAllCache(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.InvalidateAllCaches(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -131,6 +142,7 @@ func TestInvalidateAllCache(t *testing.T) {
func TestSaveConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.SaveConfig(utils.Cfg); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -147,6 +159,7 @@ func TestSaveConfig(t *testing.T) {
func TestRecycleDatabaseConnection(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.RecycleDatabaseConnection(); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -159,6 +172,7 @@ func TestRecycleDatabaseConnection(t *testing.T) {
func TestEmailTest(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
SendEmailNotifications := utils.Cfg.EmailSettings.SendEmailNotifications
SMTPServer := utils.Cfg.EmailSettings.SMTPServer
@@ -191,6 +205,7 @@ func TestEmailTest(t *testing.T) {
func TestLdapTest(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.TestLdap(utils.Cfg); err == nil {
t.Fatal("Shouldn't have permissions")
@@ -203,6 +218,8 @@ func TestLdapTest(t *testing.T) {
func TestGetTeamAnalyticsStandard(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+
th.CreatePrivateChannel(th.BasicClient, th.BasicTeam)
if _, err := th.BasicClient.GetTeamAnalytics(th.BasicTeam.Id, "standard"); err == nil {
@@ -432,6 +449,7 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
func TestGetTeamAnalyticsExtra(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
th.CreatePost(th.BasicClient, th.BasicChannel)
@@ -568,6 +586,7 @@ func TestGetTeamAnalyticsExtra(t *testing.T) {
func TestAdminResetMfa(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
if _, err := th.BasicClient.AdminResetMfa("12345678901234567890123456"); err == nil {
t.Fatal("should have failed - not an admin")
@@ -590,12 +609,14 @@ func TestAdminResetMfa(t *testing.T) {
func TestAdminResetPassword(t *testing.T) {
th := Setup().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.SystemAdminClient
team := th.SystemAdminTeam
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
- LinkUserToTeam(user, team)
+ th.LinkUserToTeam(user, team)
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
if _, err := Client.AdminResetPassword("", "newpwd1"); err == nil {
@@ -617,7 +638,7 @@ func TestAdminResetPassword(t *testing.T) {
authData := model.NewId()
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: &authData, AuthService: "random"}
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
- LinkUserToTeam(user2, team)
+ th.LinkUserToTeam(user2, team)
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
if _, err := Client.AdminResetPassword(user.Id, "newpwd1"); err != nil {
@@ -635,6 +656,8 @@ func TestAdminResetPassword(t *testing.T) {
func TestAdminLdapSyncNow(t *testing.T) {
th := Setup().InitSystemAdmin()
+ defer th.TearDown()
+
Client := th.SystemAdminClient
if _, err := Client.LdapSyncNow(); err != nil {
@@ -645,6 +668,7 @@ func TestAdminLdapSyncNow(t *testing.T) {
// Needs more work
func TestGetRecentlyActiveUsers(t *testing.T) {
th := Setup().InitBasic()
+ defer th.TearDown()
if userMap, err := th.BasicClient.GetRecentlyActiveUsers(th.BasicTeam.Id); err != nil {
t.Fatal(err)
@@ -655,6 +679,8 @@ func TestGetRecentlyActiveUsers(t *testing.T) {
func TestDisableAPIv3(t *testing.T) {
th := Setup().InitBasic()
+ defer th.TearDown()
+
Client := th.BasicClient
enableAPIv3 := *utils.Cfg.ServiceSettings.EnableAPIv3