Skip to content

Commit 1a958cb

Browse files
authored
HaProxy password: support some special characters (#25)
* added quotes in config for "NC_PASSWORD_PLACEHOLDER" Signed-off-by: Alexander Piskun <[email protected]> * fixed CI Signed-off-by: Alexander Piskun <[email protected]> --------- Signed-off-by: Alexander Piskun <[email protected]>
1 parent 56d39ed commit 1a958cb

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

haproxy.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defaults
1414
timeout server TIMEOUT_SERVER
1515

1616
userlist app_api_credentials
17-
user app_api_haproxy_user insecure-password NC_PASSWORD_PLACEHOLDER
17+
user app_api_haproxy_user insecure-password "NC_PASSWORD_PLACEHOLDER"
1818

1919
frontend docker_engine
2020
mode http

tests/misc.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ def remove_haproxy():
99

1010
def start_haproxy(port: int = 2375):
1111
tag = environ.get("TAG_SUFFIX", "latest")
12-
run(f"docker run -e NC_HAPROXY_PASSWORD='some_secure_password' -e HAPROXY_PORT={port} "
13-
"-v /var/run/docker.sock:/var/run/docker.sock "
14-
f"--name nextcloud-appapi-dsp -h nextcloud-appapi-dsp -p {port}:{port} "
15-
f"--rm --privileged -d nextcloud-appapi-dsp:{tag}".split(),
12+
run(
13+
[
14+
"docker", "run", "-e", "NC_HAPROXY_PASSWORD=some secure password", "-e",
15+
f"HAPROXY_PORT={port}", "-v", "/var/run/docker.sock:/var/run/docker.sock",
16+
"--name", "nextcloud-appapi-dsp", "-h", "nextcloud-appapi-dsp", "-p", f"{port}:{port}",
17+
"--rm", "--privileged", "-d", f"nextcloud-appapi-dsp:{tag}"
18+
],
1619
stdout=DEVNULL,
17-
check=True)
20+
check=True,
21+
)
1822

1923

2024
def wait_heartbeat():

tests/test_basic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def test_ping_spam():
7-
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some_secure_password"))
7+
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some secure password"))
88
for i in range(100):
99
r = client.get("_ping")
1010
assert r.status_code == 200
@@ -13,7 +13,7 @@ def test_ping_spam():
1313
def test_volume_creation_removal():
1414
volume_name = "nc_app_test_data"
1515
httpx.post("http://localhost:2375/volumes/create",
16-
auth=("app_api_haproxy_user", "some_secure_password"),
16+
auth=("app_api_haproxy_user", "some secure password"),
1717
json={"name": volume_name})
1818
httpx.delete(
1919
f"http://localhost:2375/volumes/{volume_name}",
@@ -26,23 +26,23 @@ def test_volume_creation_removal_invalid():
2626
for i in range(30):
2727
r = httpx.post(
2828
"http://localhost:2375/volumes/create",
29-
auth=("app_api_haproxy_user", "some_secure_password"),
29+
auth=("app_api_haproxy_user", "some secure password"),
3030
json={"name": volume_name},
3131
)
3232
assert r.status_code == 403
3333
r = httpx.delete(f"http://localhost:2375/volumes/{volume_name}",
34-
auth=("app_api_haproxy_user", "some_secure_password"))
34+
auth=("app_api_haproxy_user", "some secure password"))
3535
assert r.status_code == 403
3636

3737

3838
def test_invalid_url():
39-
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some_secure_password"))
39+
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some secure password"))
4040
for i in range(50):
4141
client.get("_unknown")
4242

4343

4444
def test_autoban():
45-
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some_secure_password1"))
45+
client = httpx.Client(base_url="http://localhost:2375", auth=("app_api_haproxy_user", "some secure password1"))
4646
with pytest.raises(httpx.ReadTimeout):
4747
for i in range(10):
4848
client.get("_ping")
@@ -56,7 +56,7 @@ def test_non_standard_port():
5656
try:
5757
misc.start_haproxy(port=12375)
5858
misc.wait_heartbeat()
59-
r = httpx.get("http://localhost:12375/_ping", auth=("app_api_haproxy_user", "some_secure_password"))
59+
r = httpx.get("http://localhost:12375/_ping", auth=("app_api_haproxy_user", "some secure password"))
6060
assert r.status_code == 200
6161
finally:
6262
misc.remove_haproxy()

0 commit comments

Comments
 (0)