Skip to content

Commit 04785a3

Browse files
authored
Remove getPersistentId, since it is incorrect (#23)
1 parent f9b7f10 commit 04785a3

File tree

2 files changed

+0
-120
lines changed

2 files changed

+0
-120
lines changed

Diff for: src/Talis/Persona/Client/Login.php

-27
Original file line numberDiff line numberDiff line change
@@ -120,33 +120,6 @@ public function validateAuth()
120120
return $this->isLoggedIn();
121121
}
122122

123-
/**
124-
* Get users persistent ID - it finds a persistent ID that matches the login provider
125-
* @return boolean|string pid else boolean false
126-
*/
127-
public function getPersistentId()
128-
{
129-
if (!isset($_SESSION[self::LOGIN_PREFIX . ':loginProvider'])) {
130-
return false;
131-
}
132-
133-
if (
134-
isset($_SESSION[self::LOGIN_PREFIX . ':loginSSO']['gupid'])
135-
&& !empty($_SESSION[self::LOGIN_PREFIX . ':loginSSO']['gupid'])
136-
) {
137-
// Loop through all gupids and match against the login provider - it should be
138-
// the prefix of the persona profile
139-
foreach ($_SESSION[self::LOGIN_PREFIX . ':loginSSO']['gupid'] as $gupid) {
140-
$loginProvider = $_SESSION[self::LOGIN_PREFIX . ':loginProvider'];
141-
if (strpos($gupid, $loginProvider) === 0) {
142-
return str_replace("$loginProvider:", '', $gupid);
143-
}
144-
}
145-
}
146-
147-
return false;
148-
}
149-
150123
/**
151124
* Get redirect URL value
152125
* @return string|boolean redirect url else boolean false

Diff for: test/unit/Persona/LoginTest.php

-93
Original file line numberDiff line numberDiff line change
@@ -405,103 +405,10 @@ public function testValidateAuthAfterRequireAuth()
405405

406406
$this->assertTrue($mockClient->validateAuth());
407407

408-
$this->assertEquals('123', $mockClient->getPersistentId());
409408
$this->assertEquals(['919191'], $mockClient->getScopes());
410409
$this->assertEquals('http://example.com/wherever', $mockClient->getRedirectUrl());
411410
}
412411

413-
// getPersistentId tests
414-
public function testGetPersistentIdNoSession()
415-
{
416-
$personaClient = new Login(
417-
[
418-
'userAgent' => 'unittest',
419-
'persona_host' => 'localhost',
420-
'cacheBackend' => $this->cacheBackend,
421-
]
422-
);
423-
$this->assertFalse($personaClient->getPersistentId());
424-
}
425-
426-
public function testGetPersistentIdNoGupidInSession()
427-
{
428-
$personaClient = new Login(
429-
[
430-
'userAgent' => 'unittest',
431-
'persona_host' => 'localhost',
432-
'cacheBackend' => $this->cacheBackend,
433-
]
434-
);
435-
$_SESSION[Login::LOGIN_PREFIX . ':loginSSO'] = [];
436-
$this->assertFalse($personaClient->getPersistentId());
437-
}
438-
439-
public function testGetPersistentIdNoLoginProviderInSession()
440-
{
441-
$personaClient = new Login(
442-
[
443-
'userAgent' => 'unittest',
444-
'persona_host' => 'localhost',
445-
'cacheBackend' => $this->cacheBackend,
446-
]
447-
);
448-
$_SESSION[Login::LOGIN_PREFIX . ':loginSSO'] = [];
449-
$this->assertFalse($personaClient->getPersistentId());
450-
}
451-
452-
public function testGetPersistentIdEmptyGupids()
453-
{
454-
$personaClient = new Login(
455-
[
456-
'userAgent' => 'unittest',
457-
'persona_host' => 'localhost',
458-
'cacheBackend' => $this->cacheBackend,
459-
]
460-
);
461-
$_SESSION[Login::LOGIN_PREFIX . ':loginProvider'] = 'trapdoor';
462-
$_SESSION[Login::LOGIN_PREFIX . ':loginSSO'] = ['gupid' => []];
463-
464-
$this->assertFalse($personaClient->getPersistentId());
465-
}
466-
467-
public function testGetPersistentIdNoMatchingGupid()
468-
{
469-
$personaClient = new Login(
470-
[
471-
'userAgent' => 'unittest',
472-
'persona_host' => 'localhost',
473-
'cacheBackend' => $this->cacheBackend,
474-
]
475-
);
476-
$_SESSION[Login::LOGIN_PREFIX . ':loginProvider'] = 'trapdoor';
477-
$_SESSION[Login::LOGIN_PREFIX . ':loginSSO'] = [
478-
'gupid' => [
479-
'google:123',
480-
'twitter:456'
481-
]
482-
];
483-
$this->assertFalse($personaClient->getPersistentId());
484-
}
485-
486-
public function testGetPersistentIdFoundMatchingGupid()
487-
{
488-
$personaClient = new Login(
489-
[
490-
'userAgent' => 'unittest',
491-
'persona_host' => 'localhost',
492-
'cacheBackend' => $this->cacheBackend,
493-
]
494-
);
495-
$_SESSION[Login::LOGIN_PREFIX . ':loginProvider'] = 'trapdoor';
496-
$_SESSION[Login::LOGIN_PREFIX . ':loginSSO'] = [
497-
'gupid' => [
498-
'google:123',
499-
'trapdoor:456'
500-
]
501-
];
502-
$this->assertEquals('456', $personaClient->getPersistentId());
503-
}
504-
505412
// getRedirectUrl tests
506413
public function testGetRedirectUrlNoSession()
507414
{

0 commit comments

Comments
 (0)