github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/api4/cluster_test.go (about) 1 // Copyright (c) 2015-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/stretchr/testify/require" 10 11 "github.com/masterhung0112/hk_server/v5/model" 12 ) 13 14 func TestGetClusterStatus(t *testing.T) { 15 th := Setup(t) 16 defer th.TearDown() 17 18 t.Run("as system user", func(t *testing.T) { 19 _, resp := th.Client.GetClusterStatus() 20 CheckForbiddenStatus(t, resp) 21 }) 22 23 t.Run("as system admin", func(t *testing.T) { 24 infos, resp := th.SystemAdminClient.GetClusterStatus() 25 CheckNoError(t, resp) 26 27 require.NotNil(t, infos, "cluster status should not be nil") 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 }