comparison auth_basic.t @ 259:024bae0ecd0c

Tests: {SHA} password scheme tests (ticket #50).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 04 Feb 2013 21:40:43 +0400
parents 6a0d934950bc
children d4d9bbe627a8
comparison
equal deleted inserted replaced
258:9f0ed4d54ae3 259:024bae0ecd0c
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(15) 26 my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(19)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
61 'apr1:' . '$apr1$salt$Xxd1irWT9ycqoYxGFn4cb.' . "\n" . 61 'apr1:' . '$apr1$salt$Xxd1irWT9ycqoYxGFn4cb.' . "\n" .
62 'apr12:' . '$apr1$' . "\n" . 62 'apr12:' . '$apr1$' . "\n" .
63 'plain:' . '{PLAIN}password' . "\n" . 63 'plain:' . '{PLAIN}password' . "\n" .
64 'ssha:' . '{SSHA}yI6cZwQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" . 64 'ssha:' . '{SSHA}yI6cZwQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" .
65 'ssha2:' . '{SSHA}_____wQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" . 65 'ssha2:' . '{SSHA}_____wQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" .
66 'ssha3:' . '{SSHA}Zm9vCg==' . "\n" 66 'ssha3:' . '{SSHA}Zm9vCg==' . "\n" .
67 'sha:' . '{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=' . "\n" .
68 'sha2:' . '{SHA}_____Mm5Pz8GgiULbPgzG37mj9g=' . "\n" .
69 'sha3:' . '{SHA}Zm9vCg==' . "\n"
67 ); 70 );
68 71
69 $t->run(); 72 $t->run();
70 73
71 ############################################################################### 74 ###############################################################################
91 like(http_get_auth('/', 'plain', 'password'), qr!SEETHIS!, 'plain password'); 94 like(http_get_auth('/', 'plain', 'password'), qr!SEETHIS!, 'plain password');
92 95
93 SKIP: { 96 SKIP: {
94 # SHA1 may not be available unless we have OpenSSL 97 # SHA1 may not be available unless we have OpenSSL
95 98
96 skip 'no sha1', 1 unless $t->has_module('--with-http_ssl_module') 99 skip 'no sha1', 2 unless $t->has_module('--with-http_ssl_module')
97 or $t->has_module('--with-sha1') 100 or $t->has_module('--with-sha1')
98 or $t->has_module('--with-openssl'); 101 or $t->has_module('--with-openssl');
99 102
100 like(http_get_auth('/', 'ssha', 'password'), qr!SEETHIS!, 'ssha'); 103 like(http_get_auth('/', 'ssha', 'password'), qr!SEETHIS!, 'ssha');
104
105 TODO: {
106 local $TODO = 'not yet';
107 like(http_get_auth('/', 'sha', 'password'), qr!SEETHIS!, 'sha');
108 }
109
101 } 110 }
102 111
103 unlike(http_get_auth('/', 'apr1', '123'), qr!SEETHIS!, 'apr1 md5 wrong'); 112 unlike(http_get_auth('/', 'apr1', '123'), qr!SEETHIS!, 'apr1 md5 wrong');
104 unlike(http_get_auth('/', 'plain', '123'), qr!SEETHIS!, 'plain wrong'); 113 unlike(http_get_auth('/', 'plain', '123'), qr!SEETHIS!, 'plain wrong');
105 unlike(http_get_auth('/', 'ssha', '123'), qr!SEETHIS!, 'ssha wrong'); 114 unlike(http_get_auth('/', 'ssha', '123'), qr!SEETHIS!, 'ssha wrong');
115 unlike(http_get_auth('/', 'sha', '123'), qr!SEETHIS!, 'sha wrong');
106 116
107 like(http_get_auth('/', 'apr12', '1'), qr!401 Unauthorized!, 'apr1 md5 broken'); 117 like(http_get_auth('/', 'apr12', '1'), qr!401 Unauthorized!, 'apr1 md5 broken');
108 like(http_get_auth('/', 'ssha2', '1'), qr!401 Unauthorized!, 'ssha broken 1'); 118 like(http_get_auth('/', 'ssha2', '1'), qr!401 Unauthorized!, 'ssha broken 1');
109 like(http_get_auth('/', 'ssha3', '1'), qr!401 Unauthorized!, 'ssha broken 2'); 119 like(http_get_auth('/', 'ssha3', '1'), qr!401 Unauthorized!, 'ssha broken 2');
120 like(http_get_auth('/', 'sha2', '1'), qr!401 Unauthorized!, 'sha broken 1');
121 like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2');
110 122
111 ############################################################################### 123 ###############################################################################
112 124
113 sub http_get_auth { 125 sub http_get_auth {
114 my ($url, $user, $password) = @_; 126 my ($url, $user, $password) = @_;