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

Fixed an OAuth 2.0 Authorization issue in ServiceNow V2 #17337

Merged
merged 20 commits into from
Jan 31, 2022

Conversation

ShacharKidor
Copy link
Contributor

@ShacharKidor ShacharKidor commented Jan 26, 2022

Contributing to Cortex XSOAR Content

Make sure to register your contribution by filling the contribution registration form

The Pull Request will be reviewed only after the contribution registration form is filled.

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

fixes: 46055

Description

  • Fixed an issue where the call that is in charge of getting an attachment file that is attached to a 'ServiceNow' ticket, isn't compatible with a client that is configured with OAuth 2.0 Authorization.
  • Added a unit test testing that issue
  • Added the 'servicenow-get-ticket' command to the 'playbook-ServiceNow_OAuth_Test'.
  • Remove 'servicenow-oauth-login' command from the 'playbook-ServiceNow_OAuth_Test'.

The edited TPB:
ServiceNow_OAuth_Test_Sun_Jan_30_2022

Minimum version of Cortex XSOAR

  • 6.0.0
  • 6.1.0
  • 6.2.0
  • 6.5.0

Does it break backward compatibility?

  • Yes
    • Further details:
  • No

Must have

  • Tests
  • Documentation

@ShacharKidor
Copy link
Contributor Author

ShacharKidor commented Jan 26, 2022

Hi @moishce,

In my first commit I added a unit test that is failing due to the bug described in the PR's body.
You can see the build failure here.

In my second commit I added the support for getting an attachment file of a ServiceNow ticket by using an OAuth 2.0 client.
As you can see the unit test passed successfully after I added the fix.

In my third commit I added the RN and improved the unit test doc string.

Let me know if you have any question or suggestion :)

@ShacharKidor ShacharKidor marked this pull request as ready for review January 27, 2022 09:00
@ShacharKidor ShacharKidor requested a review from a team as a code owner January 27, 2022 09:00
@yaakovi yaakovi requested review from Itay4 and removed request for a team January 30, 2022 07:26
@ShacharKidor ShacharKidor removed the request for review from moishce-zz January 30, 2022 15:39
Copy link
Contributor

@Itay4 Itay4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work 👍

@@ -32,6 +32,12 @@ def __init__(self, credentials: dict, use_oauth: bool = False, client_id: str =
self.password = credentials.get('password')
self.auth = (self.username, self.password)

if '@' in client_id: # for use in OAuth test-playbook
self.client_id, refresh_token = client_id.split('@')
integration_context = get_integration_context()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for that? will there be anything in the context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed that. thanks!


#### Integrations
##### ServiceNow v2
- Fixed the ***servicenow-get-ticket*** command to correctly authorize the request when getting an attachment from a 'ServiceNow' ticket.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Fixed the ***servicenow-get-ticket*** command to correctly authorize the request when getting an attachment from a 'ServiceNow' ticket.
- Fixed an issue where the ***servicenow-get-ticket*** command failed when to get attachments when using *OAuth Login*.

@ShacharKidor ShacharKidor merged commit 58e4cd4 into master Jan 31, 2022
@ShacharKidor ShacharKidor deleted the fix_service_now_auth_bug branch January 31, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants