MM-47228 - restrict guest invitation flow if subscription plan does n… (#21195)
* MM-47228 - restrict guest invitation flow if subscription plan does not support it * fix i18n texts and add unit test * test the scenario where guest invites are blocked by subscription * cover the success scenarios for cloud free trial and paid subscription * fix go vet * use the cloud prefix for the sku * fix unit tests * check the licence value to determine if the guest accounts are enabled * remove unnecessary changes for getting the subscription information * restrict user demotion if guestAccounts is not available in license Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6e9b808efd
Коммит
9a804a96fe
@@ -3361,6 +3361,52 @@ func TestInviteGuestsToTeam(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestInviteGuest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
guest1 := th.GenerateTestEmail()
|
||||
guest2 := th.GenerateTestEmail()
|
||||
|
||||
emailList := []string{guest1, guest2}
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GuestAccountsSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
||||
|
||||
t.Run("Guest Account not available in license returns forbidden", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseWithFalseDefaults("guest_accounts"))
|
||||
|
||||
guestsInvite := model.GuestsInvite{
|
||||
Emails: emailList,
|
||||
Channels: []string{th.BasicChannel.Id},
|
||||
Message: "test message",
|
||||
}
|
||||
buf, err := json.Marshal(guestsInvite)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := th.SystemAdminClient.DoAPIPost("/teams/"+th.BasicTeam.Id+"/invite-guests/email", string(buf))
|
||||
|
||||
require.Equal(t, http.StatusForbidden, res.StatusCode)
|
||||
require.True(t, strings.Contains(err.Error(), "Guest accounts are disabled"))
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("Guest Account available in license returns OK", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("guest_accounts"))
|
||||
|
||||
guestsInvite := model.GuestsInvite{
|
||||
Emails: emailList,
|
||||
Channels: []string{th.BasicChannel.Id},
|
||||
Message: "test message",
|
||||
}
|
||||
buf, err := json.Marshal(guestsInvite)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := th.SystemAdminClient.DoAPIPost("/teams/"+th.BasicTeam.Id+"/invite-guests/email", string(buf))
|
||||
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTeamInviteInfo(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user