annotate empty_gif.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 882267679006
children c544b7120a6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5 # Tests for empty gif module.
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 ###############################################################################
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 use warnings;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use strict;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use Test::More;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 use Socket qw/ CRLF /;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use lib 'lib';
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http empty_gif/)->plan(4);
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 $t->write_file_expand('nginx.conf', <<'EOF');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
41 listen 127.0.0.1:8080;
326
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server_name localhost;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 location / {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 empty_gif;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 EOF
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 $t->run();
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 my $gif = unhex(<<'EOF');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 0x0000: 47 49 46 38 39 61 01 00 01 00 80 01 00 00 00 00 |GIF89a.. ........|
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 0x0010: ff ff ff 21 f9 04 01 00 00 01 00 2c 00 00 00 00 |...!.... ...,....|
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 0x0020: 01 00 01 00 00 02 02 4c 01 00 3b |.......L ..;|
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 EOF
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 ###############################################################################
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 is(http_get_body('/'), $gif, 'empty gif');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 like(http_get('/'), qr!Content-Type: image/gif!i, 'get content type');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 like(http_head('/'), qr!Content-Type: image/gif!i, 'head content type');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 like(http('PUT / HTTP/1.0' . CRLF . CRLF), qr!405 Not Allowed!i, 'put');
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 ###############################################################################
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 sub unhex {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 my ($input) = @_;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 my $buffer = '';
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 for my $l ($input =~ m/: +((?:[0-9a-f]{2,4} +)+) /gms) {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 for my $v ($l =~ m/[0-9a-f]{2}/g) {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 $buffer .= chr(hex($v));
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 return $buffer;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 sub http_get_body {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 my ($uri) = @_;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 return undef if !defined $uri;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 my $text = http_get($uri);
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) {
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 return undef;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 return $2;
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 }
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95
a2c15637c9d5 Tests: empty gif tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 ###############################################################################