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

fix: Tokens in config are no longer ignored when there are tokens in the environment, part of refactoring in preparation for app token refreshing #284

Merged
merged 9 commits into from
Aug 9, 2024

Conversation

TrishGillett
Copy link
Contributor

@TrishGillett TrishGillett commented Aug 3, 2024

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.

@TrishGillett TrishGillett force-pushed the token-manager-2 branch 7 times, most recently from ec6dbe0 to 78918b9 Compare August 5, 2024 03:26
@TrishGillett TrishGillett marked this pull request as ready for review August 5, 2024 03:27
@edgarrmondragon edgarrmondragon self-requested a review August 5, 2024 19:26
@edgarrmondragon edgarrmondragon self-assigned this Aug 5, 2024
@TrishGillett TrishGillett changed the title refactor: More authenticator refactoring (preparation for app token refreshing) bugfix: More authenticator refactoring (preparation for app token refreshing) Aug 9, 2024
@TrishGillett TrishGillett changed the title bugfix: More authenticator refactoring (preparation for app token refreshing) fix: More authenticator refactoring (preparation for app token refreshing) Aug 9, 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.

This looks great @TrishGillett 🎉 . Just a nit about idiomatic pytest.

tap_github/tests/test_authenticator.py Outdated Show resolved Hide resolved
@edgarrmondragon edgarrmondragon changed the title fix: More authenticator refactoring (preparation for app token refreshing) fix: Tokens in config are no longer ignored when there are tokens in the environment, part of refactoring in preparation for app token refreshing Aug 9, 2024
Copy link

sonarcloud bot commented Aug 9, 2024

@edgarrmondragon edgarrmondragon merged commit aade338 into MeltanoLabs:main Aug 9, 2024
8 checks passed
token_manager = AppTokenManager("12345;;key\\ncontent")
assert token_manager.github_app_id == "12345"
assert token_manager.github_private_key == "key\ncontent"
assert token_manager.github_installation_id == ""

Choose a reason for hiding this comment

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

I think that

if github_installation_id is None:
this line is expecting this to be None not ""

I think we either want to parse this as empty string and then change the other code to look for "falsy" or we want to parse this as "None" and then we do not need to change the code.

I have been getting

404 Client Error: Not Found for url: https://api.github.com/app/installations//access_tokens

post this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @camerondavison, thanks for reporting and sorry this change caused an issue. Taking a look now. 👀

Copy link
Contributor Author

@TrishGillett TrishGillett Aug 14, 2024

Choose a reason for hiding this comment

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

Put up a PR to fix this here, if you like you can try pegging your version of the tap to the commit 38e1bdf9381c3a3fa17cceada9e1ede7be57ae6b to see if it fixes your issue.

Copy link
Member

Choose a reason for hiding this comment

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

I've also tagged v1.4.8

edgarrmondragon pushed a commit that referenced this pull request Aug 15, 2024
…#291)

Addresses the problem described by @camerondavison
[here](#284 (comment)),
and introduced in #284.

If not provided, installation ID should be set to None, since that is
the way `generate_app_access_token` expects a missing installation ID to
be represented.
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.

3 participants