Skip to content
Snippets Groups Projects
Commit f9ef7c97 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #73433 : never break chain if no server has responded

parent 434d4cc2
4 merge requests!3297WIP: Master,!2919Master,!2918Hotline,!2916hotline #73433 : try to not log patron when webservice provides authentication and fail
Pipeline #5511 failed with stage
in 26 minutes and 33 seconds
......@@ -60,15 +60,15 @@ class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface {
public function shouldBreakChain() {
if (!$this->_called_services)
return false;
return Class_AdminVar::isLoginThroughSigbOnlyEnabled()
|| $this->_allCalledServicesProvideAuthentication();
}
protected function _allCalledServicesProvideAuthentication() {
if (!$this->_called_services)
return false;
foreach($this->_called_services as $service)
if (!$service->providesAuthentication())
return false;
......
......@@ -118,7 +118,7 @@ class Mock_ZendAfi_Auth_MD5_BASE64_Adapter implements Zend_Auth_Adapter_Interfac
class AuthWithValidLocalButInvalidNanookAccountTest extends ModelTestCase {
abstract class AuthWithConfiguredNanookTestCase extends ModelTestCase {
protected
$_cache,
$_result,
......@@ -127,11 +127,7 @@ class AuthWithValidLocalButInvalidNanookAccountTest extends ModelTestCase {
public function setUp() {
parent::setUp();
$this->_cache = $this->mock()
->whenCalled('save')->answers(true)
->whenCalled('load')->answers(null)
->whenCalled('remove')->answers(true);
$this->_cache = $this->mock();
Storm_Cache::setDefaultZendCache($this->_cache);
$comm_params = ['url_serveur' => 'http://localhost:8080/afi_Nanook/ilsdi/',
......@@ -148,6 +144,23 @@ class AuthWithValidLocalButInvalidNanookAccountTest extends ModelTestCase {
->answers(Class_WebService_SIGB_Emprunteur::nullInstance())
->whenCalled('providesAuthentication')->answers(true);
Class_WebService_SIGB_Nanook::setService($comm_params, $this->_nanook);
}
public function tearDown() {
Storm_Cache::setDefaultZendCache(null);
Class_WebService_SIGB_Nanook::reset();
ZendAfi_Auth::getInstance()->setAuthDb(null);
parent::tearDown();
}
}
class AuthWithValidLocalButInvalidNanookAccountTest extends AuthWithConfiguredNanookTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Users',
['id' => 25,
......@@ -169,23 +182,55 @@ class AuthWithValidLocalButInvalidNanookAccountTest extends ModelTestCase {
}
public function tearDown() {
Storm_Cache::setDefaultZendCache(null);
Class_WebService_SIGB_Nanook::reset();
ZendAfi_Auth::getInstance()->setAuthDb(null);
parent::tearDown();
/** @test */
public function harlockShouldNotBeLogged() {
$this->assertFalse($this->_result);
}
/** @test */
public function harlockShouldNotBeLogged() {
$this->assertFalse($this->_result);
public function harlockShouldNotBeStoredInSession() {
$this->assertTrue($this->_cache->methodHasNotBeenCalled('save'));
}
}
class AuthWithLocalAdminAndLoginThroughSigbOnlyTest extends AuthWithConfiguredNanookTestCase {
public function setUp() {
parent::setUp();
$this->_cache->whenCalled('load')->answers(null)
->whenCalled('save')->answers(true);
$this->fixture('Class_Users',
['id' => 75,
'login' => 'harlock',
'password' => 'nausicaa!rulez',
'bib' => $this->fixture('Class_Bib', ['id' => 3]),
'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_BIB]);
$auth_db = (new Mock_AuthDB())
->setResultObject((object)['ID_USER' => 75, 'LOGIN' => 'harlock'])
->beSucess();
Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', 1);
$this->_result = ZendAfi_Auth::getInstance()
->setAuthDb($auth_db)
->authenticateLoginPassword('harlock', 'nausicaa!rulez');
}
/** @test */
public function harlockShouldBeLogged() {
$this->assertTrue($this->_result);
}
/** @test */
public function harlockShouldBeStoredInSession() {
$this->assertTrue($this->_cache->methodHasNotBeenCalled('save'));
$this->assertTrue($this->_cache->methodHasBeenCalled('save'));
}
}
......
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