Mercurial > hg > nginx-tests
annotate userid_flags.t @ 1896:8b74936ff2ac
Tests: added has_feature() test for CryptX.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 29 May 2023 17:04:36 +0400 |
parents | 5ac6efbe5552 |
children |
rev | line source |
---|---|
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for the userid_flags directive. |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http userid/); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 listen 127.0.0.1:8080; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 userid on; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 userid_name test; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 userid_path /0123456789; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 userid_domain test.domain; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location / { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 userid_flags samesite=strict; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /many { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 userid_flags httponly samesite=none secure; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
54 |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
55 location /off { |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
56 userid_flags off; |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
57 } |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location /lax { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 userid_flags samesite=lax; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
63 |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
64 location /unset { } |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 EOF |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $t->write_file('index.html', ''); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->write_file('lax', ''); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $t->write_file('many', ''); |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1596
diff
changeset
|
73 $t->run()->plan(5); |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
77 like(http_get('/'), qr/samesite=strict/i, 'strict'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
78 like(http_get('/lax'), qr/samesite=lax/i, 'lax'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
79 like(http_get('/many'), qr/secure; httponly; samesite=none/i, 'many'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
80 unlike(http_get('/off'), qr/(secure|httponly|samesite)/i, 'off'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
81 unlike(http_get('/unset'), qr/(secure|httponly|samesite)/i, 'unset'); |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ############################################################################### |