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: url quote passwords #549

Merged
merged 7 commits into from
Apr 20, 2024

Conversation

LyndonFan
Copy link
Contributor

Changes

Updated DbContainer to fix #547 by using urllib.parse.quote. I referenced sqlalchemy's implementation, but have not imported the library.

I have chosen to make this behaviour occur at all times (can't opt in / out), as it is common, if not the standard for these urls.

Tests

Since DbContainer can't be tested on its own, I put the tests across various database containers. I have pasted the below as comment in the test files for the listed modules:

# This is a feature in the generic DbContainer class
# but it can't be tested on its own
# so is tested in various database modules:
# - mysql / mariadb
# - postgresql
# - sqlserver
# - mongodb

Note the discussion recommended me to test with oracle, but I was unable to spin the container up locally (even with colima), so opted to replace it with mongodb.

Is there a template for PRs for the core library? I am unable to find one so have opted the above format. Please let me know if I have missed anything in this PR. Thanks!

@alexanderankin
Copy link
Collaborator

alexanderankin commented Apr 20, 2024

looks good, running these tests on my machine first and fixing some stuff up with static ports

had this other thought: do we care to simulate the craziest input possible, or is it better to replicate exactly the situation you saw, which is the auth denied error? not sure, maybe you have considered this though

e.g.

diff --git a/modules/mysql/tests/test_mysql.py b/modules/mysql/tests/test_mysql.py
index 62deac5..8ab347f 100644
--- a/modules/mysql/tests/test_mysql.py
+++ b/modules/mysql/tests/test_mysql.py
@@ -58,11 +58,21 @@ def test_docker_env_variables():
 # - mongodb
 def test_quoted_password():
     user = "root"
-    password = "p@$%25+0&%rd :/!=?"
-    quoted_password = "p%40%24%2525+0%26%25rd %3A%2F%21%3D%3F"
+    password = "p$%25+0&%rd"
+    quoted_password = "p%24%2525+0%26%25rd"
     driver = "pymysql"

maybe the answer is to parametrize, or i am just overthinking it

@alexanderankin
Copy link
Collaborator

opened #550 because debugging mssql is very not fun on a mac at the moment.

@alexanderankin alexanderankin merged commit 6c5d227 into testcontainers:main Apr 20, 2024
24 checks passed
@alexanderankin
Copy link
Collaborator

alright hopefully this doesn't break anybody

alexanderankin pushed a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.4.1](testcontainers-v4.4.0...testcontainers-v4.4.1)
(2024-05-14)


### Bug Fixes

* Add memcached container
([#322](#322))
([690b9b4](690b9b4))
* Add selenium video support
[#6](#6)
([#364](#364))
([3c8006c](3c8006c))
* **core:** add empty _configure to DockerContainer
([#556](#556))
([08916c8](08916c8))
* **core:** remove version from compose tests
([#571](#571))
([38946d4](38946d4))
* **keycloak:** add realm imports
([#565](#565))
([f761b98](f761b98))
* **mysql:** Add seed support in MySQL
([#552](#552))
([396079a](396079a))
* url quote passwords
([#549](#549))
([6c5d227](6c5d227))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Bug: Database fields not escaped when building URL
2 participants