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

Testing for providers requiring authorization #11691

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

k0mmsussert0d
Copy link
Contributor

  • PR is based on the DEVELOP branch
  • Don't send big changes all at once. Split up big PRs into multiple smaller PRs that are easier to manage and review
  • Read the contribution guide

This PR demonstrates a proposed approach to testing torrent providers requiring authorization using animebytes as an example.

Authorization mechanism is a part of an individual provider implementation. Usually, it depends on credentials stored as attributes of a provider class. In this particular example of animebytes provider, username and passkey attributes store user-provided credentials.

When provider class is imported to the testing context, advanced configuration of the instance can performed by injecting custom attributes found in _meta.attr in the test YAML file.

To prevent credentials from getting leaked by VCR recording them in the request, VCR context configuration can be defined in _meta.vcr. In case of animebytes, credentials are supplied as username and torrent_pass query parameters, so they have to be stripped with filter_query_parameters=['username', 'torrent_pass'] param provided to use_cassette(). Reference

To sum up, this PR introduces:

  • post-construction initialization step for provider instance
  • customizing vcr configuration per-case
  • some test cases for animebytes

@medariox
Copy link
Contributor

medariox commented Apr 3, 2024

Great job! Thank you for the exceptional effort 👍

@medariox medariox added this to the 1.0.21 milestone Apr 3, 2024
@medariox medariox merged commit e3084ba into pymedusa:develop Apr 3, 2024
9 of 11 checks passed
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.

2 participants