Skip to content

Conversation

@ncode
Copy link
Owner

@ncode ncode commented May 23, 2025

This pull request updates the messaging integration for the vault-audit-filter project, replacing Mattermost with Slack. It includes changes to documentation, configuration, core implementation, and tests, as well as dependency updates in go.mod.

Messaging Integration Updates:

  • Updated the messaging integration in the README.md file to replace Mattermost with Slack, including examples for both webhook and API-based configurations. [1] [2] [3] [4]
  • Replaced Mattermost-specific logic with Slack-specific implementations in pkg/messaging/messaging.go. This includes the introduction of SlackMessenger and SlackWebhookMessenger classes to handle Slack API and webhook messaging.
  • Updated the AuditServer logic in pkg/auditserver/server.go to use the new Slack-based messengers.

Dependency Updates:

  • Removed Mattermost-related dependencies and added the slack-go/slack library for Slack integration in go.mod. [1] [2]

Test Updates:

  • Refactored tests in pkg/messaging/messaging_test.go to validate the Slack integration, including both API and webhook scenarios. All Mattermost-related test cases were replaced with Slack equivalents.
  • Updated tests in pkg/auditserver/server_test.go to reflect the switch to Slack-based messaging. [1] [2]

Other Improvements:

  • Adjusted UDP forwarder tests in pkg/forwarder/forwarder_test.go to use local addresses, ensuring reliable test behavior without network dependency. [1] [2] [3]

@ncode ncode requested a review from Copilot May 23, 2025 10:11
Copy link

Copilot AI left a 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.

Comment on lines +52 to +59
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()
Copy link

Copilot AI May 23, 2025

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.

Copilot uses AI. Check for mistakes.

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()
Copy link

Copilot AI May 23, 2025

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.

Suggested change
mockClient.On("PostMessage", "test-channel").Return(fmt.Errorf("API error")).Once()
mockClient.On("PostMessage", "test-channel").Return("", "", fmt.Errorf("API error")).Once()

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 60.51%. Comparing base (561bf08) to head (51cae94).

Files with missing lines Patch % Lines
pkg/auditserver/server.go 50.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ncode ncode merged commit 486f03c into main May 23, 2025
3 checks passed
@ncode ncode deleted the juliano/slack branch May 23, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants