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

pylxd/client: inspect secret before trying to use it as a token #616

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

simondeziel
Copy link
Member

No description provided.

@simondeziel simondeziel force-pushed the password-auth-regression-fix branch from c0f2c40 to eec1d55 Compare December 11, 2024 16:31
pylxd/client.py Outdated Show resolved Hide resolved
@hamistao
Copy link
Contributor

Our unit tests are pretty terrible. So to spare you from working with that while we don't improve them, I would be fine with just testing:

  • authenticate with an actual token;
  • authenticate with a password and check it fallsback to using a password if a token is not provided;
  • use_token_field as False and forcing password usage;

Then again if you think a unit test is needed here go for it :)

@hamistao
Copy link
Contributor

Also may be worth adding something on https://github.com/canonical/pylxd/blob/main/doc/source/authentication.rst

@simondeziel simondeziel force-pushed the password-auth-regression-fix branch 3 times, most recently from 09983e4 to cbc4cdc Compare December 11, 2024 17:58
pylxd/client.py Outdated Show resolved Hide resolved
@simondeziel
Copy link
Member Author

Our unit tests are pretty terrible.

Can't agree more!

So to spare you from working with that while we don't improve them, I would be fine with just testing:

* authenticate with an actual token;

* authenticate with a password and check it fallsback to using a password if a token is not provided;

* `use_token_field` as False and forcing password usage;

Then again if you think a unit test is needed here go for it :)

Yeah, I went the doctest route thinking it would be simple but turns out not as much as I'd like. Let me know what you think of the current proposal, please.

@simondeziel simondeziel marked this pull request as ready for review December 11, 2024 18:03
@simondeziel simondeziel force-pushed the password-auth-regression-fix branch from cbc4cdc to 991ca6a Compare December 11, 2024 21:20
Copy link
Contributor

@hamistao hamistao left a comment

Choose a reason for hiding this comment

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

Sharp idea with the doctests. We could consider rewriting our unit tests as doctests at some point (far in the future perhaps).

@simondeziel simondeziel merged commit d6d9209 into canonical:main Dec 11, 2024
14 checks passed
@simondeziel simondeziel deleted the password-auth-regression-fix branch December 11, 2024 21:34
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