diff --git a/library/Class/WebService/SIGB/AbstractRESTService.php b/library/Class/WebService/SIGB/AbstractRESTService.php
index 551b76bc806f8858aabe012bbc8a57f3dafcece4..b08b8a69c64c038d355956a43cde6bdd34164912 100644
--- a/library/Class/WebService/SIGB/AbstractRESTService.php
+++ b/library/Class/WebService/SIGB/AbstractRESTService.php
@@ -146,6 +146,22 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic
 	}
 
 
+	/**
+	 * Authentifie un utilisateur via SIGB et si réussi affecte l'id_sigb reçu
+	 * @param $user Class_Users
+	 */
+	public function ilsdiAuthenticatePatron($user) {
+		$params = ['service' => 'AuthenticatePatron',
+			         'username' => $user->getIdabon(),
+			         'password' => $user->getPassword()];
+
+		$xml = $this->httpGet($params);
+
+		if ('' != $patronId = $this->_getTagData($xml, 'patronId'))
+			$user->setIdSigb($patronId);
+	}
+		
+
 	/**
 	 * @param array $params
 	 * @return array
@@ -169,8 +185,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic
 	public function ilsdiRenewLoan($params, $error_tag='error') {
 		return $this->ilsdiAction('RenewLoan', $params, $error_tag, 'Prolongation impossible');
 	}
-
-
+	
+		
 	public function ilsdiAction($name, $params, $error_tag, $error_message) {
 		$params = array_merge(array('service' => $name), $params);
 
diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php
index 37f51f809c92510bc59c1eb093699961a8227969..76dc128f3538e0d20129f23a66ddc277401b1745 100644
--- a/library/Class/WebService/SIGB/Nanook/Service.php
+++ b/library/Class/WebService/SIGB/Nanook/Service.php
@@ -29,12 +29,13 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac
 		return parent::setServerRoot($server_root);
 	}
 
-
+	
 	/**
 	 * @param Class_Users $user
 	 * @return Class_WebService_SIGB_Emprunteur
 	 */
 	public function getEmprunteur($user) {
+		$this->_authenticate($user);
 		return $this->ilsdiGetPatronInfo(array('patronId' => $user->getIdSigb()),
 																		 Class_WebService_SIGB_Nanook_PatronInfoReader::newInstance());
 	}
@@ -110,5 +111,15 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac
 		return $this->getServerRoot() . implode('/', $parts);
 	}
 
+
+	/**
+	 * @param $user Class_Users
+	 */
+	protected function _authenticate($user) {
+		if (null != $user->getIdSigb())
+			return;
+
+		$this->ilsdiAuthenticatePatron($user);
+	}
 }
 ?>
\ No newline at end of file
diff --git a/tests/application/modules/admin/controllers/UploadControllerTest.php b/tests/application/modules/admin/controllers/UploadControllerTest.php
index 8a971a34da513405642dad4fcd74658c53b92d1d..1fe3bba75a6b05f57f43cf646777f9cdb56bc02e 100644
--- a/tests/application/modules/admin/controllers/UploadControllerTest.php
+++ b/tests/application/modules/admin/controllers/UploadControllerTest.php
@@ -165,7 +165,7 @@ class UploadControllerVignetteNoticeActionTest extends AbstractControllerTestCas
 
 	/** @test */
 	public function previewImgSrcShouldBePosterDotJpeg() {
-		$this->assertXPath('//img[@class="preview"][@src="http://harrypotter.com/poster.jpg"]');
+		$this->assertXPath('//img[@class="preview"][@src="http://harrypotter.com/poster.jpg"]', $this->_response->getBody());
 	}
 }
 
diff --git a/tests/library/Class/WebService/SIGB/NanookFixtures.php b/tests/library/Class/WebService/SIGB/NanookFixtures.php
index 95b69b4d146f8b9041c8bfd6f34ac9883ad4bf33..cdc57c98a52d3b5513d903c54afd95982bec005d 100644
--- a/tests/library/Class/WebService/SIGB/NanookFixtures.php
+++ b/tests/library/Class/WebService/SIGB/NanookFixtures.php
@@ -217,4 +217,13 @@ class NanookFixtures {
 			</body>
 		</html>';
 	}
+
+
+	/** @return string */
+	public static function xmlAuthenticatePatronChristelDelpeyroux() {
+		return '<?xml version="1.0" encoding="utf-8"?>
+<AuthenticatePatron>
+  <patronId>1</patronId>
+</AuthenticatePatron>';
+	}
 }
\ No newline at end of file
diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php
index 23d4c1ab293387fa2b035ebf72d415efdc9e4b73..d8a5992596d214ea06136501da84e58f6cbb2715 100644
--- a/tests/library/Class/WebService/SIGB/NanookTest.php
+++ b/tests/library/Class/WebService/SIGB/NanookTest.php
@@ -72,7 +72,7 @@ abstract class NanookTestCase extends Storm_Test_ModelTestCase {
 	public function setUp() {
 		parent::setUp();
 
-		$this->_mock_web_client = $this->getMock('Class_WebService_SimpleWebClient');
+		$this->_mock_web_client = Storm_Test_ObjectWrapper::on(new Class_WebService_SimpleWebClient());
 
 		$this->_service = Class_WebService_SIGB_Nanook_Service::newInstance()
 			->setServerRoot('http://localhost:8080/afi_Nanook/ilsdi/')
@@ -137,11 +137,10 @@ class NanookNoConnectionTest extends NanookServiceErrorTestCase {
 		parent::setUp();
 
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
-			->will($this->throwException(
-				new Zend_Http_Client_Adapter_Exception('Unable to connect')
-			));
+			->whenCalled('open_url')
+			->willDo(function () {
+				throw new Zend_Http_Client_Adapter_Exception('Unable to connect');
+			});
 	}
 }
 
@@ -153,9 +152,8 @@ class NanookHtmlResponseTest extends NanookServiceErrorTestCase {
 		parent::setUp();
 
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
-			->will($this->returnValue(NanookFixtures::htmlTomcatError()));
+			->whenCalled('open_url')
+			->answers(NanookFixtures::htmlTomcatError());
 	}
 
 	/** @test */
@@ -184,10 +182,9 @@ class NanookGetNoticeLiliGrisbiAndCoTest extends NanookTestCase {
 		Class_Profil::getCurrentProfil()->setCfgNotice(array('exemplaires' => array()));
 
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetRecords/id/9842')
-			->will($this->returnValue(NanookFixtures::xmlGetRecordLiliGrisbiAndCo()));
+			->answers(NanookFixtures::xmlGetRecordLiliGrisbiAndCo());
 
 		$this->_notice = $this->_service->getNotice('9842');
 
@@ -271,7 +268,7 @@ class NanookGetNoticeLiliGrisbiAndCoTest extends NanookTestCase {
 	/** @test */
 	public function secondExemplaireShouldBeEnPret() {
 		$this->assertEquals(Class_WebService_SIGB_Exemplaire::DISPO_EN_PRET,
-														$this->_notice->exemplaireAt(1)->getDisponibilite());
+												$this->_notice->exemplaireAt(1)->getDisponibilite());
 	}
 
 
@@ -284,7 +281,7 @@ class NanookGetNoticeLiliGrisbiAndCoTest extends NanookTestCase {
 	/** @test */
 	public function secondExemplaireDateRetourShouldBe12012029() {
 		$this->assertEquals('12/01/2029',
-																$this->_notice->exemplaireAt(1)->getDateRetour());
+												$this->_notice->exemplaireAt(1)->getDateRetour());
 	}
 
 
@@ -306,10 +303,9 @@ class NanookGetNoticeWithErrorTest extends NanookTestCase {
 	/** @test */
 	public function noticeShouldBeNull() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetRecords/id/666')
-			->will($this->returnValue(NanookFixtures::xmlGetRecordError()));
+			->answers(NanookFixtures::xmlGetRecordError());
 
 		$this->assertNull($this->_service->getNotice('666'));
 	}
@@ -327,10 +323,9 @@ class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase {
 		parent::setUp();
 
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/1')
-			->will($this->returnValue(NanookFixtures::xmlGetPatronChristelDelpeyroux()));
+			->answers(NanookFixtures::xmlGetPatronChristelDelpeyroux());
 
 		$this->_emprunteur = $this->_service->getEmprunteur(
 														Class_Users::getLoader()
@@ -558,10 +553,9 @@ class NanookGetEmprunteurWithErrorTest extends NanookTestCase {
 	/** @test */
 	public function emprunteurShouldBeEmpty() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/666')
-			->will($this->returnValue(NanookFixtures::xmlGetPatronError()));
+			->answers(NanookFixtures::xmlGetPatronError());
 
 		$emprunteur = $this->_service->getEmprunteur(
 																								 Class_Users::getLoader()
@@ -577,15 +571,36 @@ class NanookGetEmprunteurWithErrorTest extends NanookTestCase {
 
 
 
+class NanookGetEmprunteurWithoutIdSigbTest extends NanookTestCase {
+	/** @test */
+	public function shouldAuthenticate() {
+		$this->_mock_web_client
+			->whenCalled('open_url')
+			->with('http://localhost:8080/afi_Nanook/ilsdi/service/AuthenticatePatron/username/90175000410218/password/1989')
+			->answers(NanookFixtures::xmlAuthenticatePatronChristelDelpeyroux())
+
+			->whenCalled('open_url')
+			->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/1')
+			->answers(NanookFixtures::xmlGetPatronError());
+				
+		$emprunteur = $this->_service->getEmprunteur($user = Class_Users::newInstance()
+			                                                     ->setIdabon('90175000410218')
+			                                                     ->setPassword('1989'));
+
+		$this->assertNotNull($emprunteur);
+		$this->assertEquals(1, $user->getIdSigb());
+	}
+}
+
+
 
 class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function prolongerPretShouldReturnSuccessIfNoErrors() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/RenewLoan/patronId/1/itemId/196895')
-			->will($this->returnValue(NanookFixtures::xmlRenewLoanSucces()));
+			->answers(NanookFixtures::xmlRenewLoanSucces());
 
 		$this->assertEquals(
 			array('statut' => true, 'erreur' => ''),
@@ -600,10 +615,9 @@ class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function prolongerPretShouldReturnFailureIfErrors() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/RenewLoan/patronId/1/itemId/196895')
-			->will($this->returnValue(NanookFixtures::xmlRenewLoanError()));
+			->answers(NanookFixtures::xmlRenewLoanError());
 
 		$this->assertEquals(
 			array('statut' => false, 'erreur' => 'Prolongation impossible'),
@@ -618,10 +632,9 @@ class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function reserverExemplaireOnExistingAnnexeWithNoErrorsShouldReturnSuccess() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/HoldTitle/bibId/196895/patronId/1/pickupLocation/10')
-			->will($this->returnValue(NanookFixtures::xmlHoldTitleSuccess()));
+			->answers(NanookFixtures::xmlHoldTitleSuccess());
 
 		$this->assertEquals(array('statut' => true, 'erreur' => ''),
 												$this->_service->reserverExemplaire(
@@ -635,10 +648,9 @@ class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function reserverExemplaireShouldReturnFailureIfErrors() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/HoldTitle/bibId/196895/patronId/1/pickupLocation/Site+Principal')
-			->will($this->returnValue(NanookFixtures::xmlHoldTitleError()));
+			->answers(NanookFixtures::xmlHoldTitleError());
 
 		$this->assertEquals(array('statut' => false, 'erreur' => 'Réservation impossible'),
 												$this->_service->reserverExemplaire(
@@ -652,10 +664,9 @@ class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function supprimerReservationShouldReturnSuccessIfNoErrors() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/CancelHold/patronId/1/itemId/196895')
-			->will($this->returnValue(NanookFixtures::xmlCancelHoldSuccess()));
+			->answers(NanookFixtures::xmlCancelHoldSuccess());
 
 		$this->assertEquals(array('statut' => true, 'erreur' => ''),
 												$this->_service->supprimerReservation(
@@ -668,10 +679,9 @@ class NanookOperationsTest extends NanookTestCase {
 	/** @test */
 	public function supprimerReservationShouldReturnFailureIfErrors() {
 		$this->_mock_web_client
-			->expects($this->once())
-			->method('open_url')
+			->whenCalled('open_url')
 			->with('http://localhost:8080/afi_Nanook/ilsdi/service/CancelHold/patronId/1/itemId/196895')
-			->will($this->returnValue(NanookFixtures::xmlCancelHoldError()));
+			->answers(NanookFixtures::xmlCancelHoldError());
 
 		$this->assertEquals(array('statut' => false, 'erreur' => 'Annulation impossible'),
 												$this->_service->supprimerReservation(