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 issue with passwords when passwords is provided by dict and by file #811

Closed
wants to merge 2 commits into from

Conversation

FloLaco
Copy link

@FloLaco FloLaco commented Sep 6, 2021

Issue: #809

Fix the issue about dict.update() which return None. It's a bad usage of this method.

@FloLaco FloLaco requested a review from a team as a code owner September 6, 2021 09:59
@Shrews
Copy link
Contributor

Shrews commented Sep 9, 2021

That certainly does look like problematic code. Could you add a test that validates the fix?

@FloLaco
Copy link
Author

FloLaco commented Sep 13, 2021

@Shrews I've added some tests

@Shrews
Copy link
Contributor

Shrews commented Sep 15, 2021

recheck

@@ -150,16 +150,24 @@ def _prepare_env(self, runner_mode='pexpect'):
if self.runner_mode == 'pexpect':
try:
if self.passwords and isinstance(self.passwords, dict):
self.passwords = self.passwords.update(self.loader.load_file('env/passwords', Mapping))
# Load password file and then the passwords dict argument for precedence
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for the change in precedence?

Copy link
Author

Choose a reason for hiding this comment

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

Because it's useless to provide password as dictionnary if a file is already present if we don't not modify precedence.
Argument provided by "user" in python code should always be more important as config file.

Copy link
Member

Choose a reason for hiding this comment

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

@Shrews made a good point to me

self.settings.update(self.loader.load_file('env/settings', Mapping))

differs from your precedence rules for passwords here.

I agree with you sentiment

Argument provided by "user" in python code should always be more important as config file.

But that would apply to settings, just the same that it applies to passwords.

Copy link
Author

Choose a reason for hiding this comment

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

@AlanCoding you're right.
I didn't change settings because I don't not use it and the initial fix was not intend to change settings. I just changed the obvious bug about settings.
If you insist I change change precedence with settings to, but I just need to know how to test it.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, all entries in env should have the same precedence. I feel like this PR should just fix the current bug. Changing precedence for file vs. args should likely be a separate PR and make sure that precedence is treated the same way across all possible input files.

@samdoran samdoran added the needs_triage New item that needs to be triaged label Nov 1, 2021
@samdoran
Copy link
Contributor

samdoran commented Nov 2, 2021

Superseded by #899

@samdoran samdoran closed this Nov 2, 2021
@sivel sivel removed the needs_triage New item that needs to be triaged label May 16, 2023
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.

None yet

5 participants