diff --git a/.htaccess b/.htaccess index 148c10e18cd7cdda41514165e28a7de010fb2be4..5ef08035a27d23c3f3afac19b486163c83ca9c32 100644 --- a/.htaccess +++ b/.htaccess @@ -3,7 +3,7 @@ RewriteEngine on RewriteCond %{REQUEST_URI} !^/(google[a-z0-9]+\.html|.*/xhprof_html|ckeditor|exploit|\.well-known) RewriteCond %{REQUEST_FILENAME} !^.*/robots\.txt$ [NC] -RewriteRule !(userfiles|public|tmp|temp|skins|library/templates|library/digital_resources/.*/js)/.*\.(js|ico|txt|gif|jpg|jpeg|png|css|xml|swf|mov|pdf|doc|docx|woff|woff2|eot|svg|ttf|xls|wsdl|mp3|m4v|ogg|ogv|epub|htm|html|xhtml|asmx|zip|sql|bro|flv|mp4|webm|tgz|json|geojson|xsl)$ index.php [NC,NE] +RewriteRule !(userfiles|public|tmp|temp|skins|library/templates|library/digital_resources/.*/js)/.*\.(js|ico|txt|gif|jpg|jpeg|png|css|xml|swf|mov|pdf|doc|docx|woff|woff2|eot|svg|ttf|xls|xlsx|wsdl|mp3|m4v|ogg|ogv|epub|htm|html|xhtml|asmx|zip|sql|bro|flv|mp4|webm|tgz|json|geojson|xsl)$ index.php [NC,NE] AddType application/x-javascript .js AddType text/css .css diff --git a/VERSIONS b/VERSIONS index 2a29b9de9888b60b7f067358531cbfd73987263b..cb42a69f748ae1d0ee9e03b17d1e33032d7eda75 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,16 @@ +08/01/2019 - v7.12.52 + + - ticket #81938 : correction de la sauvegarde du paramétrage des boîtes qui pouvait échouer dans certaines conditions + + - ticket #82346 : Configuration : autorisation de téléversement des fichiers .xslx dans la liste des fichiers autorisés + + - ticket #83536 : Boite Avis : ajout du contexte de retour manquant dans les liens vers les notices + + - ticket #83674 : SIGB Opsys : suppression de l'identification par le numéro de carte abonné lorsqu'il était différent de l'identifiant + + - ticket #84068 : SIGB Orphee: correction du fonctionnement lorque le webservice n'utilise pas de mots de passe + + 20/12/2018 - v7.12.51 - ticket #83526 : Cosmogramme : SIGB Nanook : Amélioriation de la mise à jour de l'étalon lors de la modification des libellés de sections, genres et emplacements diff --git a/application/modules/admin/controllers/WidgetController.php b/application/modules/admin/controllers/WidgetController.php index 0a9c04a448831efa0389abae51eaed4bfbe5fb29..80b10fd72d86901fbb2d4870509e245644f2f34d 100644 --- a/application/modules/admin/controllers/WidgetController.php +++ b/application/modules/admin/controllers/WidgetController.php @@ -301,6 +301,4 @@ class Admin_WidgetController extends ZendAfi_Controller_Action { public function formProvider($widget) { return call_user_func_array([$widget->getForm(), 'newWith'], [$widget->forForm()]); } - - } \ No newline at end of file diff --git a/application/modules/opac/controllers/BlogController.php b/application/modules/opac/controllers/BlogController.php index 704ad7e8eaa2f3ebbe5aeb5268d5c6c43d51c159..30f701613640f4b4d1bb6e260b1eeee149a2c8dd 100644 --- a/application/modules/opac/controllers/BlogController.php +++ b/application/modules/opac/controllers/BlogController.php @@ -102,7 +102,7 @@ class BlogController extends ZendAfi_Controller_Action { public function viewcritiquesAction() { $this->view->page = $this->_getParam('page', 1); - $id_module = (int)$this->_getParam('id_module'); + $this->view->id_module = $id_module = (int)$this->_getParam('id_module'); $profil = Class_Profil::getCurrentProfil(); $preferences = $profil->getModuleAccueilPreferences($id_module, 'CRITIQUES'); diff --git a/application/modules/opac/views/scripts/blog/viewcritiques.phtml b/application/modules/opac/views/scripts/blog/viewcritiques.phtml index f2427b4a9531ea0b30d8adf893c9bcd704b961d4..c692cee123a581df6776094ca6cc61d9e3ea18f8 100644 --- a/application/modules/opac/views/scripts/blog/viewcritiques.phtml +++ b/application/modules/opac/views/scripts/blog/viewcritiques.phtml @@ -1,15 +1,25 @@ openBoite($this->title); -if(is_array($this->liste_avis)) -{ + +if (is_array($this->liste_avis)) { + $helper = $this->getHelper('Avis'); + if ($this->id_module) + $helper->addUrlContext(['retour_avis' => $this->id_module]); + $html_avis = []; foreach($this->liste_avis as $avis) - $html_avis []= $this->avis($avis); + $html_avis []= $helper->avis($avis); + echo implode('
', $html_avis); } -echo BR.'
'.$this->pager($this->total,$this->config['nb_display'],$this->page,$this->params_url ).'
'; +echo BR . $this->tag('div', + $this->pager($this->total, + $this->config['nb_display'], + $this->page, + $this->params_url), + ['align' => 'center', + 'style' => 'width:100%s']); $this->closeBoite(); -?> diff --git a/library/Class/Systeme/ModulesAccueil/ConteneurDeuxColonnes.php b/library/Class/Systeme/ModulesAccueil/ConteneurDeuxColonnes.php index a52e8129bc35fcf93e66e4b8199a24386e510707..206b9ea4df6da90c64aa0d4a77a314dd454ef277 100644 --- a/library/Class/Systeme/ModulesAccueil/ConteneurDeuxColonnes.php +++ b/library/Class/Systeme/ModulesAccueil/ConteneurDeuxColonnes.php @@ -42,7 +42,7 @@ class Class_Systeme_ModulesAccueil_ConteneurDeuxColonnes extends Class_Systeme_M public function updateHook($datas) { foreach(['gauche', 'droite'] as $column) { $key = 'col_' . $column .'_module_id'; - $datas [$key] = $datas['preferences'][$key] = static::createModuleForCol($column, $datas, $datas['id_module'], $datas['profile_id']); + $datas [$key] = $datas['preferences'][$key] = static::createModuleForCol($column, $datas['preferences'], $datas['id_module'], $datas['profile_id']); } return $datas; diff --git a/library/Class/Systeme/ModulesAccueil/Library.php b/library/Class/Systeme/ModulesAccueil/Library.php index 7837bc98d32534be125fdb46edaebf3ddfaff4a9..3e21bc8a629ed9b9d22375842dfe37ea6a407638 100644 --- a/library/Class/Systeme/ModulesAccueil/Library.php +++ b/library/Class/Systeme/ModulesAccueil/Library.php @@ -145,9 +145,9 @@ class Class_Systeme_ModulesAccueil_Library extends Class_Systeme_ModulesAccueil_ public function updateHook($datas) { - if(array_key_exists('default_filters', $datas) - && (!is_array($datas['default_filters']))) - $datas['default_filters'] = []; + if (array_key_exists('default_filters', $datas['preferences']) + && (!is_array($datas['preferences']['default_filters']))) + $datas['preferences']['default_filters'] = []; return $datas; } diff --git a/library/Class/Systeme/ModulesAccueil/MenuVertical.php b/library/Class/Systeme/ModulesAccueil/MenuVertical.php index 28ea39b9f5edcc309dd1d79060a422c283bbcdd2..4b1b0b8e7bfda1531ad8cf972b4eeb84203c503c 100644 --- a/library/Class/Systeme/ModulesAccueil/MenuVertical.php +++ b/library/Class/Systeme/ModulesAccueil/MenuVertical.php @@ -61,13 +61,13 @@ class Class_Systeme_ModulesAccueil_MenuVertical extends Class_Systeme_ModulesAcc public function updateHook($datas) { - if(!isset($datas['menu'])) + if(!isset($datas['preferences']['menu'])) return $datas; - if(static::NEW_MENU != $datas['menu']) + if(static::NEW_MENU != $datas['preferences']['menu']) return $datas; - $datas['menu'] = $this->_prefixMenu($this->addMenu()); + $datas['preferences']['menu'] = $this->_prefixMenu($this->addMenu()); return $datas; } diff --git a/library/Class/Systeme/ModulesAccueil/Sitotheque.php b/library/Class/Systeme/ModulesAccueil/Sitotheque.php index 3f41408f033249788b7753ac6e5cafd98f9dafbb..b5d39244ed0f5953842a72579431118b7f35efd6 100644 --- a/library/Class/Systeme/ModulesAccueil/Sitotheque.php +++ b/library/Class/Systeme/ModulesAccueil/Sitotheque.php @@ -52,11 +52,11 @@ class Class_Systeme_ModulesAccueil_Sitotheque extends Class_Systeme_ModulesAccue public function updateHook($datas) { - if(static::DISPLAY_HIERARCHY != $datas['type_aff']) + if(static::DISPLAY_HIERARCHY != $datas['preferences']['type_aff']) return $datas; - if ($categories = explode('-', $datas['id_categorie'])) - $datas['preferences']['id_categorie'] = $datas['id_categorie'] = $categories[0]; + if ($categories = explode('-', $datas['preferences']['id_categorie'])) + $datas['preferences']['id_categorie'] = $categories[0]; return $datas; } diff --git a/library/Class/Systeme/ModulesAccueil/Tags.php b/library/Class/Systeme/ModulesAccueil/Tags.php index 930af4938f96ce7dcba498dbb862cf8b3ba50a7c..f9938870661acaa2f2d5196c9a7ccd0a223691a8 100644 --- a/library/Class/Systeme/ModulesAccueil/Tags.php +++ b/library/Class/Systeme/ModulesAccueil/Tags.php @@ -41,4 +41,13 @@ class Class_Systeme_ModulesAccueil_Tags extends Class_Systeme_ModulesAccueil_Nul 'id_panier' => 0, 'id_catalogue' => 0]; } + + + public function updateHook($datas) { + if (isset($datas['preferences']['type_tags_codes'])) { + $datas['preferences']['type_tags'] = str_replace(';', '', $datas['preferences']['type_tags_codes']); + unset($datas['preferences']['type_tags_codes']); + } + return $datas; + } } \ No newline at end of file diff --git a/library/Class/Systeme/Widget/Abstract.php b/library/Class/Systeme/Widget/Abstract.php index 61f19d4081d3ab7ee39eafa6457b7177474330c3..676850e689d3a66565ca99ae1c0e7c2ee1c06bcc 100644 --- a/library/Class/Systeme/Widget/Abstract.php +++ b/library/Class/Systeme/Widget/Abstract.php @@ -89,10 +89,10 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity { protected function _getValues($attributes) { return $this->_getWidgetResources() - ->getValues(array_merge(isset($attributes['preferences']) + ->getValues(array_merge($attributes, + isset($attributes['preferences']) ? $attributes['preferences'] - : [], - $attributes)); + : [])); } diff --git a/library/Class/Systeme/Widget/Widget.php b/library/Class/Systeme/Widget/Widget.php index 6a9fafd25d0367d27994dfefc9359fa30d18b6a5..7b8e5861773edfaeb6469d159c4f669ca4969a31 100644 --- a/library/Class/Systeme/Widget/Widget.php +++ b/library/Class/Systeme/Widget/Widget.php @@ -36,16 +36,34 @@ class Class_Systeme_Widget_Widget extends Class_Systeme_Widget_Abstract { } + protected function _cleanRootAndPreferences($datas) { + $root_properties = ['type_module' => '', + 'division' => '', + 'id_module' => '', + 'preferences' => '', + 'parent_id' => '', + 'type_menu' => '', + 'libelle' => '', + 'picto' => '', + 'sous_menus' => []]; + + + $cleaned_datas = array_intersect_key($datas, $root_properties); + $cleaned_datas['preferences'] = array_diff_key($datas, + $root_properties); + return $cleaned_datas; + } + + protected function _update() { - $datas = array_merge($this->getLocalSettings(), - $this->getNewDatas()); + $cleaned_datas = $this->_cleanRootAndPreferences( + array_merge($this->getLocalSettings(), + $this->getNewDatas())); + - if(isset($datas['preferences'])) - unset($datas['preferences']); + $cleaned_datas['profile_id'] = $this->getProfileId(); + $datas = $this->_getWidgetResources()->updateHook($cleaned_datas); - $datas['preferences'] = $datas; - $datas['profile_id'] = $this->getProfileId(); - $datas = $this->_getWidgetResources()->updateHook($datas); $sub_menus = null; if(isset($datas['children'])) $sub_menus = $this->_convertChildren($datas['children']); diff --git a/library/Class/WebService/SIGB/AbstractRESTService.php b/library/Class/WebService/SIGB/AbstractRESTService.php index 3b681672b16c600d9c59f928b25140133e36db36..5cd7289ac0035152d4a90fc3967d639191320280 100644 --- a/library/Class/WebService/SIGB/AbstractRESTService.php +++ b/library/Class/WebService/SIGB/AbstractRESTService.php @@ -188,7 +188,6 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic public function ilsdiGetPatronInfo($params, $reader, $error_tag='error') { $emprunteur = Class_WebService_SIGB_Emprunteur::newInstance()->setService($this); $params = array_merge(array('service' => 'GetPatronInfo'), $params); - $xml = $this->httpGet($params); if (0 === strpos($xml, '')) diff --git a/library/Class/WebService/SIGB/Opsys/Service.php b/library/Class/WebService/SIGB/Opsys/Service.php index 9ec9f6b092f3330901b718c4c2fd5ce4239cfecd..29eb6cdecb33592176edb5696ee59b5b125134d9 100644 --- a/library/Class/WebService/SIGB/Opsys/Service.php +++ b/library/Class/WebService/SIGB/Opsys/Service.php @@ -231,9 +231,8 @@ class Class_WebService_SIGB_Opsys_Service extends Class_WebService_SIGB_Abstract * @return Class_WebService_SIGB_Emprunteur */ public function authentifierEmprunteur($user) { - $auth = new EmprAuthentifier($this->guid, - $user->hasIdabon() ? $user->getIdabon() : $user->getLogin(), - $user->getPassword()); + $auth = new EmprAuthentifier($this->guid, $user->getLogin(), $user->getPassword()); + try { $auth_result = $this->search_client->EmprAuthentifier($auth); } catch (Exception $e) { @@ -254,7 +253,6 @@ class Class_WebService_SIGB_Opsys_Service extends Class_WebService_SIGB_Abstract $emprunteur->setEndDate($date_fin_abonnement); } - if ($date_naissance = $entite_result->findAttribute('DateNaissance')) { $date_naissance = implode('-', array_reverse(explode('/', $date_naissance))); $emprunteur->setDateNaissance($date_naissance); diff --git a/library/Class/WebService/SIGB/Orphee/Service.php b/library/Class/WebService/SIGB/Orphee/Service.php index 7f8dc166c1ca65efd15952a8f750b5dabe1c1e51..59a2fc9ff15add2353f6be50e779e60591ccb4f1 100644 --- a/library/Class/WebService/SIGB/Orphee/Service.php +++ b/library/Class/WebService/SIGB/Orphee/Service.php @@ -163,7 +163,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac protected function hasGetAdh() { - return $this->_search_client->hasFunction('GetAdh'); + return $this->_search_client && $this->_search_client->hasFunction('GetAdh'); } diff --git a/library/ZendAfi/Auth.php b/library/ZendAfi/Auth.php index e139e270595b09471ca9447c19acf61dc5c4c7fb..1d76b019015023c4d6a028699183f3c43ec1d00e 100644 --- a/library/ZendAfi/Auth.php +++ b/library/ZendAfi/Auth.php @@ -55,14 +55,9 @@ class ZendAfi_Auth extends Zend_Auth { public function newAuthDb() { - if ($this->_auth_db_adapter) - return $this->_auth_db_adapter; - - $authAdapter = new ZendAfi_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter()); - $authAdapter->setTableName('bib_admin_users'); - $authAdapter->setIdentityColumn('LOGIN'); - $authAdapter->setCredentialColumn('PASSWORD'); - return $this->_auth_db_adapter = $authAdapter; + return $this->_auth_db_adapter + ? $this->_auth_db_adapter + : $this->_auth_db_adapter = new ZendAfi_Auth_Adapter_DbTable(); } diff --git a/library/ZendAfi/Auth/Adapter/Abstract.php b/library/ZendAfi/Auth/Adapter/Abstract.php new file mode 100644 index 0000000000000000000000000000000000000000..0f3b16eaf6cffc21ee6fe7210b2b257c0ca4d0c4 --- /dev/null +++ b/library/ZendAfi/Auth/Adapter/Abstract.php @@ -0,0 +1,60 @@ +_identity = $identity; + return $this; + } + + + /** + * @param string $credential + * @return Zend_Auth_Adapter_Abstract + */ + public function setCredential($credential) { + $this->_credential = $credential; + return $this; + } + + + /** + * @return Std_Class + */ + public function getResultObject() { + return $this->_authenticated_user->toStdClass(); + } +} diff --git a/library/ZendAfi/Auth/Adapter/CommSigb.php b/library/ZendAfi/Auth/Adapter/CommSigb.php index 7e5287aa02a7307598e946a24c85180455eb363e..246b99cd9f64c0334136cd7686fdfcfd27f3bc71 100644 --- a/library/ZendAfi/Auth/Adapter/CommSigb.php +++ b/library/ZendAfi/Auth/Adapter/CommSigb.php @@ -19,34 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface { +class ZendAfi_Auth_Adapter_CommSigb extends ZendAfi_Auth_Adapter_Abstract { protected - $_identity = null, - $_credential = null, - $_authenticated_user = null, $_called_services = []; - - /** - * @param string $identity - * @return Zend_Auth_Adapter_CommSigb - */ - public function setIdentity($identity) { - $this->_identity = $identity; - return $this; - } - - - /** - * @param string $credential - * @return Zend_Auth_Adapter_CommSigb - */ - public function setCredential($credential) { - $this->_credential = $credential; - return $this; - } - - /** * @return Zend_Auth_Result */ @@ -145,6 +121,9 @@ class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface { protected function _getUserFromSigbWithLibrary($user, $library) { $this->_called_services[] = $service = $library->getSIGBComm(); + if (!$service->providesAuthentication()) + return; + if (!$loaner = $service->getEmprunteur($user)) return; @@ -206,12 +185,4 @@ class ZendAfi_Auth_Adapter_CommSigb implements Zend_Auth_Adapter_Interface { $this->_authenticated_user = $user; return $result; } - - - /** - * @return Std_Class - */ - public function getResultObject() { - return $this->_authenticated_user->toStdClass(); - } } diff --git a/library/ZendAfi/Auth/Adapter/DbTable.php b/library/ZendAfi/Auth/Adapter/DbTable.php index 4c0c9395ae33d77deedd30ed6a1f2c64a441cc8b..f46c611f23411861975ff65a6be822066258dac0 100644 --- a/library/ZendAfi/Auth/Adapter/DbTable.php +++ b/library/ZendAfi/Auth/Adapter/DbTable.php @@ -20,43 +20,24 @@ */ -class ZendAfi_Auth_Adapter_DbTable extends Zend_Auth_Adapter_DbTable { - public function shouldBreakChain() { - return false; - } - +class ZendAfi_Auth_Adapter_DbTable extends ZendAfi_Auth_Adapter_Abstract { - /** - * _authenticateCreateSelect() - This method creates a Zend_Db_Select object that - * is completely configured to be queried against the database. - * - * @return Zend_Db_Select - */ - protected function _authenticateCreateSelect() { - if (empty($this->_credentialTreatment) - || (strpos($this->_credentialTreatment, "?") === false)) - $this->_credentialTreatment = '?'; + /** @return Zend_Auth_Result */ + public function authenticate() { + $type = ($this->_authenticated_user = Class_Users::findFirstBy(['login' => $this->_identity, + 'password' => $this->_credential, + 'password not' => ''])) + ? Zend_Auth_Result::SUCCESS + : Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND; - $credentialExpression = new Zend_Db_Expr( - '(CASE WHEN ' . - $this->_zendDb->quoteInto( - $this->_zendDb->quoteIdentifier($this->_credentialColumn, true) - . ' = ' . $this->_credentialTreatment, $this->_credential - ) - . ' THEN 1 ELSE 0 END) AS ' - . $this->_zendDb->quoteIdentifier('zend_auth_credential_match') - ); - - return $this->_zendDb - ->select() - ->from($this->_tableName, array('*', $credentialExpression)) - ->where($this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?', $this->_identity) - ->where($this->_zendDb->quoteIdentifier($this->_credentialColumn, true) . ' = ?', $this->_credential) - ->where($this->_zendDb->quoteIdentifier($this->_credentialColumn, true) . ' <> ?', ''); + return new Zend_Auth_Result($type, $this->_identity); } public function getResultObject() { - return $this->getResultRowObject(null,'password'); + $object = parent::getResultObject(); + unset($object->password); + + return $object; } } diff --git a/library/startup.php b/library/startup.php index b448721d92106757756a6f85d719f6afc130ce68..a97309c8bfd9ddbcd4966d4880d14967f0d4cc61 100644 --- a/library/startup.php +++ b/library/startup.php @@ -81,7 +81,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.12'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.51'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.52'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/application/modules/admin/controllers/ModoControllerTest.php b/tests/application/modules/admin/controllers/ModoControllerTest.php index 99ea0719571d9e5dbf5491478b9092998dbbe2ab..66aac78b3b91ab7a12bf6b95e646b55ec184bff6 100644 --- a/tests/application/modules/admin/controllers/ModoControllerTest.php +++ b/tests/application/modules/admin/controllers/ModoControllerTest.php @@ -1061,7 +1061,7 @@ class ModoControllerDeleteExpiredRegistrationsTest extends Admin_AbstractControl ['id' => 1, 'login' => 'pwd', 'password' => 'pwd', - 'date' => '2018-16-01', + 'date' => '2048-12-01', 'mail' => 'pwd@afi-sa.fr']); $this->fixture('Class_UsersNonValid', diff --git a/tests/application/modules/admin/controllers/WidgetControllerTest.php b/tests/application/modules/admin/controllers/WidgetControllerTest.php index 5452e33a311418df119771ab3dad01ccb90fd959..7dd268c2008a76ccf81c0d9c3d60f35a5113fdf9 100644 --- a/tests/application/modules/admin/controllers/WidgetControllerTest.php +++ b/tests/application/modules/admin/controllers/WidgetControllerTest.php @@ -233,13 +233,13 @@ class WidgetControllerKioquePostTest extends WidgetControllerPostDispatchWidgetC /** @test */ public function titleShouldBeTitreDuKiosque() { - $this->assertEquals('titre du /kiosque', $this->_saved_settings['titre']); + $this->assertEquals('titre du /kiosque', $this->_saved_settings['preferences']['titre']); } /** @test */ public function profilRedirectShouldBeTwelve() { - $this->assertEquals('12', $this->_saved_settings['profil_redirect']); + $this->assertEquals('12', $this->_saved_settings['preferences']['profil_redirect']); } } @@ -759,21 +759,6 @@ class WidgetControllerVerticalNavDispatchWithMenuFromOtherTest extends WidgetCon -class WidgetControllerTagsDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase { - public function setUp() { - $this->_type_module = 'TAGS'; - parent::setUp(); - } - - - /** @test */ - public function tagSelectionChampsShouldBePresent() { - $this->assertXPathContentContains('//h2', 'Facettes disponibles'); - } -} - - - class WidgetControllerLoginDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase { public function setUp() { @@ -959,6 +944,85 @@ class WidgetControllerActivitiesPostDispatchTest extends WidgetControllerPostDis +class WidgetControllerTagsDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase { + public function _stormHook() { + $tags = ['modules' => ['6' => ['division' => 3, + 'id_module' => '6', + 'type_module' => 'TAGS', + 'type_tags' => 'AMDPZ', + 'nombre' => 40, + 'preferences' => ['type_tags' => 'AM', + 'titre' => 'Des tags', + 'nombre' => 10]]]]; + $this + ->_profil + ->setCfgAccueil($tags) + ->assertSave(); + } + + + /** @test */ + public function tagSelectionChampsShouldBePresent() { + $this->assertXPathContentContains('//h2', 'Facettes disponibles'); + } + + + /** @test */ + public function inputTitreShouldContainsDesTags() { + $this->assertXPath('//input[@name="titre"][@value="Des tags"]'); + } + + + /** @test */ + public function inputTypeTagsCodesShouldContainsAandM() { + $this->assertXPath('//input[@name="type_tags_codes"][@value="A;M"]'); + } + + + /** @test */ + public function inputNombreShouldHaveValueTen() { + $this->assertXPath('//input[@name="nombre"][@value="10"]'); + } +} + + + + +class WidgetControllerTagsPostDispatchTest extends WidgetControllerPostDispatchWidgetConfigurationTestCase { + public function setUp() { + $this->_type_module = 'TAGS'; + $this->_params = ['type_tags_codes' => 'A;M;S']; + parent::setUp(); + } + + + /** @test */ + public function typeTagsAMSShouldHaveBeenSaved() { + $this->assertEquals('AMS', $this->_saved_settings['preferences']['type_tags']); + } + + + /** @test */ + public function typeTagsCodesAMSShouldHaveBeenRemovedFromPreferences() { + $this->assertFalse(isset($this->_saved_settings['preferences']['type_tags_codes'])); + } + + + /** @test */ + public function typeTagsCodesAMSShouldHaveBeenRemovedFromParams() { + $this->assertFalse(isset($this->_saved_settings['type_tags'])); + } + + + /** @test */ + public function preferencesShouldNotContainsDivision() { + $this->assertFalse(isset($this->_saved_settings['preferences']['division'])); + } +} + + + + abstract class WidgetControllerTwoWidgetsTestCase extends WidgetControllerWidgetConfigurationTestCase { public function setUp() { @@ -1552,13 +1616,13 @@ class WidgetControllerLoginPostDispatchTest extends WidgetControllerPostDispatch /** @test */ public function profilRedirectShouldBe678() { - $this->assertEquals(678, $this->_saved_settings['profil_redirect']); + $this->assertEquals(678, $this->_saved_settings['preferences']['profil_redirect']); } /** @test */ public function profilLogoutRedirectShouldBe345() { - $this->assertEquals(345, $this->_saved_settings['profil_logout_redirect']); + $this->assertEquals(345, $this->_saved_settings['preferences']['profil_logout_redirect']); } @@ -1881,23 +1945,18 @@ class WidgetControllerDomainBrowserPostDispatchTest extends WidgetControllerPost /** @test */ public function paramsShouldHaveBeenSaved() { - $this->assertEquals(array_merge($this->_params, - ['boite' => '', - 'division' => '3', - 'id_module' => '6', - 'type_module' => 'DOMAIN_BROWSER', - 'preferences' => ['titre' => 'Mes Domaines', - 'allow_breadcrumb' => '0', - 'root_domain_id' => '10', - 'display_mode' => '4', - 'boite' => '', - 'division' => '3', - 'id_module' => '6', - 'type_module' => 'DOMAIN_BROWSER', - 'profile_id' => '5', - 'tri' => 'annee desc'], - 'profile_id' => '5', - 'tri' => 'annee desc']), + $this->assertEquals(['division' => '3', + 'id_module' => '6', + 'type_module' => 'DOMAIN_BROWSER', + 'preferences' => ['titre' => 'Mes Domaines', + 'allow_breadcrumb' => '0', + 'root_domain_id' => '10', + 'display_mode' => '4', + 'profile_id' => '5', + 'tri' => 'annee desc', + 'boite' => '', + ], + 'profile_id' => '5'], $this->_saved_settings); } } @@ -2318,7 +2377,7 @@ class WidgetControllerWidgetAddWidgetFromTemplateTest extends WidgetControllerWi /** @test */ public function opTimeoutShouldBeSix() { $this->assertEquals(6, - $this->_module_config['op_timeout']); + $this->_module_config['preferences']['op_timeout']); } } diff --git a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php index a1aff68f6802c40724124fb80e93f99858de157f..44fe54f783d61da5f369849971f8d7aaa0b92526 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php @@ -661,14 +661,12 @@ abstract class ModuleSelectionCritiquesTestCase extends AvisControllersFixturesT $preferences = ['modules' => [3 => ['division' => 2, 'type_module' => 'CRITIQUES', - 'preferences' => ['titre' => 'Coups de coeur' - ] - ]]]; + 'preferences' => ['titre' => 'Coups de coeur']]]]; + $profil = $this->fixture('Class_Profil', - ['id'=>2, + ['id' => 2, 'cfg_modules' => ['blog' => ['viewcritiques' => ['nb_display' => 2]]], 'cfg_accueil' => $preferences]); - } } @@ -700,34 +698,49 @@ class AbonneControllerAvisBlogControllerViewCritiquesDefaultTest extends ModuleS } + class AbonneControllerAvisBlogControllerViewCritiquesTest extends ModuleSelectionCritiquesTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/blog/viewcritiques/id_profil/2/id_module/3'); } - public function testMilleniumIsHere() { - $this->assertQueryContentContains('h2', 'Millenium',$this->_response->getBody()); + + /** @test */ + public function titleShouldBeCoupsDeCoeur() { + $this->assertXPathContentContains('//h1', 'Coups de coeur'); } - public function testPotterIsHere() { - $this->assertQueryContentContains('h2', 'Potter',$this->_response->getBody()); + + /** @test */ + public function milleniumShouldBeDisplayed() { + $this->assertXPathContentContains('//h2', 'Millenium'); } + /** @test */ - public function pagerShouldBeDisplayed() { - $this->assertXPath('//a[@href="/blog/viewcritiques/id_profil/2/id_module/3/page/2"]', $this->_response->getBody()); + public function milleniumRecordLinkShouldContainsReturnContext() { + $this->assertXPath('//a[contains(@href, "id/817")][contains(@href, "retour_avis/3")]', + $this->_response->getBody()); } + /** @test */ - public function pagerShouldNotContains3Pages() { - $this->assertNotXPath('//a[contains(@href,"/page/3")]', $this->_response->getBody()); + public function potterShouldBeDisplayed() { + $this->assertXPathContentContains('//h2', 'Potter'); } /** @test */ - public function titleShouldBeCoupsDeCoeur() { - $this->assertXPathContentContains('//h1', 'Coups de coeur'); + public function pagerShouldBeDisplayed() { + $this->assertXPath('//a[@href="/blog/viewcritiques/id_profil/2/id_module/3/page/2"]', + $this->_response->getBody()); + } + + + /** @test */ + public function pagerShouldNotContains3Pages() { + $this->assertNotXPath('//a[contains(@href,"/page/3")]', $this->_response->getBody()); } } diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 57ae9afff599c8baf456f1fb21c8ca1cb2776998..cf681457a8a5378df4ccbd9af01c4c2021720085 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -2496,6 +2496,9 @@ class AuthControllerPostWithSameIdSigbTest extends AbstractControllerTestCase { ->answers([]) ->whenCalled('isConnected') + ->answers(true) + + ->whenCalled('providesAuthentication') ->answers(true); $params = ['url_serveur' => 'http://mon-koha-de-test.org', @@ -2588,6 +2591,9 @@ class AuthControllerPostLoginWithDifferentIdIntBibTest ->answers($emprunteur) ->whenCalled('isConnected') + ->answers(true) + + ->whenCalled('providesAuthentication') ->answers(true); $params = ['url_serveur' => 'http://mon-koha-de-test.org', diff --git a/tests/application/modules/opac/controllers/AuthControllerWithoutPasswordTest.php b/tests/application/modules/opac/controllers/AuthControllerWithoutPasswordTest.php index 22ad1712f2bff501b5e10c8f965be2a4a6f6b7a4..9a6a8382b54da51154f51643a9047071e77ce449 100644 --- a/tests/application/modules/opac/controllers/AuthControllerWithoutPasswordTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerWithoutPasswordTest.php @@ -114,6 +114,9 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor ->answers($this->_emprunteur) ->whenCalled('isConnected') + ->answers(true) + + ->whenCalled('providesAuthentication') ->answers(true); } diff --git a/tests/library/Class/WebService/SIGB/BiblixNetTest.php b/tests/library/Class/WebService/SIGB/BiblixNetTest.php index 597f9c842995f00c4ab3d34d11bde0c72d9eb5c1..908fbda5dea3cad5175e09398df75ddcf09e657f 100644 --- a/tests/library/Class/WebService/SIGB/BiblixNetTest.php +++ b/tests/library/Class/WebService/SIGB/BiblixNetTest.php @@ -366,7 +366,7 @@ class BiblixAuthenticateTest extends ModelTestCase { $mock = $this ->mock() ->whenCalled('open_url') - ->with('http://www.annecy.fr/webservice/biblix.ilsdi?service=GetPatronInfo&showLoans=1&showHolds=1') + ->with('http://www.annecy.fr/webservice/biblix.ilsdi?service=GetPatronInfo&patronId=28&showLoans=1&showHolds=1') ->answers(BiblixNetFixtures::xmlGetPatronJustinTicou()) ->beStrict(); @@ -375,38 +375,57 @@ class BiblixAuthenticateTest extends ModelTestCase { $service->setWebClient($mock); - $this->fixture('Class_IntBib', - ['id' => 94, - 'comm_sigb' => Class_IntBib::COM_BIBLIXNET, - 'comm_params' => ['url_serveur' => 'http://www.annecy.fr/webservice/biblix.ilsdi']]); - $logger = $this - ->mock() - ->whenCalled('log') - ->answers(true) - - ->whenCalled('logError') - ->willDo(function($url, $message) { - throw new RuntimeException($url . ' :: ' . $message); - }); - - Class_WebService_SIGB_AbstractService::setLogger($logger); + $this->fixture('Class_Users', + ['id' => 12, + 'login' => '10102003', + 'password' => 'secret', + 'idabon' => '87364', + 'id_sigb' => 28, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 94, + 'comm_sigb' => Class_IntBib::COM_BIBLIXNET, + 'comm_params' => ['url_serveur' => 'http://www.annecy.fr/webservice/biblix.ilsdi']]), + 'bib' => $this->fixture('Class_Bib', + ['id' => 94, + 'id_site' => 94])]) + ->beAbonneSIGB() + ->assertSave(); - $errors = ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'secret'); + ZendAfi_Auth::getInstance()->clearIdentity(); } public function tearDown() { Class_WebService_SIGB_BiblixNet::reset(); - Class_WebService_SIGB_AbstractService::setLogger(null); parent::tearDown(); } /** @test */ - public function EvelyneShouldBeLogged() { + public function withRightCredentialsJustinShouldBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'secret'); + if (!$user = Class_Users::getIdentity()) return $this->fail(); + $this->assertEquals('10102003', $user->getLogin()); + return $user->getEmprunts(); + } + + + /** + * @depends withRightCredentialsJustinShouldBeLogged + * @test + */ + public function justinfShouldHaveTwoLoans($loans) { + $this->assertCount(2, $loans); + } + + + /** @test */ + public function withWrongCredentialsJustinShouldNotBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'oups'); + $this->assertEmpty(Class_Users::getIdentity()); } } \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php index 67a8d2e00b9ff9f83f24123f3214294dcf25a7e8..2c2d383a7d57306417b1b9e2b6c94353c22b2bb0 100644 --- a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php @@ -1688,13 +1688,13 @@ class OpsysServiceEmprAuthentifierParamsTest extends OpsysServiceWithSessionTest /** @test */ - public function withLoginAndIdAbonAuthentifierShouldUseIdabon() { + public function withLoginAndIdAbonAuthentifierShouldUseLoginAlso() { $this->opsys->getEmprunteur( Class_Users::newInstance(['login' => 'tintin', 'password' => '1234', 'idabon' => 'vol777'])); - $this->assertEquals('vol777', $this->auth_request->Param->IDEmprunteur); + $this->assertEquals('tintin', $this->auth_request->Param->IDEmprunteur); } } diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php index defadebe3d46013d3fc99d2aa6026bb9414e13f1..e9db8d1bb51285f0d2c796bf4422255bae0a72d4 100644 --- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php @@ -73,7 +73,6 @@ class OrpheeServiceGetServiceTest extends ModelTestCase { abstract class OrpheeServiceTestCase extends ModelTestCase { protected - $_storm_default_to_volatile = true, $_search_client, $_orphee, $_orphee_allow_hold_avail, @@ -93,16 +92,28 @@ abstract class OrpheeServiceTestCase extends ModelTestCase { ->answers(new EndSessionResponse()); $this->_beforeOrpheeServiceCreate(); - $this->_orphee = new Class_WebService_SIGB_Orphee_ServiceForTesting($this->_search_client); + $allow_hold_available_items=true; $this->_orphee_allow_hold_avail = Class_WebService_SIGB_Orphee_Service::getService('tests/fixtures/orphee.wsdl', null, $allow_hold_available_items); $this->_orphee_allow_hold_avail->setSearchClient($this->_search_client); $this->_orphee_allow_hold_avail->isConnected(); - $this->_henry_dupont = Class_Users::getLoader() - ->newInstanceWithId(2) - ->setLogin('10900000753') - ->setPassword('secret'); + $this->_orphee = new Class_WebService_SIGB_Orphee_ServiceForTesting($this->_search_client); + Class_WebService_SIGB_Orphee::setService($this->_orphee); + + $this->_henry_dupont = $this->fixture('Class_Users', + ['id' => 2, + 'login' => '10900000753', + 'idabon' => '100753', + 'password' => 'secret', + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 34, + 'comm_sigb' => Class_IntBib::COM_ORPHEE, + 'comm_params' => ['url_serveur' => 'tests/fixtures/orphee.wsdl', + 'allow_hold_available_items' => true]]), + 'bib' => $this->fixture('Class_Bib', + ['id' => 34])]); + $this->_henry_dupont->beAbonneSIGB()->assertSave(); } @@ -1545,3 +1556,73 @@ class OrpheeServiceChangePasswordWithoutClientTest extends ModelTestCase { parent::tearDown(); } } + + + + +class OrpheeAuthenticateLocallyTest extends OrpheeServiceTestCase { + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->clearIdentity(); + } + + + /** @test */ + public function withRightCredentialsHenryShouldBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10900000753', 'secret'); + $this->assertNotNull($user = Class_Users::getIdentity()); + $this->assertEquals('10900000753', $user->getLogin()); + } + + + /** @test */ + public function withWrongCredentialsJustinShouldNotBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10900000753', 'oups'); + $this->assertEmpty(Class_Users::getIdentity()); + } +} + + + + +class OrpheeAuthenticateThroughSigbTest extends OrpheeServiceTestCase { + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', 1); + + $this->_search_client + ->whenCalled('hasFunction')->with('GetAdh')->answers(true) + + ->whenCalled('GetAdh') + ->willDo( + function($param) { + $response = ($param->carte == '10900000753' && $param->pwd == 'secret') + ? OrpheeFixtures::xmlGetAdhHenryDupont() + : ''; + + return $this->mock() + ->whenCalled('getXml') + ->answers($response); + }) + + ->whenCalled('EndSession')->with(new EndSession())->answers(true); + + ZendAfi_Auth::getInstance()->clearIdentity(); + } + + + /** @test */ + public function withRightCredentialsHenryShouldBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10900000753', 'secret'); + $this->assertNotNull($user = Class_Users::getIdentity()); + $this->assertEquals('10900000753', $user->getLogin()); + } + + + /** @test */ + public function withWrongCredentialsJustinShouldNotBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10900000753', 'oups'); + $this->assertEmpty(Class_Users::getIdentity()); + } +} \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php b/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php index 384aa3183d9dea6579ae6bdc12c85922c4bad756..1157f310d64ecafd1e9360a251220a6b0d5fd621 100644 --- a/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php +++ b/tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php @@ -271,38 +271,58 @@ class VSmartAuthenticateTest extends ModelTestCase { $service->setWebClient($mock); - $this->fixture('Class_IntBib', - ['id' => 94, - 'comm_sigb' => Class_IntBib::COM_VSMART, - 'comm_params' => ['url_serveur' => 'http://www.moulins.fr/webservice/VubisSmartHttpApi.csp']]); - - $logger = $this - ->mock() - ->whenCalled('log') - ->answers(true) - - ->whenCalled('logError') - ->willDo(function($url, $message) { - throw new RuntimeException($url . ' :: ' . $message); - }); - - Class_WebService_SIGB_AbstractService::setLogger($logger); - - $errors = ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'secret'); + $this->fixture('Class_Users', + ['id' => 12, + 'login' => '10102003', + 'password' => 'secret', + 'idabon' => '87364', + 'id_sigb' => 28, + 'int_bib' => $this->fixture('Class_IntBib', + ['id' => 94, + 'comm_sigb' => Class_IntBib::COM_VSMART, + 'comm_params' => ['url_serveur' => 'http://www.moulins.fr/webservice/VubisSmartHttpApi.csp']]), + 'bib' => $this->fixture('Class_Bib', + ['id' => 94, + 'id_site' => 94])]) + ->beAbonneSIGB() + ->assertSave(); + + + ZendAfi_Auth::getInstance()->clearIdentity(); } public function tearDown() { Class_WebService_SIGB_VSmart::reset(); - Class_WebService_SIGB_AbstractService::setLogger(null); parent::tearDown(); } + /** @test */ - public function EvelyneShouldBeLogged() { + public function withRightCredentialsEvelyneShouldBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'secret'); + if (!$user = Class_Users::getIdentity()) return $this->fail(); + $this->assertEquals('10102003', $user->getLogin()); + return $user->getEmprunts(); + } + + + /** + * @depends withRightCredentialsEvelyneShouldBeLogged + * @test + */ + public function justinfShouldHaveThreeLoans($loans) { + $this->assertCount(3, $loans); + } + + + /** @test */ + public function withWrongCredentialsJustinShouldNotBeLogged() { + ZendAfi_Auth::getInstance()->authenticateLoginPassword('10102003', 'oups'); + $this->assertEmpty(Class_Users::getIdentity()); } } \ No newline at end of file diff --git a/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php b/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php index b13fb96221bb22941665a65f36ffc050f8705a41..2f53ffd10e425384a622753261830ca4d1c069d7 100644 --- a/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php +++ b/tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php @@ -108,9 +108,16 @@ abstract class AuthCommSigbWithWebServicesAndAbonneZorkTestCase extends AuthComm 'libelle' => 'Some patrons', 'type_fichier' => Class_IntProfilDonnees::FT_PATRONS]); - Class_WebService_SIGB_Nanook::setService($comm_params, $this->nanook = $this->mock()); - Class_WebService_SIGB_Orphee::setService($this->orphee = $this->mock()); - Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock()); + Class_WebService_SIGB_Nanook::setService($comm_params, + $this->nanook = $this->mock() + ->whenCalled('providesAuthentication') + ->answers(true)); + Class_WebService_SIGB_Orphee::setService($this->orphee = $this->mock() + ->whenCalled('providesAuthentication') + ->answers(false)); + Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock() + ->whenCalled('providesAuthentication') + ->answers(true)); $this->nanook ->whenCalled('getEmprunteur') @@ -518,7 +525,9 @@ class AuthCommSigbWithWebServicesAndAbonneZorkAndMinimalResponseTest 'libelle' => 'Some patrons', 'type_fichier' => Class_IntProfilDonnees::FT_PATRONS]); - Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock()); + Class_WebService_SIGB_Opsys::setService($this->opsys = $this->mock() + ->whenCalled('providesAuthentication') + ->answers(true)); $annecy_library = $this->fixture('Class_Bib', ['id' => 43, diff --git a/tests/scenarios/Widgets/WidgetsTest.php b/tests/scenarios/Widgets/WidgetsTest.php index 89e8cb11ad9fa2c8bca0a36dd15af02a072cf9e6..01b776a4ec7d4a12e23eb81cd9c506e038edd1f6 100644 --- a/tests/scenarios/Widgets/WidgetsTest.php +++ b/tests/scenarios/Widgets/WidgetsTest.php @@ -483,8 +483,8 @@ class WidgetsPostEditVerticalMenuTest extends WidgetsSimpleTestCase { /** @test */ - public function newMenuIdShouldHaveBeenSetInMenuVerticalSettongs() { - $this->assertEquals('2-0', Class_Profil::getCurrentProfil()->getCfgAccueilAsArray()['modules'][6]['menu']); + public function newMenuIdShouldHaveBeenSetInMenuVerticalSettings() { + $this->assertEquals('2-0', Class_Profil::getCurrentProfil()->getCfgAccueilAsArray()['modules'][6]['preferences']['menu']); }