create and use get, update, delete instead of old
deleteParams, deleteSingleParam -> delete getParams -> get saveParams -> update
This commit is contained in:
parent
2554a45a15
commit
fa73d81251
11 changed files with 214 additions and 145 deletions
5
t/Auth.t
5
t/Auth.t
|
|
@ -24,7 +24,6 @@ use WebGUI::Session;
|
|||
my $session = WebGUI::Test->session;
|
||||
|
||||
my @cleanupUsernames = (); # Will be cleaned up when we're done
|
||||
my $AUTH_METHOD = "TEST"; # Used as second argument to WebGUI::Auth->new
|
||||
my $auth; # will be used to create auth instances
|
||||
my ($request, $oldRequest, $output);
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ my $createAccountSession = WebGUI::Test->newSession(0, {
|
|||
returnUrl => 'REDIRECT_URL',
|
||||
});
|
||||
|
||||
$auth = WebGUI::Auth->new( $createAccountSession, $AUTH_METHOD );
|
||||
$auth = WebGUI::Auth->new( $createAccountSession );
|
||||
my $username = $createAccountSession->id->generate;
|
||||
push @cleanupUsernames, $username;
|
||||
$output = $auth->createAccountSave( $username, { }, "PASSWORD" );
|
||||
|
|
@ -77,7 +76,7 @@ my $loginSession = WebGUI::Test->newSession(0, {
|
|||
returnUrl => 'REDIRECT_LOGIN_URL',
|
||||
});
|
||||
|
||||
$auth = WebGUI::Auth->new( $loginSession, $AUTH_METHOD, 3 );
|
||||
$auth = WebGUI::Auth->new( $loginSession, 3 );
|
||||
my $username = $loginSession->id->generate;
|
||||
push @cleanupUsernames, $username;
|
||||
$session->setting->set('showMessageOnLogin', 0);
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ $user->update({
|
|||
username => "Andy Dufresne",
|
||||
});
|
||||
my $auth = $user->authInstance;
|
||||
$auth->saveParams( $user->getId, $user->get('authMethod'), {
|
||||
$auth->update(
|
||||
ldapUrl => $ldapProps->{ldapUrl},
|
||||
connectDN => "uid=Andy Dufresne,o=shawshank",
|
||||
ldapConnection => $ldapProps->{ldapLinkId},
|
||||
} );
|
||||
);
|
||||
|
||||
$session->request->setup_body({
|
||||
username => 'Andy Dufresne',
|
||||
|
|
@ -134,7 +134,7 @@ $auth = WebGUI::Auth::LDAP->new( $session, 'LDAP' );
|
|||
$out = $auth->login;
|
||||
is $session->user->get('username'), 'Brooks Hatley', 'Brooks was created';
|
||||
cmp_deeply(
|
||||
$auth->getParams,
|
||||
$auth->get,
|
||||
{
|
||||
connectDN => 'uid=Brooks Hatley,o=shawshank',
|
||||
ldapConnection => '00000000000000testlink',
|
||||
|
|
@ -167,7 +167,7 @@ $auth = WebGUI::Auth::LDAP->new( $session, 'LDAP' );
|
|||
$out = $auth->login;
|
||||
is $session->user->get('username'), 'Brooks Hatley', 'Brooks was logged in after name change';
|
||||
cmp_deeply(
|
||||
$auth->getParams,
|
||||
$auth->get,
|
||||
{
|
||||
connectDN => 'uid=Brooks Hatlen,o=shawshank',
|
||||
ldapConnection => '00000000000000testlink',
|
||||
|
|
|
|||
|
|
@ -88,8 +88,9 @@ my $userId = $session->db->quickScalar(
|
|||
"SELECT userId FROM authentication WHERE authMethod=? AND fieldName=? AND fieldData=?",
|
||||
[ "Twitter", "twitterUserId", "2345" ],
|
||||
);
|
||||
ok( $userId, 'user exists in authentication table' );
|
||||
$user = WebGUI::User->new( $session, $userId );
|
||||
note( $userId );
|
||||
isnt( $user->userId, 1, 'user exists in authentication table' );
|
||||
is( $user->username, "RedHerring", "correct username is set" );
|
||||
WebGUI::Test->addToCleanup( $user );
|
||||
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ WebGUI::Test->addToCleanup($user);
|
|||
$user->username( $USERNAME );
|
||||
$user->addToGroups( ['3'] );
|
||||
my $auth = WebGUI::Operation::Auth::getInstance( $session, $user->authMethod, $user->userId );
|
||||
$auth->saveParams( $user->userId, $user->authMethod, {
|
||||
$auth->update(
|
||||
'identifier' => $auth->hashPassword($IDENTIFIER)
|
||||
});
|
||||
);
|
||||
|
||||
my ($redirect, $response, $url);
|
||||
|
||||
|
|
@ -115,8 +115,6 @@ $mech->get_ok( $assetUrl . "?op=auth;method=displayLogin" );
|
|||
$mech->submit_form_ok(
|
||||
{
|
||||
with_fields => {
|
||||
op => 'auth',
|
||||
method => 'login',
|
||||
username => $USERNAME,
|
||||
identifier => $IDENTIFIER,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue