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

refactor: Authenticator refactoring (preparation for app token refreshing) #281

Merged
merged 5 commits into from
Jul 31, 2024

Conversation

TrishGillett
Copy link
Contributor

Note: In this PR I am not changing functionality but just refactoring to make functionality changes possible in a future PR. Essentially: make the change easy, then make the easy change.

My goal is to add github app token features, for example refreshing app tokens before they expire (they're only good for an hour and currently don't refresh), and allowing multiple app tokens

Currently, personal and app tokens are stored in the same list and treated interchangeably, so some structural changes are needed in order to handle them differently. My plan is to develop PersonalTokenManager and AppTokenManager classes so the code for working with each token type can be built into its manager class. In this PR I start by proposing to convert the TokenRateLimit class to a more general TokenManager, and I move functionality common to both token types there. I've added unit tests for the methods in TokenManager.

Follow up PRs will develop PersonalTokenManager and AppTokenManager and implement the new app token features.

@TrishGillett TrishGillett changed the title Authenticator refactoring (preparation for app token refreshing) refactor: Authenticator refactoring (preparation for app token refreshing) Jul 30, 2024
tap_github/authenticator.py Show resolved Hide resolved
tap_github/authenticator.py Outdated Show resolved Hide resolved
tap_github/authenticator.py Show resolved Hide resolved
tap_github/tests/test_authenticator.py Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jul 31, 2024

Copy link
Member

@edgarrmondragon edgarrmondragon left a comment

Choose a reason for hiding this comment

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

Thanks @TrishGillett!

@edgarrmondragon edgarrmondragon merged commit b009443 into MeltanoLabs:main Jul 31, 2024
8 checks passed
edgarrmondragon pushed a commit that referenced this pull request Aug 9, 2024
…the environment, part of refactoring in preparation for app token refreshing (#284)

This PR continues the work started in
#281, completing the major
refactor. This is accomplished by creating PersonalTokenManager and
AppTokenManager classes, moving logic to them, and adding tests.

After this PR, I'll be able to easily implement refreshing for app
tokens and other app token related features.

In additional to the added unit tests, I have tested running an
extractor on top of the proposed code, in a couple scenarios:

with auth_token? | with additional_auth_tokens? | with personal tokens
in env? | with app token? | # tokens that should be used | # tokens used
in test run
--|--|--|--|--|--
no | no | no | yes | 1 | 1 ✅ 
yes | yes (1) | no | yes | 3 | 3 ✅ 
no | yes (2) | no | yes | 3 | 3 ✅ 

I am not easily able to test the case of personal tokens being detected
from the environment, just because changing the name of environment
variables is not simple in my set up.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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