diff --git a/src/prefect/blocks/notifications.py b/src/prefect/blocks/notifications.py index dba7a67de3e6..ae74bf05f05e 100644 --- a/src/prefect/blocks/notifications.py +++ b/src/prefect/blocks/notifications.py @@ -570,6 +570,10 @@ class MattermostWebhook(AbstractAppriseNotificationBlock): description="The hostname of your Mattermost server.", examples=["Mattermost.example.com"], ) + secure: bool = Field( + default=False, + description="Whether to use secure https connection.", + ) token: SecretStr = Field( default=..., @@ -621,6 +625,7 @@ def block_initialization(self) -> None: channels=self.channels, include_image=self.include_image, port=self.port, + secure=self.secure, ).url() # pyright: ignore[reportUnknownMemberType, reportUnknownArgumentType] incomplete type hints in apprise ) self._start_apprise_client(url) diff --git a/tests/blocks/test_notifications.py b/tests/blocks/test_notifications.py index bf1ac4224667..c2f4733305b1 100644 --- a/tests/blocks/test_notifications.py +++ b/tests/blocks/test_notifications.py @@ -170,6 +170,30 @@ async def test_notify_async(self): body="test", title="", notify_type=PREFECT_NOTIFY_TYPE_DEFAULT ) + def test_notify_secure(self): + with patch("apprise.Apprise", autospec=True) as AppriseMock: + apprise_instance_mock = AppriseMock.return_value + apprise_instance_mock.async_notify = AsyncMock() + + mm_block = MattermostWebhook( + hostname="example.com", token="token", secure=True, port=443 + ) + + @flow + def test_flow(): + mm_block.notify("test") + + test_flow() + + AppriseMock.assert_called_once() + apprise_instance_mock.add.assert_called_once_with( + f"mmosts://{mm_block.hostname}/{mm_block.token.get_secret_value()}/" + "?image=no&format=text&overflow=upstream" + ) + apprise_instance_mock.async_notify.assert_called_once_with( + body="test", title="", notify_type=PREFECT_NOTIFY_TYPE_DEFAULT + ) + def test_notify_sync(self): with patch("apprise.Apprise", autospec=True) as AppriseMock: apprise_instance_mock = AppriseMock.return_value