mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-13 08:22:55 +00:00
The new format has a few benefits: it's shorter, simpler and human-readable as well. We don't use base64 anymore, since url encoding got us covered. We also show a better error in case we couldn't parse the payload; the users should know it's all about passing the correct project name.
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import pytest
|
|
import psycopg2
|
|
|
|
|
|
def test_proxy_select_1(static_proxy):
|
|
static_proxy.safe_psql('select 1', options='project=generic-project-name')
|
|
|
|
|
|
def test_password_hack(static_proxy):
|
|
user = 'borat'
|
|
password = 'password'
|
|
static_proxy.safe_psql(f"create role {user} with login password '{password}'",
|
|
options='project=irrelevant')
|
|
|
|
# Note the format of `magic`!
|
|
magic = f"project=irrelevant;{password}"
|
|
static_proxy.safe_psql('select 1', sslsni=0, user=user, password=magic)
|
|
|
|
# Must also check that invalid magic won't be accepted.
|
|
with pytest.raises(psycopg2.errors.OperationalError):
|
|
magic = "broken"
|
|
static_proxy.safe_psql('select 1', sslsni=0, user=user, password=magic)
|
|
|
|
|
|
# Pass extra options to the server.
|
|
#
|
|
# Currently, proxy eats the extra connection options, so this fails.
|
|
# See https://github.com/neondatabase/neon/issues/1287
|
|
@pytest.mark.xfail
|
|
def test_proxy_options(static_proxy):
|
|
with static_proxy.connect(options='-cproxytest.option=value') as conn:
|
|
with conn.cursor() as cur:
|
|
cur.execute('SHOW proxytest.option')
|
|
value = cur.fetchall()[0][0]
|
|
assert value == 'value'
|