glance/glance/tests
Ian Wienand f601cfccf1 Support RFC1738 quoted chars in passwords
In the bug, a user tried setting a devstack password with a "@" in it.

As it turns out, sqlalchmey turns the connection-string into a
sqlalchemy.engine.url.URL object [1] which returns a RFC1738 quoted
string.

However, alembic's set_main_option [2] uses python
string-interpolation which interprets '%' characters.  This means you
end up with an interpolation traceback when using any quoted character
(':@/') in a user/password (more likely password).

Avoid this by ensuring the URL is safe for python interpolation in
set_main_option by replacing '%' -> '%%'.

I convinced myself this is safe because sqlalchemy correctly parses
the quoted and unquoted versions just the same

---
 >>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy:@/pw@/moo'))
 'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
 >>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'))
 'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
---

A test is added

[1] https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/url.py
[2] http://alembic.zzzcomputing.com/en/latest/api/config.html#alembic.config.Config.set_main_option

Change-Id: I3ef7e3e539e35ce040573f2044ab6eb3c990200a
Closes-Bug: #1695299
2018-08-13 14:44:32 +10:00
..
etc Implement and Enable Community Images 2017-01-18 17:56:12 +00:00
functional Introduce ''mock_object'' method to base test class 2018-08-09 12:40:12 -04:00
integration Introduce ''mock_object'' method to base test class 2018-08-09 12:40:12 -04:00
unit Support RFC1738 quoted chars in passwords 2018-08-13 14:44:32 +10:00
var Support importing OVA/OVF package to Glance 2016-02-24 14:35:19 -08:00
__init__.py Make eventlet monkey patching conform to best practices 2018-03-29 20:36:09 +00:00
stubs.py Remove unused None from dict.get() 2017-07-05 12:49:10 +00:00
test_hacking.py Hacking checks for not using dict iteration calls 2016-01-25 21:54:08 -08:00
utils.py Introduce ''mock_object'' method to base test class 2018-08-09 12:40:12 -04:00