Skip to content

Commit 94050d7

Browse files
committed
Tests: fixed typo in stream_js.t introduced in fd7766ab0a69.
In addition, tests were added to catch proper exit status.
1 parent b4894f3 commit 94050d7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

stream_js.t

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ stream {
7070
7171
js_include test.js;
7272
73+
log_format status $server_port:$status;
74+
7375
server {
7476
listen 127.0.0.1:8080;
7577
return $js_addr;
@@ -112,18 +114,21 @@ stream {
112114
listen 127.0.0.1:8087;
113115
js_access js_access_undecided;
114116
return OK;
117+
access_log %%TESTDIR%%/status.log status;
115118
}
116119
117120
server {
118121
listen 127.0.0.1:8088;
119122
js_access js_access_allow;
120123
return OK;
124+
access_log %%TESTDIR%%/status.log status;
121125
}
122126
123127
server {
124128
listen 127.0.0.1:8089;
125129
js_access js_access_deny;
126130
return OK;
131+
access_log %%TESTDIR%%/status.log status;
127132
}
128133
129134
server {
@@ -255,12 +260,12 @@ $t->write_file('test.js', <<EOF);
255260
return;
256261
}
257262
258-
s.abort();
263+
s.deny();
259264
}
260265
261266
function js_access_deny(s) {
262267
if (s.remoteAddress.match('127.0.0.1')) {
263-
s.abort();
268+
s.deny();
264269
return;
265270
}
266271
@@ -354,7 +359,7 @@ $t->write_file('test.js', <<EOF);
354359
EOF
355360

356361
$t->run_daemon(\&stream_daemon, port(8090));
357-
$t->try_run('no stream njs available')->plan(19);
362+
$t->try_run('no stream njs available')->plan(22);
358363
$t->waitforsocket('127.0.0.1:' . port(8090));
359364

360365
###############################################################################
@@ -395,6 +400,11 @@ ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0,
395400
ok(index($t->read_file('error.log'), 'at js_filter_except') > 0,
396401
'stream js_filter backtrace');
397402

403+
my @p = (port(8087), port(8088), port(8089));
404+
like($t->read_file('status.log'), qr/$p[0]:200/, 'status undecided');
405+
like($t->read_file('status.log'), qr/$p[1]:200/, 'status allow');
406+
like($t->read_file('status.log'), qr/$p[2]:403/, 'status deny');
407+
398408
###############################################################################
399409

400410
sub stream_daemon {

0 commit comments

Comments
 (0)