File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,14 @@ function get_ip_from_cid() {
110110}
111111
112112function postgresql_cmd() {
113- docker run --rm -e PGPASSWORD=" $PASS " " $IMAGE_NAME " psql -v ON_ERROR_STOP=1 " postgresql://$PGUSER @$CONTAINER_IP :5432/${DB-db} " " $@ "
113+ # URI encode the values used inside the connection URI to avoid special
114+ # characters causing the tests using them to fail.
115+ # These tests should not fail because the container is created just fine
116+ # as it uses just environment variables. We need both the creation and
117+ # connection to use the same values, which this use of `jq` ensures.
118+ USERENC=$( jq -rn --arg x " $PGUSER " ' $x|@uri' )
119+ DBENC=$( jq -rn --arg x " ${DB-db} " ' $x|@uri' )
120+ docker run --rm -e PGPASSWORD=" $PASS " " $IMAGE_NAME " psql -v ON_ERROR_STOP=1 " postgresql://$USERENC @$CONTAINER_IP :5432/$DBENC " " $@ "
114121}
115122
116123function test_connection() {
@@ -647,7 +654,10 @@ VERY_LONG_IDENTIFIER="very_long_identifier_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
647654 assert_container_creation_succeeds -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -e POSTGRESQL_ADMIN_PASSWORD=" \" " || ret=8
648655
649656 assert_container_creation_succeeds -e POSTGRESQL_ADMIN_PASSWORD=" the @password" || ret=9
657+ # Postgres <18 accepts spaces in the connection URI just fine,
658+ # but 18 does not and tells you to use %20 instead, so we encode every DB- and username.
650659 assert_container_creation_succeeds -e POSTGRESQL_PASSWORD=" the pass" -e POSTGRESQL_USER=" the user" -e POSTGRESQL_DATABASE=" the db" || ret=10
660+ assert_container_creation_succeeds -e POSTGRESQL_PASSWORD=" the pass" -e POSTGRESQL_USER=" the@user" -e POSTGRESQL_DATABASE=" the/db" || ret=10
651661
652662 if [ $ret -eq 0 ]; then
653663 echo " Success!"
You can’t perform that action at this time.
0 commit comments