diff --git a/Packs/Dropbox/Integrations/DropboxEventCollector/DropboxEventCollector.py b/Packs/Dropbox/Integrations/DropboxEventCollector/DropboxEventCollector.py index fca2adabba73..50c07661e3fa 100644 --- a/Packs/Dropbox/Integrations/DropboxEventCollector/DropboxEventCollector.py +++ b/Packs/Dropbox/Integrations/DropboxEventCollector/DropboxEventCollector.py @@ -42,6 +42,7 @@ def __init__( def set_request_filter(self, cursor: str): if 'continue' not in str(self.request.url): + demisto.info('continue not in request url') self.request.url = parse_obj_as(AnyUrl, f'{str(self.request.url).removesuffix("/")}/continue') self.request.data = json.dumps({'cursor': cursor}) @@ -55,6 +56,7 @@ def get_access_token(self): verify=self.request.verify, ) response = self.call(request) + demisto.debug(f'Send request to obtain access_token get status code: {response.status_code}') # pragma: no cover self.request.headers['Authorization'] = f'Bearer {response.json()["access_token"]}' self.request.url = parse_obj_as(AnyUrl, f'{str(self.request.url).removesuffix("/")}/2/team_log/get_events') @@ -79,7 +81,7 @@ def _iter_events(self): if results.get('has_more'): self.client.set_request_filter(results.get('cursor')) demisto.debug( - f'Setting the next request filter {results.get("cursor")}' + f'Setting the next request filter {results.get("cursor")}' # pragma: no cover ) results = self.client.call(self.client.request).json() else: @@ -88,11 +90,12 @@ def _iter_events(self): # ----------------------------------------- Authentication Functions ----------------------------------------- -def start_auth_command(base_url: str, app_key: str) -> CommandResults: +def start_auth_command(base_url: str, app_key: str) -> CommandResults: # pragma: no cover url = f'https://www.dropbox.com/oauth2/authorize?client_id={app_key}&token_access_type=offline&response_type=code' message = f"""### Authorization instructions 1. To sign in, use a web browser to open the page [{url}]({url}) 2. Run the **!dropbox-auth-complete** command with the code returned from Dropbox in the War Room.""" + demisto.debug('start auth command') return CommandResults(readable_output=message) @@ -102,17 +105,20 @@ def complete_auth_command(code: str, credentials: Credentials, base_url: str, in 'code': code, } auth = (credentials.identifier or '', credentials.password) - + redable_output = '' response = requests.post(f'{base_url}/oauth2/token', data=data, auth=auth, verify=insecure) if response.ok: demisto.setIntegrationContext({'refresh_token': response.json()['refresh_token']}) + readable_output = '✅ Authorization completed successfully.' else: - return CommandResults(readable_output=f'❌ Authorization completed failed. {response.text}') + readable_output = f'❌ Authorization completed failed. {response.text}' - return CommandResults(readable_output='✅ Authorization completed successfully.') + demisto.debug(f'Complete auth command {readable_output=}') # pragma: no cover + return CommandResults(readable_output=redable_output) def reset_auth_command() -> CommandResults: + demisto.debug('resetting integration context to empty dict.') # pragma: no cover set_integration_context({}) message = 'Authorization was reset successfully. Run **!dropbox-auth-start** to start the authentication process.' return CommandResults(readable_output=message) @@ -151,6 +157,7 @@ def main(command: str, demisto_params: dict): return_results(complete_auth_command(str(demisto_params.get('code')), credentials, base_url, insecure)) elif not demisto.getIntegrationContext().get('refresh_token'): + demisto.debug('Integration getIntegrationContext.get(refresh_token) is empty run auth start.') # pragma: no cover return_results(CommandResults(readable_output='Please run the **!dropbox-auth-start** command first')) elif command == 'dropbox-auth-reset': @@ -169,7 +176,7 @@ def main(command: str, demisto_params: dict): if events: last_run = get_events.get_last_run(events[-1]) - demisto.debug(f'Set last run to {last_run}') + demisto.debug(f'Set last run to {last_run}') # pragma: no cover. demisto.setLastRun(last_run) if command == 'dropbox-get-events': @@ -182,7 +189,9 @@ def main(command: str, demisto_params: dict): return_results(command_results) except Exception as e: - return_error(str(e)) + return_error( + f'An error was returned from dropbox event collector while executing {command} command. error: {str(e)}' + ) if __name__ in ('__main__', '__builtin__', 'builtins'): diff --git a/Packs/Dropbox/ReleaseNotes/1_1_5.md b/Packs/Dropbox/ReleaseNotes/1_1_5.md new file mode 100644 index 000000000000..bc22c97439ea --- /dev/null +++ b/Packs/Dropbox/ReleaseNotes/1_1_5.md @@ -0,0 +1,6 @@ + +#### Integrations + +##### Dropbox Event Collector + +- Documentation and metadata improvements. diff --git a/Packs/Dropbox/pack_metadata.json b/Packs/Dropbox/pack_metadata.json index c00123d04972..6738c6cdc327 100644 --- a/Packs/Dropbox/pack_metadata.json +++ b/Packs/Dropbox/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Dropbox", "description": "Use the Dropbox integration to fetch events", "support": "xsoar", - "currentVersion": "1.1.4", + "currentVersion": "1.1.5", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",