Commit 234dd27f authored by Laurent's avatar Laurent

Merge branch 'hotline#112284_add_login_ws_requests_to_inspectorgadget' into 'hotline'

hotline#112284 : view  webservices requests on inspector gadget when login

See merge request !3537
parents a44fef71 e32b8c9e
Pipeline #10520 canceled with stage
in 44 minutes and 44 seconds
- ticket #112284 : Inspector Gadget : Ajout de la visualisation des requetes transmises aux SIGB lors de la connexion de l'utilisateur.
\ No newline at end of file
......@@ -161,8 +161,11 @@ class AuthController extends ZendAfi_Controller_Action {
public function loginAction() {
$this->view->preferences = $this->_loginPrefFromWidgetOrModule();
$redirect = $this->_getParam('redirect', '/opac');
$redirect = $this->_getParam('redirect', Class_Url::relative(['module' => 'opac',
'action' => 'index',
'controller' => 'index']));
$this->view->redirect = $redirect;
$service = $this->_getParam('service','');
$this->view->service = $service;
......
......@@ -3,11 +3,20 @@ $url_action = $this->form_action ?
$this->form_action : $this->url(['controller' => 'auth',
'action' => ('boite-login'),
'id_module' => $this->id_module]);
$datas = ['redirect_url' => $this->redirect,
'service' => $this->service,
'id_notice' => $this->id_notice];
if ($inspector_gadget = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget'))
$datas = $inspector_gadget->addToParams($datas);
echo $this->Widget_Login(
new Class_Entity(array_merge(['Preferences' => $this->preferences],
['FormOptions' => ['data' => array_merge($this->preferences,
['redirect_url' => $this->redirect,
'service' => $this->service,
'id_notice' => $this->id_notice]),
$datas),
'action' => $url_action]])));
......@@ -155,6 +155,12 @@ class Class_Url {
*/
public static function assemble(array $urlOptions = array(), $name = null, $reset = true, $encode = true) {
$router = Zend_Controller_Front::getInstance()->getRouter();
$inspector_gadget = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget');
if ($inspector_gadget)
$urlOptions = $inspector_gadget->addToParams($urlOptions);
return $router->assemble($urlOptions, $name, $reset, $encode);
}
......@@ -266,12 +272,6 @@ Bokeh Error : adminVar "NOM_DOMAINE" is empty. Bokeh in php cli mode is unable t
if (is_string($url_array_or_string))
return static::_beginWithSlash($url_array_or_string);
$inspector_gadget = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget');
if ($inspector_gadget)
$url_array_or_string = $inspector_gadget->addToParams($url_array_or_string);
return static::assemble($url_array_or_string, $name, $reset, $encode);
}
}
......@@ -112,6 +112,15 @@ class ZendAfi_Form_Login extends ZendAfi_Form {
array_push($group, 'redirect');
}
if (isset($this->_data['inspector_gadget'])) {
$this->addElement('hidden',
'inspector_gadget',
['value' => $this->_data['inspector_gadget']]);
array_push($group, 'inspector_gadget');
}
if(strlen($this->_service)>1){
$this->addElement('hidden',
'service',
......
......@@ -155,6 +155,15 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa
$this->assertXPathContentContains('//div[@class="barre_nav"]/span','Connexion');
}
/** @test */
public function pageShouldkeepInspectorGadgetInForm() {
$this->bootstrap();
$this->dispatch('/opac/auth/login?inspector_gadget=keep',true);
$this->assertXPath('//form//input[@type="hidden"][@name="inspector_gadget"][@value="keep"]', $this->_response->getBody());
}
}
......@@ -1072,7 +1081,7 @@ class AuthControllerPostSimpleSuccessfulTest extends AuthControllerPostSimpleSuc
/** @test */
public function responseShouldBeARedirectToOPAC() {
$this->assertRedirectTo('/opac');
$this->assertRedirectTo('/');
}
......@@ -1334,7 +1343,7 @@ class AuthControllerPostSimpleFailureTest extends AuthControllerPostSimpleTestCa
public function withAuthenticationFailureResponseShouldBeRedirect() {
$this->postDispatch('/opac/auth/login',
['username' => 'foo', 'password' => 'bar']);
$this->assertRedirectTo('/opac');
$this->assertRedirectTo('/');
}
......
......@@ -307,6 +307,16 @@ class AuthControllerWithNanookPostLoginWithMailAndUnsecurePasswordOthersLogins
/** @test */
public function withActionLoginWithInspectorGadgetShouldDisplayButtonWebserviceCalls() {
$this->postDispatch('/opac/auth/login', ['username' => 'name@server.tld',
'password' => '1987',
'inspector_gadget' => 1]);
$this->assertXPathContentContains('//button', 'Appels webservices', $this->_response->getBody());
}
/** @test */
public function withActionAjaxLoginShouldForwardToSecurePassword() {
$this->postDispatch('/opac/auth/ajax-login', ['username' => 'name@server.tld',
'password' => '1987']);
......
......@@ -104,7 +104,7 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
public function setUp() {
parent::setUp();
$this->postDispatch('/opac/auth/login', ['username' => 'foo', 'password' => 'bar']);
$this->postDispatch('/opac/auth/login', ['username' => 'foo', 'password' => 'bar' , 'inspector_gadget' => 'keep']);
}
......@@ -124,13 +124,21 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
->whenCalled('open_url')
->with('http://mon-koha-de-test.org?service=GetPatronInfo&patron_id=96138&show_contact=0&show_loans=1&show_holds=0')
->answers(KohaFixtures::xmlGetPatronInfoDupont())
->whenCalled('getLastResponse')
->answers(
(new Class_Entity())->setStatus('ok')->setBody(KohaFixtures::xmlAuthenticatePatronOk()))
->whenCalled('getLastRequest')
->answers('true')
->beStrict();
Class_HttpClientFactory::setInstance($this->mock()->whenCalled('getLastHttpClient')->answers($this->_mock_web_client));
$this->_service = Class_WebService_SIGB_Koha::getService($this->_params);
$this->_service->setWebClient($this->_mock_web_client);
}
public function tearDown() {
Class_HttpClientFactory::resetInstance();
parent::tearDown();
}
/** @test */
public function userFooShouldBeLogged() {
......@@ -142,6 +150,14 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
public function userFooPasswordShouldHaveNotBeenSet() {
$this->assertEquals('', Class_Users::getIdentity()->getPassword());
}
/** @test */
public function withActionLoginWithInspectorGadgetShouldKeepWebserviceCalls() {
$this->assertRedirectTo('/index/index/inspector_gadget/keep');
$this->assertNotNull(Zend_Registry::get('session')->inspectorCalls);
}
}
......
......@@ -234,21 +234,48 @@ class AuthorPageViewAuthorWithoutRecordTest extends AuthorPageTestCase {
class AuthorPageViewByIdTest extends AuthorPageTestCase {
class AuthorPageViewByIdWithInspectorGadgetTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/author/view/id/2408/inspector_gadget/1');
}
/** @test */
public function biographyTextLesMiserablesShouldBeReplacedByLinkToRecord() {
$this->assertXPathContentContains('//div[@class="biography"]//a[contains(@href, "/recherche/viewnotice/code_rebond/A2408/inspector_gadget/1/id/9")][@title="Accéder au document: Les Misérables"]',
'Les Misérables',$this->_response->getBody());
}
/** @test */
public function pageShouldContainsInspectorGadgetButton() {
$this->assertXPathContentContains('//button[contains(@class,"admin-button")]', 'Auteur Bokeh');
}
/** @test */
public function pageShouldLinkGavrocheWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/inspector_gadget/1/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->_response->getBody());
}
/** @test */
public function pageShouldLinkLesMiserablesWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/inspector_gadget/1/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
}
}
class AuthorPageViewByIdTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/author/view/id/2408');
}
/** @test */
public function authorWikdataIdShouldBeQ8298() {
$this->assertEquals('Q8298', Class_CodifAuteur::find(2408)->getWikidataId());
......@@ -294,7 +321,7 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase {
/** @test */
public function biographyTextLesMiserablesShouldBeReplacedByLinkToRecord() {
$this->assertXPathContentContains('//div[@class="biography"]//a[contains(@href, "/recherche/viewnotice/code_rebond/A2408/id/9")][@title="Accéder au document: Les Misérables"]',
'Les Misérables');
'Les Misérables',$this->_response->getBody());
}
......@@ -411,14 +438,14 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase {
/** @test */
public function pageShouldLinkGavrocheWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/inspector_gadget/1/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->_response->getBody());
}
/** @test */
public function pageShouldLinkLesMiserablesWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/inspector_gadget/1/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
}
......
Markdown is supported
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