Mercurial > hg > nginx-tests
annotate geo_binary.t @ 1851:0351dee227a8
Tests: unbreak tests with dynamic certificates on stable.
In 74cffa9d4c43, ticket based session reuse is enabled in addition to
using a shared SSL session cache. This changed how a session can be
resumed in a different server:
- for a session ID based resumption, it is resumed in the same context
- when using session tickets, a key name is also checked for matching
- with a ticket callback, this is skipped in favor of callback's logic
This makes 'session id context match' tests fail with session tickets
on stable since ticket key names are unique in distinct SSL contexts.
On the other hand, tests pass on 1.23.2+ due to automatic ticket keys
rotation that installs ticket callback, and using a common shared SSL
session cache.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 28 Mar 2023 01:36:32 +0400 |
parents | 1fe8d33f75ad |
children |
rev | line source |
---|---|
1044
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for nginx geo module with binary base. |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 plan(skip_all => 'long configuration parsing') unless $ENV{TEST_NGINX_UNSAFE}; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http geo/); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 geo $geo_base_create { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 ranges; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 include base.conf; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 geo $geo_base_include { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 ranges; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 include base.conf; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 listen 127.0.0.1:8080; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 server_name localhost; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 location / { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 add_header X-IP $remote_addr; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 add_header X-GBc $geo_base_create; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 add_header X-GBi $geo_base_include; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 EOF |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 $t->write_file('1', ''); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 $t->write_file('base.conf', join('', map { |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 "127." . $_/256/256 % 256 . "." . $_/256 % 256 . "." . $_ % 256 . |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 "-127." . $_/256/256 % 256 . "." . $_/256 % 256 . "." .$_ % 256 . " " . |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 ($_ == 1 ? "loopback" : "range$_") . ";" } (0 .. 100000))); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->run(); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 plan(skip_all => 'no 127.0.0.1 on host') |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 if http_get('/1') !~ /X-IP: 127.0.0.1/m; |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 $t->plan(2); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 ############################################################################### |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 my $r = http_get('/1'); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 like($r, qr/^X-GBc: loopback/m, 'geo binary base create'); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 like($r, qr/^X-GBi: loopback/m, 'geo binary base include'); |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
1fe8d33f75ad
Tests: split out geo tests with binary base and skip by default.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 ############################################################################### |