Skip to content
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

Revert part of #4609, fixes #4650 #4656

Merged
merged 8 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Fixed
(``ssh_runner.ssh_config_file_path``). (bug fix) #4660 #4661
* Update pack install action so it works correctly when ``python_versions`` ``pack.yaml`` metadata
attribute is used in combination with ``--python3`` pack install flag. (bug fix) #4654 #4662
* Add ``source_channel`` back to the context used by Mistral workflows for executions which are
triggered via ChatOps (using action alias).

In StackStorm v3.0.0, this variable was inadvertently removed from the context used by Mistral
workflows. (bug fix) #4650 #4656

3.0.0 - April 18, 2019
----------------------
Expand Down
1 change: 1 addition & 0 deletions st2api/st2api/controllers/v1/aliasexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _post(self, payload, requester_user, show_secrets=False, match_multiple=Fals
'action_alias_ref': reference.get_ref_from_model(action_alias_db),
'api_user': payload.user,
'user': requester_user.name,
'source_channel': payload.source_channel,
}

results = []
Expand Down
13 changes: 11 additions & 2 deletions st2api/tests/unit/controllers/v1/test_alias_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def test_match_and_execute_matches_many(self, mock_request):
return_value=(None, EXECUTION))
def test_match_and_execute_matches_one(self, mock_request):
base_data = {
'source_channel': 'chat',
'source_channel': 'chat-channel',
'notification_route': 'hubot',
'user': 'chat-user'
'user': 'chat-user',
}

# Command matches - should result in action execution
Expand All @@ -204,6 +204,15 @@ def test_match_and_execute_matches_one(self, mock_request):
expected_parameters = {'cmd': 'date', 'hosts': 'localhost'}
self.assertEquals(mock_request.call_args[0][0].parameters, expected_parameters)

# Also check for source_channel - see
# /~https://github.com/StackStorm/st2/issues/4650
actual_context = mock_request.call_args[0][0].context

self.assertTrue('source_channel' in mock_request.call_args[0][0].context.keys())
self.assertEquals(actual_context['source_channel'], 'chat-channel')
self.assertEquals(actual_context['api_user'], 'chat-user')
self.assertEquals(actual_context['user'], 'stanley')

@mock.patch.object(action_service, 'request',
return_value=(None, EXECUTION))
def test_match_and_execute_matches_one_multiple_match(self, mock_request):
Expand Down