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

do not overwrite the stored password with the masked password #1209

Merged

Conversation

dennisobrien
Copy link
Contributor

This addresses #1199

The fixes a common case of editing a database connection by changing something in the "extra" json but leaving the sqlalchemy uri as-is (and password-masked). Saving this would result in the password being updated with "XXXXXXXXXX". This only updates the password if it is not the password mask.

Added a test as well.

@xrmx
Copy link
Contributor

xrmx commented Sep 28, 2016

Looks like something is wrong wrt usage of sqlalchemy in your test

UPDATE: or not, #1208 has the same error on a different test :|

@dennisobrien
Copy link
Contributor Author

I'll try to look deeper at this in the next couple of days. Most likely the test I added is doing something wrong. I looked at how other tests were structured and took my best guess.

I agree it is strange that #1208 has a similar error.

url = 'databaseview/edit/{}'.format(database.id)
data = {k: database.__getattribute__(k) for k in DatabaseView.add_columns}
data['sqlalchemy_uri'] = database.safe_sqlalchemy_uri()
response = self.client.post(url, data=data)
Copy link
Member

Choose a reason for hiding this comment

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

I believe you are getting an error here because the database object is modified in the post request and sql alchemy cannot fetch new attributes.

you could try to requery the object after the post request.

data = {k: database.__getattribute__(k) for k in DatabaseView.add_columns}
data['sqlalchemy_uri'] = database.safe_sqlalchemy_uri()
response = self.client.post(url, data=data)
assert sqlalchemy_uri_decrypted == database.sqlalchemy_uri_decrypted
Copy link
Member

Choose a reason for hiding this comment

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

could you please use self.assertEquals instead of assert?
assertEquals gives a nice error message in case of the mismatch

@dennisobrien
Copy link
Contributor Author

Hmm, this is a new build failure after I clicked "update branch". The previous CI build did succeed. I'm not sure if this was from complications from merging 4164d6c or if this is a problem in master brought into this PR by updating the branch.

@bkyryliuk
Copy link
Member

that looks like transient error

@mistercrunch
Copy link
Member

please rebase your branch, otherwise LGTM

@dennisobrien dennisobrien force-pushed the dennisobrien/fix_edit_db_mask_password branch from 4282718 to 669612f Compare October 5, 2016 23:48
@dennisobrien
Copy link
Contributor Author

Rebased and dealt with the merge conflict in tests/core_tests.py

@mistercrunch
Copy link
Member

Thanks for following through @dennisobrien !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants