diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index 94fb96c2c9bf8717514d2063f7a7502e4b3cf5c2..a0cd71f0549d0496e975440d89d49bb27bba229c 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -71,18 +71,18 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac 'password' => $user->getPassword()]; $xml = $this->httpGet($params); - if ('' != $patronId = $this->_getTagData($xml, 'patronId')) { - $user->setIdSigb($patronId); - return true; - } - if ('PatronPasswordNotSecure' == $this->_getTagData($xml, 'error')) { - $message = $this->_getTagData($xml, 'message'); - $pattern = $this->_getTagData($xml, 'pattern'); + $message = $this->_getTagData($xml, 'securePasswordLabel'); + $pattern = '/' . $this->_getTagData($xml, 'securePasswordPattern') . '/'; throw new Class_WebService_SIGB_Nanook_PatronPasswordNotSecureException($message, $pattern); } + if ('' != $patronId = $this->_getTagData($xml, 'patronId')) { + $user->setIdSigb($patronId); + return true; + } + return false; } diff --git a/tests/application/modules/opac/controllers/AuthControllerWithNanookTest.php b/tests/application/modules/opac/controllers/AuthControllerWithNanookTest.php index e955d0b829155037fc30bcbe7629cc23c4976226..b3d645a53ffc51b3bae10c954dce40ac9836c856 100644 --- a/tests/application/modules/opac/controllers/AuthControllerWithNanookTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerWithNanookTest.php @@ -35,10 +35,10 @@ abstract class AuthControllerNanookTestCase extends AbstractControllerTestCase { ->mock() ->whenCalled('open_url') ->with('http://localhost:8080/afi_Nanook/ilsdi/service/AuthenticatePatron/username/name%40server.tld/password/1987') - ->answers('<?xml version="1.0" encoding="UTF-8"?><AuthenticatePatron><error>PatronPasswordNotSecure</error>'. - '<message>Le mot de passe doit faire au moins 6 caractères et comporter au moins une lettre et un chiffre</message>'. - '<pattern>/^(?=.*[^0-9])(?=.*[0-9]).{6,}$/</pattern>'. - '</AuthenticatePatron>') + ->answers('<?xml version="1.0" encoding="UTF-8"?><AuthenticatePatron><patronId>4</patronId><error>PatronPasswordNotSecure</error>' + . '<securePasswordPattern>^(?=.*[A-Za-z])(?=.*\d).{6,}$</securePasswordPattern>' + . '<securePasswordLabel>Le mot de passe doit comporter au minimum 6 caractères et doit être constitué d\'au moins un chiffre et une lettre</securePasswordLabel>' + . '</AuthenticatePatron>') ->beStrict(); $this->_service = Class_WebService_SIGB_Nanook_Service::newInstance() @@ -91,7 +91,7 @@ class AuthControllerWithNanookPostLoginWithMailAndUnsecurePassword /** @test */ public function pageShouldContainsPasswordExplanation() { - $this->assertXPathContentContains('//p', 'Le mot de passe doit faire au moins'); + $this->assertXPathContentContains('//p', 'Le mot de passe doit comporter au minimum 6'); } @@ -103,7 +103,7 @@ class AuthControllerWithNanookPostLoginWithMailAndUnsecurePassword /** @test */ public function formShouldContainsInputPattern() { - $this->assertXPath('//form//input[@type="hidden"][@value="/^(?=.*[^0-9])(?=.*[0-9]).{6,}$/"][@name="pattern"]'); + $this->assertXPath('//form//input[@type="hidden"][@value="/^(?=.*[A-Za-z])(?=.*\d).{6,}$/"][@name="pattern"]'); }