diff options
author | George Goldberg <george@gberg.me> | 2017-03-15 19:32:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 19:32:02 +0000 |
commit | 91d430b2a39a03b052cc103f73f44c68cbc96b2d (patch) | |
tree | da7c188407498aced674937c4802c8a9e848f280 /api4 | |
parent | 8568afe5b4fb4d26b14fbc0d21f088eaa490b314 (diff) | |
download | chat-91d430b2a39a03b052cc103f73f44c68cbc96b2d.tar.gz chat-91d430b2a39a03b052cc103f73f44c68cbc96b2d.tar.bz2 chat-91d430b2a39a03b052cc103f73f44c68cbc96b2d.zip |
Fix policy application in team edition. (#5771)
Diffstat (limited to 'api4')
-rw-r--r-- | api4/channel_test.go | 15 | ||||
-rw-r--r-- | api4/context.go | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go index c8faf7aa1..0f11edebc 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -91,10 +91,10 @@ func TestCreateChannel(t *testing.T) { }() *utils.Cfg.TeamSettings.RestrictPublicChannelCreation = model.PERMISSIONS_ALL *utils.Cfg.TeamSettings.RestrictPrivateChannelCreation = model.PERMISSIONS_ALL - utils.SetDefaultRolesBasedOnConfig() utils.IsLicensed = true utils.License = &model.License{Features: &model.Features{}} utils.License.Features.SetDefaults() + utils.SetDefaultRolesBasedOnConfig() channel.Name = GenerateTestChannelName() _, resp = Client.CreateChannel(channel) @@ -160,6 +160,19 @@ func TestCreateChannel(t *testing.T) { _, resp = th.SystemAdminClient.CreateChannel(private) CheckNoError(t, resp) + // Check that if unlicensed the policy restriction is not enforced. + utils.IsLicensed = false + utils.License = nil + utils.SetDefaultRolesBasedOnConfig() + + channel.Name = GenerateTestChannelName() + _, resp = Client.CreateChannel(channel) + CheckNoError(t, resp) + + private.Name = GenerateTestChannelName() + _, resp = Client.CreateChannel(private) + CheckNoError(t, resp) + if r, err := Client.DoApiPost("/channels", "garbage"); err == nil { t.Fatal("should have errored") } else { diff --git a/api4/context.go b/api4/context.go index c30a975f2..7136a9b46 100644 --- a/api4/context.go +++ b/api4/context.go @@ -133,7 +133,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId) - w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash)) + w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash, utils.IsLicensed)) if einterfaces.GetClusterInterface() != nil { w.Header().Set(model.HEADER_CLUSTER_ID, einterfaces.GetClusterInterface().GetClusterId()) } |