comparison secure_link.t @ 255:cca7b57587d6

Tests: secure_link inheritance test.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 28 Jan 2013 18:36:59 +0400
parents 6a0d934950bc
children 94f8ee2f6688
comparison
equal deleted inserted replaced
252:8b554d26eb1a 255:cca7b57587d6
22 ############################################################################### 22 ###############################################################################
23 23
24 select STDERR; $| = 1; 24 select STDERR; $| = 1;
25 select STDOUT; $| = 1; 25 select STDOUT; $| = 1;
26 26
27 my $t = Test::Nginx->new()->has(qw/http secure_link/)->plan(8); 27 my $t = Test::Nginx->new()->has(qw/http secure_link/)->plan(9);
28 28
29 $t->write_file_expand('nginx.conf', <<'EOF'); 29 $t->write_file_expand('nginx.conf', <<'EOF');
30 30
31 %%TEST_GLOBALS%% 31 %%TEST_GLOBALS%%
32 32
92 return 403; 92 return 403;
93 } 93 }
94 94
95 rewrite ^ /$secure_link break; 95 rewrite ^ /$secure_link break;
96 } 96 }
97
98 location /inheritance/ {
99 secure_link_secret secret;
100
101 location = /inheritance/test {
102 secure_link Xr4ilOzQ4PCOq3aQ0qbuaQ==;
103 secure_link_md5 secret;
104
105 if ($secure_link = "1") {
106 rewrite ^ /test.html break;
107 }
108
109 return 403;
110 }
111 }
97 } 112 }
98 } 113 }
99 114
100 EOF 115 EOF
101 116
133 qr/PASSED/, 'request old style'); 148 qr/PASSED/, 'request old style');
134 like(http_get('/p/' . md5_hex('fake') . '/test.html'), qr/^HTTP.*403/, 149 like(http_get('/p/' . md5_hex('fake') . '/test.html'), qr/^HTTP.*403/,
135 'request old style fake hash'); 150 'request old style fake hash');
136 like(http_get('/p/test.html'), qr/^HTTP.*403/, 'request old style no hash'); 151 like(http_get('/p/test.html'), qr/^HTTP.*403/, 'request old style no hash');
137 152
153 TODO: {
154 local $TODO = 'not yet' unless $t->has_version('1.3.12');
155
156 like(http_get('/inheritance/test'), qr/PASSED/, 'inheritance');
157
158 }
159
138 ############################################################################### 160 ###############################################################################
139 161
140 sub encode_base64url { 162 sub encode_base64url {
141 my $e = encode_base64(shift, ""); 163 my $e = encode_base64(shift, "");
142 $e =~ s/=+\z//; 164 $e =~ s/=+\z//;