MM-41294: Allow team scheme APIs to be accessed with a professional l… (#21660)
* MM-41294: Allow team scheme APIs to be accessed with a professional license. * MM-41294: Adds tests.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e7a8d8426
Коммит
b0001f7cad
@@ -33,7 +33,7 @@ func createScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddEventParameter("scheme", scheme)
|
||||
|
||||
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Channels().License() == nil || (!*c.App.Channels().License().Features.CustomPermissionsSchemes && c.App.Channels().License().SkuShortName != model.LicenseShortSkuProfessional) {
|
||||
c.Err = model.NewAppError("Api4.CreateScheme", "api.scheme.create_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func patchScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddEventParameter("scheme_patch", patch)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Channels().License() == nil || (!*c.App.Channels().License().Features.CustomPermissionsSchemes && c.App.Channels().License().SkuShortName != model.LicenseShortSkuProfessional) {
|
||||
c.Err = model.NewAppError("Api4.PatchScheme", "api.scheme.patch_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -239,7 +239,7 @@ func deleteScheme(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddEventParameter("scheme_id", c.Params.SchemeId)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if c.App.Channels().License() == nil || !*c.App.Channels().License().Features.CustomPermissionsSchemes {
|
||||
if c.App.Channels().License() == nil || (!*c.App.Channels().License().Features.CustomPermissionsSchemes && c.App.Channels().License().SkuShortName != model.LicenseShortSkuProfessional) {
|
||||
c.Err = model.NewAppError("Api4.DeleteScheme", "api.scheme.delete_scheme.license.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -150,6 +150,31 @@ func TestCreateScheme(t *testing.T) {
|
||||
_, r6, _ := th.SystemAdminClient.CreateScheme(scheme6)
|
||||
CheckNotImplementedStatus(t, r6)
|
||||
|
||||
// Create scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
|
||||
lic := &model.License{
|
||||
Features: &model.Features{
|
||||
CustomPermissionsSchemes: model.NewBool(false),
|
||||
},
|
||||
Customer: &model.Customer{
|
||||
Name: "TestName",
|
||||
Email: "test@example.com",
|
||||
},
|
||||
SkuName: "SKU NAME",
|
||||
SkuShortName: model.LicenseShortSkuProfessional,
|
||||
StartsAt: model.GetMillis() - 1000,
|
||||
ExpiresAt: model.GetMillis() + 100000,
|
||||
}
|
||||
th.App.Srv().SetLicense(lic)
|
||||
scheme6b := &model.Scheme{
|
||||
DisplayName: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Scope: model.SchemeScopeTeam,
|
||||
}
|
||||
_, resp, err := th.SystemAdminClient.CreateScheme(scheme6b)
|
||||
require.NoError(t, err)
|
||||
CheckCreatedStatus(t, resp)
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.LoginSystemAdmin()
|
||||
@@ -579,6 +604,24 @@ func TestPatchScheme(t *testing.T) {
|
||||
_, r11, _ := th.SystemAdminClient.PatchScheme(s6.Id, schemePatch)
|
||||
CheckNotImplementedStatus(t, r11)
|
||||
|
||||
// Patch scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
|
||||
lic := &model.License{
|
||||
Features: &model.Features{
|
||||
CustomPermissionsSchemes: model.NewBool(false),
|
||||
},
|
||||
Customer: &model.Customer{
|
||||
Name: "TestName",
|
||||
Email: "test@example.com",
|
||||
},
|
||||
SkuName: "SKU NAME",
|
||||
SkuShortName: model.LicenseShortSkuProfessional,
|
||||
StartsAt: model.GetMillis() - 1000,
|
||||
ExpiresAt: model.GetMillis() + 100000,
|
||||
}
|
||||
th.App.Srv().SetLicense(lic)
|
||||
_, _, err = th.SystemAdminClient.PatchScheme(s6.Id, schemePatch)
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.LoginSystemAdmin()
|
||||
@@ -745,6 +788,15 @@ func TestDeleteScheme(t *testing.T) {
|
||||
s1, _, err := th.SystemAdminClient.CreateScheme(scheme1)
|
||||
require.NoError(t, err)
|
||||
|
||||
scheme2 := &model.Scheme{
|
||||
DisplayName: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
Description: model.NewId(),
|
||||
Scope: model.SchemeScopeChannel,
|
||||
}
|
||||
s2, _, err := th.SystemAdminClient.CreateScheme(scheme2)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Test with unknown ID.
|
||||
r2, err := th.SystemAdminClient.DeleteScheme(model.NewId())
|
||||
require.Error(t, err)
|
||||
@@ -766,6 +818,24 @@ func TestDeleteScheme(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
CheckNotImplementedStatus(t, r5)
|
||||
|
||||
// Delete scheme with a Professional SKU license but no explicit 'custom_permissions_schemes' license feature.
|
||||
lic := &model.License{
|
||||
Features: &model.Features{
|
||||
CustomPermissionsSchemes: model.NewBool(false),
|
||||
},
|
||||
Customer: &model.Customer{
|
||||
Name: "TestName",
|
||||
Email: "test@example.com",
|
||||
},
|
||||
SkuName: "SKU NAME",
|
||||
SkuShortName: model.LicenseShortSkuProfessional,
|
||||
StartsAt: model.GetMillis() - 1000,
|
||||
ExpiresAt: model.GetMillis() + 100000,
|
||||
}
|
||||
th.App.Srv().SetLicense(lic)
|
||||
_, err = th.SystemAdminClient.DeleteScheme(s2.Id)
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.SetPhase2PermissionsMigrationStatus(false)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
|
||||
Ссылка в новой задаче
Block a user