From 42ce7397f1a1c0f59a1896d5f62d49ef4fe97b38 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 22 Apr 2016 11:28:51 +0100 Subject: Fix Twitter authentication test. Pull in the same fix that was made in f598f56f for the Facebook tests. --- t/app/controller/auth_social.t | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t index bfb6017e2..6929c0ddc 100644 --- a/t/app/controller/auth_social.t +++ b/t/app/controller/auth_social.t @@ -147,7 +147,10 @@ my $tw_uid = 987654321; for my $tw_state ( 'refused', 'existing UID', 'no email' ) { for my $page ( 'my', 'report', 'update' ) { subtest "test Twitter '$tw_state' login for page '$page'" => sub { + # Lots of user changes happening here, make sure we don't confuse + # Catalyst with a cookie session user that no longer exists $mech->log_out_ok; + $mech->cookie_jar({}); if ($tw_state eq 'existing UID') { my $user = $mech->create_user_ok($tw_email); $user->update({ twitter_id => $tw_uid }); @@ -155,12 +158,12 @@ for my $tw_state ( 'refused', 'existing UID', 'no email' ) { $mech->delete_user($tw_email); } - # Set up a mock to catch (most, see below) requests to Facebook + # Set up a mock to catch (most, see below) requests to Twitter my $tw = t::Mock::Twitter->new; LWP::Protocol::PSGI->register($tw->to_psgi_app, host => 'api.twitter.com'); # Due to https://metacpan.org/pod/Test::WWW::Mechanize::Catalyst#External-Redirects-and-allow_external - # the redirect to Facebook's OAuth page can mess up the session + # the redirect to Twitter's OAuth page can mess up the session # cookie. So let's pretend we always on api.twitter.com, which # sorts that out. $mech->host('api.twitter.com'); -- cgit v1.2.3