github.com/vnforks/kid@v5.11.1+incompatible/api4/cluster_test.go (about)

     1  // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package api4
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/mattermost/mattermost-server/model"
    10  )
    11  
    12  func TestGetClusterStatus(t *testing.T) {
    13  	th := Setup().InitBasic()
    14  	defer th.TearDown()
    15  
    16  	t.Run("as system user", func(t *testing.T) {
    17  		_, resp := th.Client.GetClusterStatus()
    18  		CheckForbiddenStatus(t, resp)
    19  	})
    20  
    21  	t.Run("as system admin", func(t *testing.T) {
    22  		infos, resp := th.SystemAdminClient.GetClusterStatus()
    23  		CheckNoError(t, resp)
    24  
    25  		if infos == nil {
    26  			t.Fatal("should not be nil")
    27  		}
    28  	})
    29  
    30  	t.Run("as restricted system admin", func(t *testing.T) {
    31  		th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true })
    32  
    33  		_, resp := th.SystemAdminClient.GetClusterStatus()
    34  		CheckForbiddenStatus(t, resp)
    35  	})
    36  }