mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-21 23:27:57 +00:00
e83f60cc0b
We already have a MS Teams integration but MS Teams is discontinuing the incoming webhook feature used by this integration: https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ MS Teams now recommends to use Workflows to post messages via webhook. MS Teams does not provide backwards compatibility or an upgrade path for existing integrations. This commit adds a new "msteamsw" integration which uses MS Teams Workflows to post notifications. It also updates the instructions and illustrations in the "Add MS Teams Integration" page. cc: #1024
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from django.test.utils import override_settings
|
|
|
|
from hc.api.models import Channel
|
|
from hc.test import BaseTestCase
|
|
|
|
|
|
class AddMsTeamsTestCase(BaseTestCase):
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.url = f"/projects/{self.project.code}/add_msteams/"
|
|
|
|
def test_instructions_work(self) -> None:
|
|
self.client.login(username="alice@example.org", password="password")
|
|
r = self.client.get(self.url)
|
|
self.assertContains(r, "Integration Settings", status_code=200)
|
|
|
|
def test_it_works(self) -> None:
|
|
form = {"value": "https://example.com/foo"}
|
|
|
|
self.client.login(username="alice@example.org", password="password")
|
|
r = self.client.post(self.url, form)
|
|
self.assertRedirects(r, self.channels_url)
|
|
|
|
c = Channel.objects.get()
|
|
self.assertEqual(c.kind, "msteamsw")
|
|
self.assertEqual(c.value, "https://example.com/foo")
|
|
self.assertEqual(c.project, self.project)
|
|
|
|
def test_it_requires_rw_access(self) -> None:
|
|
self.bobs_membership.role = "r"
|
|
self.bobs_membership.save()
|
|
|
|
self.client.login(username="bob@example.org", password="password")
|
|
r = self.client.get(self.url)
|
|
self.assertEqual(r.status_code, 403)
|
|
|
|
@override_settings(MSTEAMS_ENABLED=False)
|
|
def test_it_handles_disabled_integration(self) -> None:
|
|
self.client.login(username="alice@example.org", password="password")
|
|
r = self.client.get(self.url)
|
|
self.assertEqual(r.status_code, 404)
|