Skip to content

Commit 82243d8

Browse files
committed
test: malformed test crashes the bg worker
1 parent 10be612 commit 82243d8

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

nix/nginx/conf/custom.conf

+4
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ location /redirect_me {
4545
location /to_here {
4646
echo 'I got redirected';
4747
}
48+
49+
location /pathological {
50+
pathological;
51+
}

nix/nginxScript.nix

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
{ nginx, nginxModules, writeShellScriptBin } :
1+
{ lib, fetchFromGitHub, nginx, nginxModules, writeShellScriptBin } :
22

33
let
4+
ngx_pathological = rec {
5+
name = "ngx_pathological";
6+
version = "0.1";
7+
src = fetchFromGitHub {
8+
owner = "steve-chavez";
9+
repo = name;
10+
rev = "46a6d48910b482cf82ecd8a3fce448498cc9f886";
11+
sha256 = "sha256-unPSFxbuvv5chyPKDRaKvxuekz3tPmhHiVzZzX1D4lk=";
12+
};
13+
meta = with lib; {
14+
license = with licenses; [ mit ];
15+
};
16+
};
417
customNginx = nginx.override {
518
modules = [
619
nginxModules.echo
20+
ngx_pathological
721
];
822
};
923
script = ''

nix/ngx_pathological.nix

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ stdenv, postgresql, curl }:
2+
3+
stdenv.mkDerivation {
4+
name = "pg_net";
5+
6+
buildInputs = [ postgresql curl ];
7+
8+
src = ../.;
9+
10+
installPhase = ''
11+
mkdir -p $out/bin
12+
install -D pg_net.so -t $out/lib
13+
14+
install -D -t $out/share/postgresql/extension sql/*.sql
15+
install -D -t $out/share/postgresql/extension pg_net.control
16+
'';
17+
}

test/test_http_malformed_headers.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from sqlalchemy import text
2+
3+
4+
def test_http_malformed_headers(sess):
5+
"""Check that malformed headers are processed correctly"""
6+
# Create a request
7+
(request_id,) = sess.execute(text(
8+
"""
9+
select net.http_get(
10+
url:='http://localhost:8080/pathological?malformed-header=missing-value'
11+
);
12+
"""
13+
)).fetchone()
14+
15+
# Commit so background worker can start
16+
sess.commit()
17+
18+
# Collect the response, waiting as needed
19+
response = sess.execute(
20+
text(
21+
"""
22+
select * from net._http_collect_response(:request_id, async:=false);
23+
"""
24+
),
25+
{"request_id": request_id},
26+
).fetchone()
27+
print(response)
28+
assert response is not None
29+
assert response[0] == "SUCCESS"
30+
assert "MissingValue" in response[2]

0 commit comments

Comments
 (0)