Mercurial > hg > nginx-tests
comparison userid_flags.t @ 1595:a2c6b95d6591
Tests: userid_flags tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 28 Sep 2020 19:10:40 +0100 |
parents | |
children | f42d82b114cd |
comparison
equal
deleted
inserted
replaced
1594:2083b4f183e7 | 1595:a2c6b95d6591 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for the userid_flags directive. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http userid/); | |
26 | |
27 $t->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080; | |
41 server_name localhost; | |
42 | |
43 userid on; | |
44 userid_name test; | |
45 userid_path /0123456789; | |
46 userid_domain test.domain; | |
47 | |
48 location / { | |
49 userid_flags samesite=strict; | |
50 | |
51 location /many { | |
52 userid_flags httponly samesite=none secure; | |
53 } | |
54 } | |
55 | |
56 location /lax { | |
57 userid_flags samesite=lax; | |
58 } | |
59 } | |
60 } | |
61 | |
62 EOF | |
63 | |
64 $t->write_file('index.html', ''); | |
65 $t->write_file('lax', ''); | |
66 $t->write_file('many', ''); | |
67 $t->try_run('no userid_flags')->plan(3); | |
68 | |
69 ############################################################################### | |
70 | |
71 like(http_get('/'), qr/samesite=strict/, 'strict'); | |
72 like(http_get('/lax'), qr/samesite=lax/, 'lax'); | |
73 like(http_get('/many'), qr/secure; httponly; samesite=none/, 'many'); | |
74 | |
75 ############################################################################### |