Skip to content

Commit

Permalink
📝Slack test : update Readme with new Oauth Configuration and set a ch…
Browse files Browse the repository at this point in the history
…annel name that isn't dependent on user slack language
  • Loading branch information
zbendhiba committed Mar 14, 2022
1 parent f9e5fd6 commit fc8d67a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
27 changes: 26 additions & 1 deletion integration-tests/slack/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@ By default the Slack integration tests use WireMock to stub the API interactions

To run the `camel-quarkus-Slack` integration tests against the real API, you must first create a Slack account and workspace https://slack.com/get-started#/create.

Then configure Slack custom configurations for 'Incoming Webhooks' & the 'Slack API Tester' on your workspace.
Create a channel named `test-channel`.

You’ll need to create a Slack app and use it on your workspace.

Use the 'User OAuth Token' as token for the producer abd consumer endpoints. Set the corresponding scopes for Bot Token:

* `channels:history`
* `groups:history`
* `im:history`
* `mpim:history`
* `channels:read`
* `groups:read`
* `im:read`
* `mpim:read`
* `chat:write`
Install your app for the channel `test-channel`.

Add an `Incoming Webhook` for you app.

Invite the bot in the channel `test-channel`.

[source]
----
/invite @BOT_NAME
----

Next set the following environment variables:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class SlackResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getSlackMessages() throws Exception {
Message message = consumerTemplate.receiveBody("slack://general?maxResults=1&" + getSlackAuthParams(),
Message message = consumerTemplate.receiveBody("slack://test-channel?maxResults=1&" + getSlackAuthParams(),
5000L, Message.class);
return message.getText();
}
Expand All @@ -61,7 +61,7 @@ public String getSlackMessages() throws Exception {
@POST
@Consumes(MediaType.TEXT_PLAIN)
public Response createSlackMessage(String message) throws Exception {
producerTemplate.requestBody("slack://general?" + getSlackAuthParams(), message);
producerTemplate.requestBody("slack://test-channel?" + getSlackAuthParams(), message);
return Response
.created(new URI("https://camel.apache.org/"))
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"{\"ok\":true,\"messages\":
[{\"bot_id\":\"test\",\"type\":\"message\",\"text\":\"Hello Camel Quarkus Slack\",\"user\":\"test\",\"ts\":\"1615377778.002900\",\"team\":\"test\",\"bot_profile\":{\"id\":\"test\",\"deleted\":false,\"name\":\"API Test\",\"updated\":1615375056,\"app_id\":\"test\",\"icons\":{\"image_36\":\"https:\\/\\/a.slack-edge.com\\/80588\\/img\\/plugins\\/app\\/bot_36.png\",\"image_48\":\"https:\\/\\/a.slack-edge.com\\/80588\\/img\\/plugins\\/app\\/bot_48.png\",\"image_72\":\"https:\\/\\/a.slack-edge.com\\/80588\\/img\\/plugins\\/app\\/service_72.png\"},\"team_id\":\"test\"}}],\"has_more\":true,\"pin_count\":0,\"channel_actions_ts\":null,\"channel_actions_count\":0,\"response_metadata\":{\"next_cursor\":\"bmV4dF90czoxNjE1Mzc3Njk4MDAyODAw\"}}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url" : "/api/chat.postMessage",
"method" : "POST",
"bodyPatterns" : [ {
"equalTo" : "channel=general&text=Hello%20Camel%20Quarkus%20Slack&link_names=0&mrkdwn=1&unfurl_links=0&unfurl_media=0&reply_broadcast=0",
"equalTo" : "channel=test-channel&text=Hello%20Camel%20Quarkus%20Slack&link_names=0&mrkdwn=1&unfurl_links=0&unfurl_media=0&reply_broadcast=0",
"caseInsensitive" : false
} ]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url" : "/api/conversations.history",
"method" : "POST",
"bodyPatterns" : [ {
"equalTo" : "channel=test&limit=1&inclusive=0",
"equalTo" : "channel=test-channel&limit=1&inclusive=0",
"caseInsensitive" : false
} ]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"response" : {
"status" : 200,
"body" : "{\"ok\":true,\"channels\":[{\"id\":\"test\",\"name\":\"java-development\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904170,\"is_archived\":false,\"is_general\":false,\"unlinked\":0,\"name_normalized\":\"java-development\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":false,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"previous_names\":[],\"num_members\":1},{\"id\":\"test\",\"name\":\"random\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904169,\"is_archived\":false,\"is_general\":false,\"unlinked\":0,\"name_normalized\":\"random\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":false,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"Non-work banter and water cooler conversation\",\"creator\":\"test\",\"last_set\":1571904169},\"purpose\":{\"value\":\"A place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber you'd prefer to keep out of more focused work-related channels.\",\"creator\":\"test\",\"last_set\":1571904169},\"previous_names\":[],\"num_members\":1},{\"id\":\"test\",\"name\":\"general\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904169,\"is_archived\":false,\"is_general\":true,\"unlinked\":0,\"name_normalized\":\"general\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":true,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"Company-wide announcements and work-based matters\",\"creator\":\"test\",\"last_set\":1571904169},\"purpose\":{\"value\":\"This channel is for workspace-wide communication and announcements. All members are in this channel.\",\"creator\":\"test\",\"last_set\":1571904169},\"previous_names\":[],\"num_members\":2}],\"response_metadata\":{\"next_cursor\":\"\"}}",
"body" : "{\"ok\":true,\"channels\":[{\"id\":\"test\",\"name\":\"java-development\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904170,\"is_archived\":false,\"is_general\":false,\"unlinked\":0,\"name_normalized\":\"java-development\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":false,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"previous_names\":[],\"num_members\":1},{\"id\":\"test\",\"name\":\"random\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904169,\"is_archived\":false,\"is_general\":false,\"unlinked\":0,\"name_normalized\":\"random\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":false,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"Non-work banter and water cooler conversation\",\"creator\":\"test\",\"last_set\":1571904169},\"purpose\":{\"value\":\"A place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber you'd prefer to keep out of more focused work-related channels.\",\"creator\":\"test\",\"last_set\":1571904169},\"previous_names\":[],\"num_members\":1},{\"id\":\"test\",\"name\":\"general\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904169,\"is_archived\":false,\"is_general\":true,\"unlinked\":0,\"name_normalized\":\"general\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":true,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"Company-wide announcements and work-based matters\",\"creator\":\"test\",\"last_set\":1571904169},\"purpose\":{\"value\":\"This channel is for workspace-wide communication and announcements. All members are in this channel.\",\"creator\":\"test\",\"last_set\":1571904169},\"previous_names\":[],\"num_members\":2},{\"id\":\"test-channel\",\"name\":\"test-channel\",\"is_channel\":true,\"is_group\":false,\"is_im\":false,\"created\":1571904170,\"is_archived\":false,\"is_general\":false,\"unlinked\":0,\"name_normalized\":\"test-channel\",\"is_shared\":false,\"parent_conversation\":null,\"creator\":\"test\",\"is_ext_shared\":false,\"is_org_shared\":false,\"shared_team_ids\":[\"test\"],\"pending_shared\":[],\"pending_connected_team_ids\":[],\"is_pending_ext_shared\":false,\"is_member\":false,\"is_private\":false,\"is_mpim\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":0},\"previous_names\":[],\"num_members\":3}],\"response_metadata\":{\"next_cursor\":\"\"}}",
"headers" : {
"date" : "Wed, 10 Mar 2021 12:02:58 GMT",
"server" : "Apache",
Expand Down

0 comments on commit fc8d67a

Please sign in to comment.