Skip to content

Commit

Permalink
Item12263: Also verify the Mapper caches
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@16092 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Nov 24, 2012
1 parent bfa0cd7 commit 625e6d3
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions UnitTestContrib/test/unit/FuncUsersTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1866,25 +1866,15 @@ sub verify_getWikiNameOfWikiName {

# Dump the caches, shoudl be empty except for the guest user
print STDERR "======= CACHE Before tests ============\n";
print STDERR 'WikiName2CUID: '
. Data::Dumper::Dumper( \$users->{wikiName2cUID} );
print STDERR 'cUID2WkikName: '
. Data::Dumper::Dumper( \$users->{cUID2WikiName} );
print STDERR 'cUID2Login: ' . Data::Dumper::Dumper( \$users->{cUID2Login} );
print STDERR 'login2cUID: ' . Data::Dumper::Dumper( \$users->{login2cUID} );
_dumpUserCache($users);

# Calling getWikiName for a WikiName corrupts the caches
$this->assert_equals( Foswiki::Func::getWikiName('UserA'),
'UserA', 'getWikiName failed to return expected WikiName' );

# Dump the caches, should contain the mappings for UserA
print STDERR "======= CACHE After corruption ============\n";
print STDERR 'WikiName2CUID: '
. Data::Dumper::Dumper( \$users->{wikiName2cUID} );
print STDERR 'cUID2WkikName: '
. Data::Dumper::Dumper( \$users->{cUID2WikiName} );
print STDERR 'cUID2Login: ' . Data::Dumper::Dumper( \$users->{cUID2Login} );
print STDERR 'login2cUID: ' . Data::Dumper::Dumper( \$users->{login2cUID} );
_dumpUserCache($users);

$this->assert_equals( Foswiki::Func::wikiToUserName('UserA'),
$loginname{UserA},
Expand Down Expand Up @@ -1913,15 +1903,46 @@ sub verify_getWikiNameOfWikiName {
'getCanonicalUserID failed when called with Web.WikiName'
);

# Verify that all of the cache entries are valid
$this->assert_equals(
$loginname{UserA},
$users->_getMapping( $loginname{UserA} )->{L2U}{ $loginname{UserA} },
'L2U is incorrect'
) if defined $users->_getMapping( $loginname{UserA} )->{L2U};
$this->assert_equals(
$loginname{UserA},
$users->_getMapping( $loginname{UserA} )->{W2U}{UserA},
'W2U is incorrect'
) if defined $users->_getMapping( $loginname{UserA} )->{W2U};
$this->assert_equals(
'UserA',
$users->_getMapping( $loginname{UserA} )->{U2W}{ $loginname{UserA} },
'U2W is incorrect'
) if defined $users->_getMapping( $loginname{UserA} )->{U2W};

print STDERR "======= CACHE At End ============\n";
_dumpUserCache($users);

return;
}

sub _dumpUserCache {
my $users = shift;
print STDERR 'WikiName2CUID: '
. Data::Dumper::Dumper( \$users->{wikiName2cUID} );
print STDERR 'cUID2WkikName: '
. Data::Dumper::Dumper( \$users->{cUID2WikiName} );
print STDERR 'cUID2Login: ' . Data::Dumper::Dumper( \$users->{cUID2Login} );
print STDERR 'login2cUID: ' . Data::Dumper::Dumper( \$users->{login2cUID} );

return;
print STDERR 'L2U'
. Data::Dumper::Dumper(
\$users->_getMapping( $loginname{'UserA'} )->{L2U} );
print STDERR 'W2U'
. Data::Dumper::Dumper(
\$users->_getMapping( $loginname{'UserA'} )->{W2U} );
print STDERR 'U2W'
. Data::Dumper::Dumper(
\$users->_getMapping( $loginname{'UserA'} )->{U2W} );
}

#http://foswiki.org/Tasks/
Expand Down

0 comments on commit 625e6d3

Please sign in to comment.