From: tla Date: Mon, 9 Feb 2015 16:04:54 +0000 (+0100) Subject: add test to check that traditions are taken away from the old Google OpenID user X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=b145d86689af2391a53b9e0ec50526bf680a072d;hp=0e1f8ad143ad77a79f95f32d838c64d0227de13c add test to check that traditions are taken away from the old Google OpenID user --- diff --git a/t/07google.t b/t/07google.t index c02faba..4d35bcd 100644 --- a/t/07google.t +++ b/t/07google.t @@ -163,6 +163,9 @@ io("$FindBin::Bin/var")->rmtree if io("$FindBin::Bin/var")->exists; $ua->get('/logout'); } +my $openid_uid; +my $gplus_uid; +my %tradition_names; { diag("Test converting OpenID based Google account with traditions"); my $scope = $dir->new_scope; @@ -201,14 +204,29 @@ io("$FindBin::Bin/var")->rmtree if io("$FindBin::Bin/var")->exists; sub => 450, email => 'openid@example.org' }); + $openid_uid = $openid_u->kiokudb_object_id; + $gplus_uid = $gplus_u->kiokudb_object_id; foreach my $trad_id (0..$#{ $openid_u->traditions }) { - is($gplus_u->traditions->[$trad_id]->name, $openid_u->traditions->[$trad_id]->name, 'Traditions were copied over to G+ user'); + my $trad = $gplus_u->traditions->[$trad_id]; + $tradition_names{$trad->name} = 1; + is($trad->name, $openid_u->traditions->[$trad_id]->name, 'Traditions were copied over to G+ user'); } $ua->get('/logout'); } +{ + diag("Check that the user traditions were removed from the old user"); + my $scope = $dir->new_scope; + my $openid_u = $dir->lookup( $openid_uid ); + my $gplus_u = $dir->lookup( $gplus_uid ); + is( scalar @{$openid_u->traditions}, 0, "Traditions were removed from old user" ); + foreach my $tradition ( @{$gplus_u->traditions} ) { + ok( $tradition_names{ $tradition->name }, "Tradition has remained with new user" ); + } +} + { diag("Verify we can login the new Google+ account again"); my $scope = $dir->new_scope;