summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-29 20:12:59 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-29 20:12:59 +0200
commit25d0530e860e2103fd28f556ac728c4f72fcd45a (patch)
tree0e42e748071ad2e6554c3a3ab16c0dd929da80d4 /t
parent6ff397c9b3b702805e248783243368a5dc5388b4 (diff)
Add password reset functionality
Closes #5
Diffstat (limited to 't')
-rw-r--r--t/02-registration.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/02-registration.t b/t/02-registration.t
index 48d7d4c..89bf475 100644
--- a/t/02-registration.t
+++ b/t/02-registration.t
@@ -159,5 +159,45 @@ $t->post_ok(
);
$t->status_is(302)->header_is( location => '/' );
+$csrf_token = $t->ua->get('/account')->res->dom->at('input[name=csrf_token]')
+ ->attr('value');
+$t->post_ok(
+ '/logout' => form => {
+ csrf_token => $csrf_token,
+ }
+);
+$t->status_is(302)->header_is( location => '/login' );
+
+$csrf_token = $t->ua->get('/recover')->res->dom->at('input[name=csrf_token]')
+ ->attr('value');
+$t->post_ok(
+ '/recover' => form => {
+ csrf_token => $csrf_token,
+ action => 'initiate',
+ user => 'someone',
+ email => 'foo@example.org',
+ }
+);
+$t->status_is(200)->content_like(qr{wird durchgeführt});
+
+$res = $t->app->pg->db->select( 'pending_passwords', ['token'],
+ { user_id => $uid } );
+$token = $res->hash->{token};
+
+$t->get_ok("/recover/${uid}/${token}")->status_is(200)
+ ->content_like(qr{Neues Passwort eintragen});
+
+$t->post_ok(
+ '/recover' => form => {
+ csrf_token => $csrf_token,
+ action => 'set_password',
+ id => $uid,
+ token => $token,
+ newpw => 'foofoofoo2',
+ newpw2 => 'foofoofoo2',
+ }
+);
+$t->status_is(302)->header_is( location => '/account' );
+
$t->app->pg->db->query('drop schema travelynx_test_02 cascade');
done_testing();