summaryrefslogtreecommitdiffstats
path: root/api/webhook_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/webhook_test.go')
-rw-r--r--api/webhook_test.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/api/webhook_test.go b/api/webhook_test.go
index dc708cf76..8a170bd9a 100644
--- a/api/webhook_test.go
+++ b/api/webhook_test.go
@@ -716,19 +716,17 @@ func TestUpdateOutgoingHook(t *testing.T) {
Client.Logout()
Client.Must(Client.LoginById(user2.Id, user2.Password))
Client.SetTeamId(team.Id)
- t.Run("UpdateByUserWithoutPermissions", func(t *testing.T) {
- if _, err := Client.UpdateOutgoingWebhook(hook); err == nil {
- t.Fatal("should have failed - user does not have permissions to manage webhooks")
- }
+ if _, err := Client.UpdateOutgoingWebhook(hook); err == nil {
+ t.Fatal("should have failed - user does not have permissions to manage webhooks")
+ }
- *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
- utils.SetDefaultRolesBasedOnConfig()
- t.Run("WithoutOnlyAdminIntegrations", func(t *testing.T) {
- if _, err := Client.UpdateOutgoingWebhook(hook); err != nil {
- t.Fatal("update webhook failed when admin only integrations is turned off")
- }
- })
- })
+ *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
+ utils.SetDefaultRolesBasedOnConfig()
+ hook2 := createOutgoingWebhook(channel1.Id, []string{"http://nowhereelse.com"}, []string{"dogs"}, Client, t)
+
+ if _, err := Client.UpdateOutgoingWebhook(hook2); err != nil {
+ t.Fatal("update webhook failed when admin only integrations is turned off")
+ }
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = true
utils.SetDefaultRolesBasedOnConfig()
@@ -919,6 +917,11 @@ func TestRegenOutgoingHookToken(t *testing.T) {
}
}
+ Client.SetTeamId(model.NewId())
+ if _, err := Client.RegenOutgoingWebhookToken(hook.Id); err == nil {
+ t.Fatal("should have failed - wrong team id")
+ }
+
Client.Logout()
Client.Must(Client.LoginById(user2.Id, user2.Password))
Client.SetTeamId(team.Id)