Slack: Add bot/user token support, correct thread_ts support (#123)

* Slack: Add bot/user token support, correct thread_ts support

Add support for user/bot/application tokens (and Slack WebAPI).
Fix input type for thread_id, which needs to be string.
Return thread_ts/thread_id when user/bot tokens are used, so they can be reused later

* Slack: Add changelog fragment, fix YAML syntax

Co-authored-by: Middleton, Michal <Michal.Middleton@concur.com>
This commit is contained in:
Michal Middleton 2020-04-17 06:44:55 -05:00 committed by GitHub
parent 5424c47d2f
commit 0c0490298f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 16 deletions

View file

@ -68,7 +68,7 @@ class TestSlackModule(ModuleTestCase):
set_module_args({
'token': 'XXXX/YYYY/ZZZZ',
'msg': 'test',
'thread_id': 100.00
'thread_id': '100.00'
})
with patch.object(slack, "fetch_url") as fetch_url_mock:
@ -80,7 +80,7 @@ class TestSlackModule(ModuleTestCase):
call_data = json.loads(fetch_url_mock.call_args[1]['data'])
assert call_data['username'] == "Ansible"
assert call_data['text'] == "test"
assert call_data['thread_ts'] == 100.00
assert call_data['thread_ts'] == '100.00'
assert fetch_url_mock.call_args[1]['url'] == "https://hooks.slack.com/services/XXXX/YYYY/ZZZZ"
def test_message_with_invalid_color(self):