-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate from mattermost to slack notification and small test update #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request migrates messaging integration from Mattermost to Slack while updating tests, documentation, and dependencies for the vault-audit-filter project. The key changes are:
- Switching from Mattermost-specific implementations to Slack-based implementations for both API and webhook messaging.
- Updating tests and configuration examples to reflect the Slack integration.
- Revising dependency requirements and documentation to support the new Slack integration.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/messaging/messaging_test.go | Updated tests to use Slack integration with new messaging methods. |
| pkg/messaging/messaging.go | Replaced Mattermost client logic with Slack client logic. |
| pkg/forwarder/forwarder_test.go | Adjusted UDP forwarder tests to use local addresses. |
| pkg/auditserver/server_test.go | Updated tests messaging type strings from Mattermost to Slack. |
| pkg/auditserver/server.go | Updated AuditServer configuration to support Slack integrations. |
| go.mod | Removed Mattermost dependencies and added slack-go/slack. |
| README.md | Revised documentation to reflect Slack changes. |
| mockClient.On("PostMessage", "test-channel").Return(nil).Once() | ||
| err := messenger.Send(testMessage) | ||
| assert.NoError(t, err) | ||
| mockClient.AssertExpectations(t) | ||
| }) | ||
|
|
||
| t.Run("API error", func(t *testing.T) { | ||
| mockClient.On("CreatePost", expectedPost).Return((*model.Post)(nil), &model.Response{StatusCode: http.StatusBadRequest}, fmt.Errorf("API error")).Once() | ||
| err := messenger.Send(testMessage) | ||
| assert.Error(t, err) | ||
| assert.Contains(t, err.Error(), "failed to send message: API error") | ||
| mockClient.AssertExpectations(t) | ||
| }) | ||
|
|
||
| t.Run("Unexpected status code", func(t *testing.T) { | ||
| mockClient.On("CreatePost", expectedPost).Return(&model.Post{}, &model.Response{StatusCode: http.StatusOK}, nil).Once() | ||
| mockClient.On("PostMessage", "test-channel").Return(fmt.Errorf("API error")).Once() |
Copilot
AI
May 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider specifying all return values in the mock for PostMessage (e.g., Return("", "", nil)) to match the three-value return signature.
|
|
||
| t.Run("Unexpected status code", func(t *testing.T) { | ||
| mockClient.On("CreatePost", expectedPost).Return(&model.Post{}, &model.Response{StatusCode: http.StatusOK}, nil).Once() | ||
| mockClient.On("PostMessage", "test-channel").Return(fmt.Errorf("API error")).Once() |
Copilot
AI
May 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity and type safety, consider returning all three expected values (e.g., Return("", "", fmt.Errorf("API error"))) in the mock call for PostMessage.
| mockClient.On("PostMessage", "test-channel").Return(fmt.Errorf("API error")).Once() | |
| mockClient.On("PostMessage", "test-channel").Return("", "", fmt.Errorf("API error")).Once() |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
==========================================
- Coverage 61.93% 60.51% -1.42%
==========================================
Files 8 8
Lines 373 352 -21
==========================================
- Hits 231 213 -18
+ Misses 135 133 -2
+ Partials 7 6 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request updates the messaging integration for the
vault-audit-filterproject, replacing Mattermost with Slack. It includes changes to documentation, configuration, core implementation, and tests, as well as dependency updates ingo.mod.Messaging Integration Updates:
README.mdfile to replace Mattermost with Slack, including examples for both webhook and API-based configurations. [1] [2] [3] [4]pkg/messaging/messaging.go. This includes the introduction ofSlackMessengerandSlackWebhookMessengerclasses to handle Slack API and webhook messaging.AuditServerlogic inpkg/auditserver/server.goto use the new Slack-based messengers.Dependency Updates:
slack-go/slacklibrary for Slack integration ingo.mod. [1] [2]Test Updates:
pkg/messaging/messaging_test.goto validate the Slack integration, including both API and webhook scenarios. All Mattermost-related test cases were replaced with Slack equivalents.pkg/auditserver/server_test.goto reflect the switch to Slack-based messaging. [1] [2]Other Improvements:
pkg/forwarder/forwarder_test.goto use local addresses, ensuring reliable test behavior without network dependency. [1] [2] [3]