X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2FPlack-Middleware-Auth-Complex.t;h=eae34b7e0d36de75dd52916b044b291db997e151;hb=1f7bfc2775dedc426518325a481c4b490a41c6e3;hp=956ee67321c4c90d00bf8ba3ffec08413b178cfa;hpb=12aa0bc64ec5cbecd0cce89d1144deb0c66bbd61;p=plack-middleware-auth-complex.git diff --git a/t/Plack-Middleware-Auth-Complex.t b/t/Plack-Middleware-Auth-Complex.t index 956ee67..eae34b7 100644 --- a/t/Plack-Middleware-Auth-Complex.t +++ b/t/Plack-Middleware-Auth-Complex.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 59; +use Test::More tests => 61; BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' } BEGIN { use_ok('Plack::Middleware::Auth::Complex') }; @@ -30,8 +30,13 @@ sub is_http { my $create_table = 'CREATE TABLE users (id TEXT PRIMARY KEY, passphrase TEXT, email TEXT)'; my $ac = Plack::Middleware::Auth::Complex->new({ - dbi_connect => ['dbi:SQLite:dbname=:memory:'], - post_connect_cb => sub { shift->{dbh}->do($create_table) }, + dbi_connect => ['dbi:SQLite:dbname=:memory:'], + post_connect_cb => sub { shift->{dbh}->do($create_table) }, + register_url => '/register', + passwd_url => '/passwd', + request_reset_url => '/request-reset', + reset_url => '/reset', + cache_max_age => 0, }); my $app = $ac->wrap(\&app); @@ -45,9 +50,10 @@ test_psgi $app, sub { is_http $cb->(POST '/'), 200, 'Anon', 'POST /'; is_http $cb->(GET '/register'), 200, 'Anon', 'GET /register'; set_auth 'user', 'password'; + is_http $cb->(GET '/', Authorization => 'Hello'), 200, 'Anon', 'GET / with invalid Authorization'; is_http $cb->(GET '/', Authorization => $auth), 200, 'Anon', 'GET / with bad user/pass'; is_http $cb->(POST '/register'), 400, 'Missing parameter username', 'POST /register with no parameters'; - is_http $cb->(POST '/register', [@register_args, username => '???'] ), 400, 'Username must match (?^a:^\w{2,20}$)', 'POST /register with bad username'; + is_http $cb->(POST '/register', [@register_args, username => '???'] ), 400, 'Username must match (?^as:^\w{2,20}$)', 'POST /register with bad username'; is_http $cb->(POST '/register', [@register_args, password => '???'] ), 400, 'The two passwords do not match', 'POST /register with different passwords'; is_http $cb->(POST '/register', \@register_args), 200, 'Registered successfully', 'POST /register with correct parameters', is_http $cb->(POST '/register', \@register_args), 400, 'Username already in use', 'POST /register with existing user',