changeset 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 9f0ed4d54ae3
children 1c356f231c8f
files auth_basic.t
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/auth_basic.t
+++ b/auth_basic.t
@@ -23,7 +23,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(15)
+my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(19)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -63,7 +63,10 @@ my $d = $t->testdir();
 	'plain:' . '{PLAIN}password' . "\n" .
 	'ssha:' . '{SSHA}yI6cZwQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" .
 	'ssha2:' . '{SSHA}_____wQadOA1e+/f+T+H3eCQQhRzYWx0' . "\n" .
-	'ssha3:' . '{SSHA}Zm9vCg==' . "\n"
+	'ssha3:' . '{SSHA}Zm9vCg==' . "\n" .
+	'sha:' . '{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=' . "\n" .
+	'sha2:' . '{SHA}_____Mm5Pz8GgiULbPgzG37mj9g=' . "\n" .
+	'sha3:' . '{SHA}Zm9vCg==' . "\n"
 );
 
 $t->run();
@@ -93,20 +96,29 @@ like(http_get_auth('/', 'plain', 'passwo
 SKIP: {
 	# SHA1 may not be available unless we have OpenSSL
 
-	skip 'no sha1', 1 unless $t->has_module('--with-http_ssl_module')
+	skip 'no sha1', 2 unless $t->has_module('--with-http_ssl_module')
 		or $t->has_module('--with-sha1')
 		or $t->has_module('--with-openssl');
 
 	like(http_get_auth('/', 'ssha', 'password'), qr!SEETHIS!, 'ssha');
+
+TODO: {
+	local $TODO = 'not yet';
+	like(http_get_auth('/', 'sha', 'password'), qr!SEETHIS!, 'sha');
+}
+
 }
 
 unlike(http_get_auth('/', 'apr1', '123'), qr!SEETHIS!, 'apr1 md5 wrong');
 unlike(http_get_auth('/', 'plain', '123'), qr!SEETHIS!, 'plain wrong');
 unlike(http_get_auth('/', 'ssha', '123'), qr!SEETHIS!, 'ssha wrong');
+unlike(http_get_auth('/', 'sha', '123'), qr!SEETHIS!, 'sha wrong');
 
 like(http_get_auth('/', 'apr12', '1'), qr!401 Unauthorized!, 'apr1 md5 broken');
 like(http_get_auth('/', 'ssha2', '1'), qr!401 Unauthorized!, 'ssha broken 1');
 like(http_get_auth('/', 'ssha3', '1'), qr!401 Unauthorized!, 'ssha broken 2');
+like(http_get_auth('/', 'sha2', '1'), qr!401 Unauthorized!, 'sha broken 1');
+like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2');
 
 ###############################################################################