Mock Slack Server - department-of-veterans-affairs/abd-vro GitHub Wiki

Mock Slack Server is mainly developed to validate calls to Slack channels in automated end-to-end tests.

Implementation

Mock Slack Server is a Spring Boot based REST API.

It is implemented as a Gradle subproject mocks:mock-slack in abd-vro project.

Slack Message Store

The primary functionality of Mock Slack Server is to detect Slack channel posts. To facilitate end-to-end tests, this Mock Server stores all received Slack messages in a Java HashMap with collection id's as keys. The values are the content of the slack message as stored in a SlackMessage object. The collection id is extracted from the message using a regex expression. The regex can be found in the Spring Boot Application configuration.

Spring Boot Application configuration initializes the HashMap as part of initialization of the SlackMessageStore bean.

End Points

End-points are defined in an interface and implemented in a controller.

The end-points are:

  • POST /slack-messages: posts a new slack message.
  • GET /slack-messages/{collectionId}: retrieves a previously posted slack message for the collection.
  • DELETE /slack-messages/{collectionId}: deletes any stored slack message for the collection.

The main POST end-point mock Slack API basic message POST end-point. This end-point accepts a basic json object with text property similar to the Slack end-point. The collection id is extracted from the text property using the regex available in Spring Boot Application configuration.

The GET end-point retrieves the slack message posted for a collection. It is used in automated end-to-end tests to verify a slack message is posted.

The DELETE end-point removes the slack message for a collection if it has been posted. It is used before any end-to-end test to make sure a previous run of the end-end-test does not affect the current run.