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

Test coverage of several scenarios for auth/introspect route #1608

Conversation

azharcodeit
Copy link
Collaborator

@azharcodeit azharcodeit commented Jun 27, 2024

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

Related Issue

Related to Issue #1614

Describe this PR

This PR covers several scenarios of the auth/introspect route with tests, based on the login_required dependency injected into check_login.

Scenarios Covered:

  1. Valid/correct credentials:

Test the auth/introspect endpoint with valid credentials (a valid access_token).
This test will be updated once the access_token is clarified.
Verify the behavior of the auth/introspect endpoint when no credentials are provided. Expectation is status_code = 200.

  1. No credentials:

Verify the behavior of the auth/introspect endpoint when no credentials are provided. Expectation is an exception with status_code = 401 and detail = "No access token provided".

  1. Invalid/incorrect credentials:

Test the auth/introspect endpoint with invalid credentials.
Expectation is an exception with status_code = 401 and detail = "Access token not valid".

Screenshots

This test intentionally fails due to the absence of a valid access_token.

Screenshot 2024-06-27 at 14 16 00

Alternative Approaches Considered

Did you attempt any other approaches that are not documented in code?

Review Guide

Notes for the reviewer. How to test this change?

Command to run all tests defined in the project using pytest:

docker compose run --rm api pytest

Checklist before requesting a review

[optional] What gif best describes this PR or how it makes you feel?

@spwoodcock
Copy link
Member

As discussed, we will close this for now & perhaps review testing the /auth/refresh endpoint instead at some point.

@spwoodcock spwoodcock closed this Jul 17, 2024
@spwoodcock spwoodcock added the tests Related to automated code tests label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code tests Related to automated code tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants