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

Adding oauth test #35417

Merged
merged 14 commits into from
Sep 11, 2024
Merged

Adding oauth test #35417

merged 14 commits into from
Sep 11, 2024

Conversation

awais786
Copy link
Contributor

@awais786 awais786 commented Sep 3, 2024

Added OAuth tests for various instructor URLs.

This PR includes authentication of URLs using OAuth2 and testing access to recently converted Django Rest Framework (DRF) endpoints."

@awais786 awais786 marked this pull request as ready for review September 6, 2024 18:56
@awais786 awais786 requested a review from feanil September 6, 2024 18:56
@awais786
Copy link
Contributor Author

awais786 commented Sep 9, 2024

@feanil Please review.

Copy link
Member

@UsamaSadiq UsamaSadiq left a comment

Choose a reason for hiding this comment

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

One small suggestion, otherwise looking good to be merged.

)
return response

def test_end_points_with_oauth_without_jwt(self):
Copy link
Member

Choose a reason for hiding this comment

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

We should create a common function to avoid duplicating the code in all test cases.
Example:
Create a function similar to

def run_endpoint_tests(self, expected_status, add_role, use_jwt):

containing all the duplicate code so the actual tests can be changed to something like following:

def test_end_points_with_oauth_without_jwt(self):
    self.run_endpoint_tests(expected_status=401, add_role=False, use_jwt=False)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@UsamaSadiq good suggestion, I have implemented.

}

# endpoints contains all urls with body and role.
self.endpoints = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we only testing these specific endpoints?
Do they belong to a particular feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am converting these endpoints to DRF. So now they all are oauth2 compatible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can organize this endpoints list in a maintainable way, for example define the endpoints in the constants in next PRs

@awais786 awais786 merged commit 1a1697c into master Sep 11, 2024
49 checks passed
@awais786 awais786 deleted the adding-oauth-test branch September 11, 2024 12:43
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants