Skip to content

Commit

Permalink
Cisco webex update authentication call to use body instead of url par…
Browse files Browse the repository at this point in the history
…ams (#34912)

* cisco webex rename integration context

* change the access token to body

* add ut and rn

* fix import

* fix ut

* docker

* fix RN
  • Loading branch information
MosheEichler committed Jun 19, 2024
1 parent af243a7 commit 7f2325d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
''' HELPER FUNCTIONS '''


def remove_integration_context_for_user(user: str):
"""
Remove integration context for a user
Args:
user: The user to remove the integration context for.
"""
integration_context = get_integration_context()
integration_context[user] = {}
set_integration_context(integration_context)


def date_time_to_iso_format(date_time: datetime) -> str:
"""
Gets a datetime object and returns s string represents a datetime is ISO format.
Expand Down Expand Up @@ -113,7 +124,7 @@ def create_access_token(self, grant_type: str, code: str | None = None, refresh_
client_secret=self.client_secret,
redirect_uri=self.redirect_uri,
)
return self._http_request(method='POST', url_suffix='access_token', headers=headers, params=params)
return self._http_request(method='POST', url_suffix='access_token', headers=headers, data=params)

def save_tokens_to_integration_context(self, result: dict):
"""
Expand Down Expand Up @@ -488,6 +499,7 @@ def main() -> None: # pragma: no cover

elif demisto.command() == 'cisco-webex-oauth-start':
client = admin_client if args.get('user') == 'admin' else compliance_officer_client
remove_integration_context_for_user(client.user)
result = oauth_start(client)
return_results(result)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ script:
name: since_datetime
description: Gets events from Cisco Webex.
name: cisco-webex-get-compliance-officer-events
dockerimage: demisto/python3:3.10.13.84405
dockerimage: demisto/python3:3.10.14.98471
isfetchevents: true
runonce: false
script: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ def get_access_token(self):
""" TEST HELPER FUNCTION """


def mock_set_integration_context(context: dict = None) -> dict | None:
return context


def test_remove_integration_context_for_user(mocker):
import CiscoWebexEventCollector

mock_integration_context = {'test_user': {'context_key': 'context_value'}}
mocker.patch.object(CiscoWebexEventCollector, 'get_integration_context', return_value=mock_integration_context)
mock_context = mocker.patch('CiscoWebexEventCollector.set_integration_context', side_effect=mock_set_integration_context)

assert CiscoWebexEventCollector.get_integration_context() == mock_integration_context
CiscoWebexEventCollector.remove_integration_context_for_user('test_user')
assert mock_context.call_args.args[0] == {'test_user': {}}


@freeze_time("2023-12-20 13:40:00 UTC")
def test_create_last_run():
"""
Expand Down Expand Up @@ -193,8 +209,7 @@ def test_oauth_complete(client):

with requests_mock.Mocker() as m:
m.post(
'https://url.com/access_token?grant_type=authorization_code&code=123456&client_id=1&client_secret=1'
'&redirect_uri=https%3A%2F%2Fredirect.com',
'https://url.com/access_token',
json=mock_get_access_token()
)
results = oauth_complete(client, {'code': '123456'})
Expand Down
6 changes: 6 additions & 0 deletions Packs/CiscoSpark/ReleaseNotes/1_0_7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### Cisco Webex Event Collector
- Updated the Docker image to: *demisto/python3:3.10.14.98471*.
- Fixed an issue where the ***cisco-webex-oauth-complete*** command failed on a bad request.
2 changes: 1 addition & 1 deletion Packs/CiscoSpark/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Cisco Webex Teams",
"description": "Send messages, create rooms and more, via the Cisco Webex Teams (Cisco Spark) API.",
"support": "xsoar",
"currentVersion": "1.0.6",
"currentVersion": "1.0.7",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 7f2325d

Please sign in to comment.