Skip to content
Snippets Groups Projects
Commit e90c0377 authored by Laurent's avatar Laurent
Browse files

dev #60742 La Souris Qui Raconte: implements SSO authentication

parent 915472c2
Branches
Tags
4 merge requests!2334Master,!2239Dev#60742 connecteur sso moissonnage la souris qui raconte,!2228Dev#60742 connecteur sso moissonnage la souris qui raconte,!2226Dev#60742 connecteur sso moissonnage la souris qui raconte
Pipeline #1960 failed with stage
in 13 minutes and 8 seconds
......@@ -42,11 +42,6 @@ class LaSourisQuiRaconte_Config extends Class_DigitalResource_Config {
}
public function hasRightAccess($user) {
return $user && $user->isAbonnementValid();
}
public function isEnabled() {
return '' != $this->getAdminVar('TOKEN');
}
......
......@@ -27,6 +27,7 @@ class LaSourisQuiRaconteSSoTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Storm_Cache::beVolatile();
Class_AdminVar::set('LaSourisQuiRaconte_TOKEN', 'bokeh_export');
$this->_tom = $this->fixture('Class_Users',
['id' => 1,
......@@ -43,13 +44,16 @@ class LaSourisQuiRaconteSSoTest extends AbstractControllerTestCase {
}
/** @test */
public function userWithRightPermissonsShouldBeRedirectedToLSQROnModulesAccess() {
protected function _logValidUser() {
$group = $this->fixture('Class_UserGroup', ['id' => 1]);
$this->_tom
->beAbonneSIGB()
->setDateFin('9999-01-01')
->setIdabon('2345')
->setBib($this->fixture('Class_Bib',
['id' => 2,
'libelle' => 'Annecy']))
->setUserGroups([$group])
->save();
......@@ -58,7 +62,12 @@ class LaSourisQuiRaconteSSoTest extends AbstractControllerTestCase {
['id' => 1,
'code' => 'LaSourisQuiRaconte'])
->permitTo($group, new Class_Entity());
}
/** @test */
public function userWithRightPermissonsShouldBeRedirectedToLSQROnModulesAccess() {
$this->_logValidUser();
$ticket = (new Class_CasTicket())->getTicketForCurrentUser();
$this->dispatch('/opac/modules/la-souris-qui-raconte', true);
......@@ -72,4 +81,44 @@ class LaSourisQuiRaconteSSoTest extends AbstractControllerTestCase {
$this->_response->getBody());
}
/** @test */
public function validateAuthWithoutTicketShouldAnswerError() {
$this->dispatch('/LaSourisQuiRaconte_Plugin/auth/validate', true);
$this->assertEquals(['response' => ['success' => 'false',
'error' => 'Paramètre ticket non fourni']],
json_decode($this->_response->getBody(), true));
}
/** @test */
public function validateAuthWithInvalidTicketShouldAnswerError() {
$this->dispatch('/LaSourisQuiRaconte_Plugin/auth/validate/ticket/666', true);
$this->assertEquals(['response' => ['success' => 'false',
'error' => 'Ticket invalide']],
json_decode($this->_response->getBody(), true));
}
/** @test */
public function validateWithValidUserTicketShouldAnswerSuccessAndLibraryName() {
$this->_logValidUser();
$ticket = (new Class_CasTicket())->getTicketForCurrentUser();
$this->dispatch('/LaSourisQuiRaconte_Plugin/auth/validate/ticket/' . $ticket,
true);
$this->assertEquals(['response' => ['success' => 'true',
'bibname' => 'Annecy']],
json_decode($this->_response->getBody(), true));
}
/** @test */
public function validateWithUserWithoutPermissionShouldAnswerError() {
$ticket = (new Class_CasTicket())->getTicketForCurrentUser();
$this->dispatch('/LaSourisQuiRaconte_Plugin/auth/validate/ticket/' . $ticket,
true);
$this->assertEquals(['response' => ['success' => 'false',
'error' => 'L\'utilisateur n\'est pas autorisé à accéder à cette ressource']],
json_decode($this->_response->getBody(), true));
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment