diff --git a/VERSIONS_WIP/60583 b/VERSIONS_WIP/60583 new file mode 100644 index 0000000000000000000000000000000000000000..4a9a43ca29f2df8eed35310e4277271b53ce56c2 --- /dev/null +++ b/VERSIONS_WIP/60583 @@ -0,0 +1,2 @@ + - ticket #60583 : Migration des connecteurs SSO / CAS ArteVOD, MusicMe et Numilog vers le système d'authentification préalable. + \ No newline at end of file diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php index 1fe1e1f449d34dfbcef43a3d420b41fc9beb7919..7975c4d6e5eaeef3ba464fbba7139aefd8b51194 100644 --- a/application/modules/opac/controllers/ModulesController.php +++ b/application/modules/opac/controllers/ModulesController.php @@ -20,6 +20,7 @@ */ class ModulesController extends ZendAfi_Controller_Action { + public function preDispatch() { $mapping = ['vodeclic' => 'Vodeclic', 'toutapprendre' => 'ToutApprendre', @@ -28,7 +29,10 @@ class ModulesController extends ZendAfi_Controller_Action { 'planetnemo' => 'PlanetNemo', 'kidilangues' => 'Kidilangues', 'orthodidacte' => 'Orthodidacte', - 'cite-de-la-musique' => 'CiteDeLaMusique']; + 'cite-de-la-musique' => 'CiteDeLaMusique', + 'artevod' => 'ArteVOD', + 'musicme' => 'MusicMe', + 'numilog' => 'Numilog']; $action = $this->_request->getActionName(); @@ -52,27 +56,9 @@ class ModulesController extends ZendAfi_Controller_Action { } - public function artevodAction() { - $arte = new Class_Systeme_ModulesMenu_ArteVOD(); - return $this->checkNotifyMessage($arte, $arte->getDynamiqueUrl()); - } - - - public function musicmeAction() { - $musicme = new Class_Systeme_ModulesMenu_MusicMe(); - return $this->checkNotifyMessage($musicme, $musicme->getDynamiqueUrl()); - } - - - public function numilogAction() { - $numilog = new Class_Systeme_ModulesMenu_Numilog(); - $this->_redirect($numilog->getDynamiqueUrl()); - } - - public function numeriquepremiumAction() { $url = $this->_getParam('url'); - $this->checkNotifyMessage(NULL, $url); + $this->checkNotifyMessage((new Class_Entity)->setMessage($this->_('Le service est mal configuré. Il manque l\'URL du service.')), $url); } diff --git a/library/Class/KidilanguesLink.php b/library/Class/KidilanguesLink.php index 4b107e856cb5055907eb04d553e121cde5296913..5f7069082032a536d0f9eb2b92dfd4aa46eb0f1e 100644 --- a/library/Class/KidilanguesLink.php +++ b/library/Class/KidilanguesLink.php @@ -65,6 +65,9 @@ class Class_KidilanguesLink { public function kidilanguesEncrypt($data_to_encrypt) { + if(!$data_to_encrypt) + return ''; + $key = Class_AdminVar::get('KIDILANGUES_KEY'); return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data_to_encrypt, MCRYPT_MODE_CBC, md5($key)); } diff --git a/library/Class/Systeme/ModulesMenu/ArteVOD.php b/library/Class/Systeme/ModulesMenu/ArteVOD.php index 75d5c096744dab133ba2fa89dba64835108e1d1f..86086bfaf4ce595663042fcd5df367a437165aa6 100644 --- a/library/Class/Systeme/ModulesMenu/ArteVOD.php +++ b/library/Class/Systeme/ModulesMenu/ArteVOD.php @@ -30,30 +30,19 @@ class Class_Systeme_ModulesMenu_ArteVOD extends Class_Systeme_ModulesMenu_SSOAbs public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers ArteVod'); } - public function getArteVodUrlForUser($user) { - if ($user && $user->hasRightAccesArteVod()) { - $arte_link=Class_ArteVodLink::forUser($user); - $url=$arte_link->url(); - if (!strlen($url)>0) - $this->setMessage($arte_link->getMessage()); - return $url; - } - $this->setMessage($this->_('Votre abonnement ne permet pas d\'accéder aux ressources ArteVod. Merci de contacter la médiathèque')); - return ''; - } - + public function urlForUser($user) { + if (!$user->hasRightAccesArteVod()) + return ''; - public function getDynamiqueUrl($docid = null) { - $user = Class_Users::getIdentity(); - if (!$user) { - $arte_link=new Class_ArteVodLink(); - return $arte_link->baseUrl(); - } - $url=$this->getArteVodUrlForUser($user); + $arte_link = Class_ArteVodLink::forUser($user); + $url = $arte_link->url(); + if (!strlen($url) > 0) + $this->setMessage($arte_link->getMessage()); return $url; } diff --git a/library/Class/Systeme/ModulesMenu/CVS.php b/library/Class/Systeme/ModulesMenu/CVS.php index affb0c82e3f1fd7775d9526aaf21410262276c3c..d0e6445ec9d734d87d8746807b34cd29cf53f5a9 100644 --- a/library/Class/Systeme/ModulesMenu/CVS.php +++ b/library/Class/Systeme/ModulesMenu/CVS.php @@ -28,21 +28,21 @@ class Class_Systeme_ModulesMenu_CVS extends Class_Systeme_ModulesMenu_SSOAbstrac public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers CVS'); $this->_url = Class_CVSLink::staticLink(); } public function getCVSUrlForUser($user) { - if ((new Class_AdminVar_CVS())->isCVSAccessOrDemo($user)) { - $cvs_link = Class_CVSLink::forUser($user); - $url=$cvs_link->url(); - if (!strlen($url)>0) - $this->setMessage($cvs_link->getMessage()); - return $url; - } - $this->setMessage($this->_('Votre abonnement ne permet pas d\'accéder aux ressources CVS. Merci de contacter la médiathèque')); - return ''; + if (!(new Class_AdminVar_CVS())->isCVSAccessOrDemo($user)) + return ''; + + $cvs_link = Class_CVSLink::forUser($user); + $url = $cvs_link->url(); + if (!strlen($url)>0) + $this->setMessage($cvs_link->getMessage()); + return $url; } @@ -54,9 +54,8 @@ class Class_Systeme_ModulesMenu_CVS extends Class_Systeme_ModulesMenu_SSOAbstrac public function urlForUser($user) { $url = $this->getCVSUrlForUser($user); - if ($url && (strlen($this->_doc_id)>0)) { + if ($url && (strlen($this->_doc_id)>0)) $url.='#album&docid='.$this->_doc_id; - } return $url; } diff --git a/library/Class/Systeme/ModulesMenu/CiteDeLaMusique.php b/library/Class/Systeme/ModulesMenu/CiteDeLaMusique.php index e53cecc0160566d843c8d76436cec557eae830b7..63472a3fec956c2c682c0505f7d14de36cc36e27 100644 --- a/library/Class/Systeme/ModulesMenu/CiteDeLaMusique.php +++ b/library/Class/Systeme/ModulesMenu/CiteDeLaMusique.php @@ -29,6 +29,7 @@ class Class_Systeme_ModulesMenu_CiteDeLaMusique extends Class_Systeme_ModulesMen public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Cité de la Musique'); } @@ -42,10 +43,8 @@ class Class_Systeme_ModulesMenu_CiteDeLaMusique extends Class_Systeme_ModulesMen } - if (!$user->hasRightAccessCiteDeLaMusique()) { - $this->setMessage($this->_('Vous devez être connecté sous un compte avec abonnement valide pour pouvoir accéder à la ressource numérique')); + if (!$user->hasRightAccessCiteDeLaMusique()) return ''; - } return 'http://media.citedelamusique.fr/medias/logon/' . $cite_musique->getLibraryId(); } @@ -54,6 +53,4 @@ class Class_Systeme_ModulesMenu_CiteDeLaMusique extends Class_Systeme_ModulesMen public function isVisibleForProfil($profil) { return (new Class_AdminVar_CiteDeLaMusique())->isEnabled(); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu/Kidilangues.php b/library/Class/Systeme/ModulesMenu/Kidilangues.php index 819d04baa9c2a61263da15126a7b668e90c64b21..548adf00fd7b3b6f8fea2b46d1fa2c61cd3f382b 100644 --- a/library/Class/Systeme/ModulesMenu/Kidilangues.php +++ b/library/Class/Systeme/ModulesMenu/Kidilangues.php @@ -27,17 +27,17 @@ class Class_Systeme_ModulesMenu_Kidilangues extends Class_Systeme_ModulesMenu_SS public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Kidilangues'); $this->_url = Class_KidilanguesLink::staticUrl(); } public function urlForUser($user) { - if ($user && $user->hasRightAccesKidilangues() && Class_AdminVar::isKidilanguesEnabled()) { - return (new Class_KidilanguesLink())->url(); - } - $this->setMessage('Vous n\'avez pas accès à cette ressource.'); - return ''; + if (!$user->hasRightAccesKidilangues() || !Class_AdminVar::isKidilanguesEnabled()) + return ''; + + return (new Class_KidilanguesLink())->url(); } diff --git a/library/Class/Systeme/ModulesMenu/LeSocial.php b/library/Class/Systeme/ModulesMenu/LeSocial.php index 21256065b9057fc159f50c2167dcb4df261426e8..7c0519c2bb545488f2bcf95d5f753c9e9dae3097 100644 --- a/library/Class/Systeme/ModulesMenu/LeSocial.php +++ b/library/Class/Systeme/ModulesMenu/LeSocial.php @@ -26,6 +26,7 @@ class Class_Systeme_ModulesMenu_LeSocial extends Class_Systeme_ModulesMenu_SSOAb public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Le Social'); $this->_url = Class_LeSocialLink::staticUrl(); } @@ -34,7 +35,7 @@ class Class_Systeme_ModulesMenu_LeSocial extends Class_Systeme_ModulesMenu_SSOAb public function urlForUser($user) { if ($user && $user->hasRightAccessLeSocial() && Class_AdminVar::isLeSocialEnabled()) return ( Class_LeSocialLink::forUser($user)->url()); - $this->setMessage('Vous n\'avez pas accès à cette ressource.'); + return ''; } diff --git a/library/Class/Systeme/ModulesMenu/MusicMe.php b/library/Class/Systeme/ModulesMenu/MusicMe.php index f86b20d8b4bb1a9d1246805b2fc20f9b0ac27a54..46d8df9159e93d0f047126d74b2d7b4fd6dd95ce 100644 --- a/library/Class/Systeme/ModulesMenu/MusicMe.php +++ b/library/Class/Systeme/ModulesMenu/MusicMe.php @@ -29,30 +29,20 @@ class Class_Systeme_ModulesMenu_MusicMe extends Class_Systeme_ModulesMenu_SSOAbs public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers MusicMe'); } - public function getMusicMeUrlForUser($user) { - if ($user && $user->hasRightAccesMusicMe()) { - $musicme_link=Class_MusicMeLink::forUser($user); - $url=$musicme_link->url(); - if (!strlen($url)>0) - $this->setMessage($musicme_link->getMessage()); - return $url; - } - $this->setMessage($this->_('Votre abonnement ne permet pas d\'accéder aux ressources MusicMe. Merci de contacter la médiathèque')); - return ''; - } + public function urlForUser($user) { + if (!$user->hasRightAccesMusicMe()) + return ''; + $musicme_link=Class_MusicMeLink::forUser($user); + $url=$musicme_link->url(); + if (!strlen($url)>0) + $this->setMessage($musicme_link->getMessage()); - public function getDynamiqueUrl($docid=null) { - $user = Class_Users::getIdentity(); - if (!$user) { - $musicme_link=new Class_MusicMeLink(null); - return $musicme_link->baseUrl(); - } - $url=$this->getMusicMeUrlForUser($user); return $url; } diff --git a/library/Class/Systeme/ModulesMenu/MyCow.php b/library/Class/Systeme/ModulesMenu/MyCow.php index 8e05ad4ee2321d1e2b2d0212573f5bf546fead9a..6778ce9db58ba0efe2fd6832a3cbc38e53ce24b5 100644 --- a/library/Class/Systeme/ModulesMenu/MyCow.php +++ b/library/Class/Systeme/ModulesMenu/MyCow.php @@ -29,6 +29,7 @@ class Class_Systeme_ModulesMenu_MyCow extends Class_Systeme_ModulesMenu_SSOAbstr public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers MyCOW.EU'); } @@ -37,7 +38,6 @@ class Class_Systeme_ModulesMenu_MyCow extends Class_Systeme_ModulesMenu_SSOAbstr if ($user && $user->hasRightAccessMyCow() && Class_AdminVar::isMyCowEnabled()) return Class_MyCowLink::forUser($user)->url(); - $this->setMessage('Vous n\'avez pas accès à cette ressource.'); return ''; } diff --git a/library/Class/Systeme/ModulesMenu/Numilog.php b/library/Class/Systeme/ModulesMenu/Numilog.php index 6569397f9f37b17e6ebeab78e5b1a738bad2b368..3c7bb8abcb03cc62099580b4295f6ec8de1b35c0 100644 --- a/library/Class/Systeme/ModulesMenu/Numilog.php +++ b/library/Class/Systeme/ModulesMenu/Numilog.php @@ -29,21 +29,15 @@ class Class_Systeme_ModulesMenu_Numilog extends Class_Systeme_ModulesMenu_SSOAbs public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Numilog'); } - public function getNumilogUrlForUser($user) { + public function urlForUser($user) { if ($user && $user->hasRightAccesNumilog()) return Class_NumilogLink::forUser($user)->url(); - return Class_AdminVar::get('NUMILOG_URL'); - } - - - public function getDynamiqueUrl() { - return ($user = Class_Users::getIdentity()) - ? $this->getNumilogUrlForUser($user) - : Class_AdminVar::get('NUMILOG_URL'); + return ''; } diff --git a/library/Class/Systeme/ModulesMenu/Orthodidacte.php b/library/Class/Systeme/ModulesMenu/Orthodidacte.php index cdbcf5da68fafe54a4f764bb7210e29ba0299e7d..7d59a30627c84ddd7890116a712b3d05b5be80c1 100644 --- a/library/Class/Systeme/ModulesMenu/Orthodidacte.php +++ b/library/Class/Systeme/ModulesMenu/Orthodidacte.php @@ -29,15 +29,14 @@ class Class_Systeme_ModulesMenu_Orthodidacte extends Class_Systeme_ModulesMenu_S public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Orthodidacte'); } public function urlForUser($user) { - if (!$user->hasRightAccesOrthodidacte()) { - $this->setMessage($this->_('Votre abonnement ne permet pas d\'accéder aux ressources Orthodidacte. Merci de contacter la médiathèque')); + if (!$user->hasRightAccesOrthodidacte()) return ''; - } return Class_Orthodidacte_Link::newFor($user); } @@ -46,6 +45,4 @@ class Class_Systeme_ModulesMenu_Orthodidacte extends Class_Systeme_ModulesMenu_S public function isVisibleForProfil($profil) { return Class_AdminVar::isOrthodidacteEnabled(); } - -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/Class/Systeme/ModulesMenu/PlanetNemo.php b/library/Class/Systeme/ModulesMenu/PlanetNemo.php index 97a85349f704bc4efcbbbe6887c700706f573e58..84fd710b8c7ae2894544f1f6e588239cb9dd14b8 100644 --- a/library/Class/Systeme/ModulesMenu/PlanetNemo.php +++ b/library/Class/Systeme/ModulesMenu/PlanetNemo.php @@ -27,16 +27,16 @@ class Class_Systeme_ModulesMenu_PlanetNemo extends Class_Systeme_ModulesMenu_SSO public function construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers planetnemo.fr'); } public function urlForUser($user) { - if ($user && $user->hasRightAccessPlanetNemo() && Class_AdminVar::isPlanetNemoEnabled()) - return Class_PlanetNemoLink::forUser($user)->url(); + if (!$user->hasRightAccessPlanetNemo()) + return ''; - $this->setMessage('Vous n\'avez pas accès à cette ressource.'); - return ''; + return Class_PlanetNemoLink::forUser($user)->url(); } diff --git a/library/Class/Systeme/ModulesMenu/SSOAbstract.php b/library/Class/Systeme/ModulesMenu/SSOAbstract.php index 8cbfff5c4045678504937eacf76d611109d49fbc..15da820bddac0703e4d68f88d49ebb2ca3bb030f 100644 --- a/library/Class/Systeme/ModulesMenu/SSOAbstract.php +++ b/library/Class/Systeme/ModulesMenu/SSOAbstract.php @@ -19,9 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class Class_Systeme_ModulesMenu_SSOAbstract extends Class_Systeme_ModulesMenu_Null { +class Class_Systeme_ModulesMenu_SSOAbstract extends Class_Systeme_ModulesMenu_Null { protected $_login_redirect_url = null; + + public function __construct() { + $this->setMessage($this->_('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.')); + } + + public function afterLoginRedirectTo($url) { $this->_login_redirect_url = $url; return $this; @@ -29,7 +35,11 @@ abstract class Class_Systeme_ModulesMenu_SSOAbstract extends Class_Systeme_Modul public function loginUrl() { - return Class_Url::assemble(array_filter(['controller' => 'auth', 'action' => 'login'])) . + $this->setMessage($this->_('Vous devez vous connecté avec un abonnement valide pour profiter de la ressource.')); + + return Class_Url::absolute(['module' => 'opac', + 'controller' => 'auth', + 'action' => 'login']) . '?redirect=' . urlencode($this ->_login_redirect_url); } diff --git a/library/Class/Systeme/ModulesMenu/ToutApprendre.php b/library/Class/Systeme/ModulesMenu/ToutApprendre.php index 83f14b65b5946082bde1ba506b7c708d9c3aecb3..84038b6e36496dde0728a2e5250eacc309c7bfa5 100644 --- a/library/Class/Systeme/ModulesMenu/ToutApprendre.php +++ b/library/Class/Systeme/ModulesMenu/ToutApprendre.php @@ -27,16 +27,17 @@ class Class_Systeme_ModulesMenu_ToutApprendre extends Class_Systeme_ModulesMenu_ public function __construct() { + parent::__construct(); $this->libelle = $this->_('libelle'); $this->_url = Class_ToutApprendreLink::staticUrl(); } public function urlForUser($user) { - if ($user && $user->hasRightAccesToutApprendre()) - return Class_ToutApprendreLink::forUser($user)->url(); - $this->setMessage('Votre abonnement est terminé'); - return ''; + if (!$user->hasRightAccesToutApprendre()) + return ''; + + return Class_ToutApprendreLink::forUser($user)->url(); } diff --git a/library/Class/Systeme/ModulesMenu/Vodeclic.php b/library/Class/Systeme/ModulesMenu/Vodeclic.php index 8d7a1bd89b0aa0a8ec7812bbe172fab775934507..92fabf30e49b6d3eca689577db579e2f9fde3704 100644 --- a/library/Class/Systeme/ModulesMenu/Vodeclic.php +++ b/library/Class/Systeme/ModulesMenu/Vodeclic.php @@ -27,16 +27,17 @@ class Class_Systeme_ModulesMenu_Vodeclic extends Class_Systeme_ModulesMenu_SSOAb public function __construct() { + parent::__construct(); $this->_libelle = $this->_('Lien vers Vodeclic'); $this->_url = Class_VodeclicLink::staticUrl(); } public function urlForUser($user) { - if ($user && $user->hasRightAccesVodeclic()) - return Class_VodeclicLink::forUser($user)->url(); - $this->setMessage('Votre abonnement est terminé'); - return ''; + if (!$user->hasRightAccesVodeclic()) + return ''; + + return Class_VodeclicLink::forUser($user)->url(); } diff --git a/tests/application/modules/opac/controllers/ModulesControllerKidilanguesTest.php b/tests/application/modules/opac/controllers/ModulesControllerKidilanguesTest.php index 17ad0cbf82255058564fc599b10eafcbdf236f15..ad40bf4e0971fb27df7e24bf9deb1643306b8933 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerKidilanguesTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerKidilanguesTest.php @@ -53,7 +53,7 @@ class ModulesControllerKidilanguesNoAccessRightTest extends ModulesControllerKid /** @test */ public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource.'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); } } @@ -152,6 +152,6 @@ class ModulesControllerKidilanguesDeactivateAndUserLoggedTest extends ModulesCon /** @test */ public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource.'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque'); } } diff --git a/tests/application/modules/opac/controllers/ModulesControllerMyCowTest.php b/tests/application/modules/opac/controllers/ModulesControllerMyCowTest.php index 63f5a152783b7904c04264ad305667890c7d1b5a..c321ad4de4d0301833569f7ee079a8f721a22b38 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerMyCowTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerMyCowTest.php @@ -65,7 +65,7 @@ class ModulesControllerMyCowNoAccessRightTest extends AbstractControllerTestCase /** @test */ public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource.'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); } } @@ -142,6 +142,6 @@ class ModulesControllerMyCowDeactivateAndUserLoggedTest extends AbstractControll /** @test */ public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource.'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); } } diff --git a/tests/application/modules/opac/controllers/ModulesControllerPlanetNemoTest.php b/tests/application/modules/opac/controllers/ModulesControllerPlanetNemoTest.php index f0444d67a7b978fdd7ed8f9855468b6430e0f719..67fffb3e666bec4e2c8b510cb19140b2a993b2a8 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerPlanetNemoTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerPlanetNemoTest.php @@ -28,7 +28,7 @@ class ModulesControllerPlanetNemoNoAccessRightTest extends AbstractControllerTes /** @test */ public function shouldHaveAccessForbiddenMessage() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource.'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); } } diff --git a/tests/application/modules/opac/controllers/ModulesControllerTest.php b/tests/application/modules/opac/controllers/ModulesControllerTest.php index b8e0b5d6aff9c523f4947e75286ddb558036809b..887f4ba67b30f726154abd73bd829965e986c8bd 100644 --- a/tests/application/modules/opac/controllers/ModulesControllerTest.php +++ b/tests/application/modules/opac/controllers/ModulesControllerTest.php @@ -61,12 +61,18 @@ class ModulesControllerLeSocialWithoutGroupTest extends AbstractControllerTestCa RessourcesNumeriquesFixtures::activateLeSocial(); $this->dispatch('/opac/modules/lesocial',true); } + + /** @test */ public function accesShouldBeForbidden() { - $this->assertFlashMessengerContentContains('Vous n\'avez pas accès à cette ressource'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); } } + + + + class ModulesControllerLeSocialWithGroupTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -97,7 +103,19 @@ class ModulesControllerArteVodTest extends AbstractControllerTestCase { public function arteVodUrlWithoutUserShouldBeHomePage() { ZendAfi_Auth::getInstance()->clearIdentity(); $this->dispatch('/opac/modules/artevod'); - $this->assertContains('http://www.mediatheque-numerique.com',$this->_response->getBody()); + $this->assertXpath('//script[contains(text(), "location.href=")][contains(text(), "auth/login?redirect=http")]'); + } + + + /** @test */ + public function contextShouldExpectation() { + $group = $this->fixture('Class_UserGroup', ['id' => 1]) + ->addRight(Class_UserGroup::RIGHT_ACCES_ARTEVOD); + + Class_Users::getIdentity()->setUserGroups([$group]); + + $this->dispatch('/opac/modules/artevod'); + $this->assertXpathContentContains('//script', 'document.location.href="https://portal.mediatheque-numerique.com/sso_login?sso_id=afi&id=666&id_encrypted=ce04173447e59a7a3608f625b0348ccec5f4070c7c3f286b032cbe6374ec9f32&d=28320c8a6c44f751b8e5c94f0092509a0c0303f71df326e15341aea531ed14ba&return_url=http%3A%2F%2Fwww.mediatheque-numerique.com%2F";'); } } @@ -105,6 +123,8 @@ class ModulesControllerArteVodTest extends AbstractControllerTestCase { class ModulesControllerNumilogTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); Class_AdminVar::newInstanceWithId('NUMILOG_URL',['valeur' => 'http://numilogurl/action']); @@ -112,25 +132,46 @@ class ModulesControllerNumilogTest extends AbstractControllerTestCase { /** @test */ - public function numilogUrlWithoutUserShouldBeLoginPage() { + public function responseShouldContainsRedirectToLogin() { ZendAfi_Auth::getInstance()->clearIdentity(); $this->dispatch('/opac/modules/numilog'); - $this->assertRedirectTo('http://numilogurl/action'); + $this->assertXpath('//script[contains(text(), "location.href=")][contains(text(), "auth/login?redirect=http")]'); + } + + + /** @test */ + public function shouldRedirectToNumilog() { + $group = $this->fixture('Class_UserGroup', ['id' => 1]) + ->addRight(Class_UserGroup::RIGHT_ACCES_NUMILOG); + + Class_Users::getIdentity()->setUserGroups([$group]); + + $this->dispatch('/opac/modules/numilog'); + $this->assertXpathContentContains('//script', 'document.location.href="http://numilogurl/action?ticket=ST-'); } } + class ModulesControllerNumeriquepremiumTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - $this->postDispatch('/opac/modules/numeriquepremium', ['url' => 'http://foo/']); } + /** @test */ public function numeriquepremiumShouldContainScript() { + $this->postDispatch('/opac/modules/numeriquepremium', ['url' => 'http://foo/']); $this->assertXPathContentContains('//script', 'http://foo/', $this->_response->getBody()); } + + + /** @test */ + public function numeriquepremiumDispatchTest() { + $this->dispatch('/opac/modules/numeriquepremium', true); + $this->assertRedirect(); + } } @@ -281,3 +322,36 @@ class ModulesControllerBibliondemandSsoTest extends AbstractControllerTestCase { $this->assertXPathContentContains('//script', 'document.location.href="http://numerique-pasdecalais.bibliondemand.com/logon.aspx?provider=SsoCas&sso-id=cg62-saintomer&returnUrl='. urlencode('http://music.1dtouch.com/users/auth/assa?dest=albums/137962&bibid=CG62').'"', $this->_response->getBody()); } } + + + + + +class ModulesControllerMusicMeTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + Class_AdminVar::newInstanceWithId('MUSICME_URL',['valeur' => 'http://music_me.com/ecoute']); + } + + + /** @test */ + public function responseShouldContainsRedirectToLogin() { + ZendAfi_Auth::getInstance()->clearIdentity(); + $this->dispatch('/opac/modules/musicme'); + $this->assertXpath('//script[contains(text(), "location.href=")][contains(text(), "auth/login?redirect=http")]'); + } + + + /** @test */ + public function shouldRedirectToNumilog() { + $group = $this->fixture('Class_UserGroup', ['id' => 1]) + ->addRight(Class_UserGroup::RIGHT_ACCES_MUSICME); + + Class_Users::getIdentity()->setUserGroups([$group]); + + $this->dispatch('/opac/modules/musicme'); + $this->assertXpathContentContains('//script', 'document.location.href="http://music_me.com/ecoute'); + } +} diff --git a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php index 3b27e5bbe1b8d3afe628453d5bb0fa8bc2ee66b2..dc1690d7b69a0da0e17033e869b80a902a60d238 100644 --- a/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php +++ b/tests/library/Class/Systeme/ModulesMenu/ToutApprendreTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -33,7 +33,7 @@ class Class_Systeme_ModulesMenu_ToutApprendreTest extends Storm_Test_ModelTestCa 'date_debut' => '1999-02-10', 'date_fin' => '2025-09-12', 'user_groups' => [$this->fixture('Class_UserGroup', [ - 'id' => 20, + 'id' => 20, 'libelle' => 'ToutApprendre' ])->addRight(Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE)] ])->beAbonneSIGB(); @@ -51,8 +51,8 @@ class Class_Systeme_ModulesMenu_ToutApprendreTest extends Storm_Test_ModelTestCa /** @test */ public function urlWithAbonnementInvalidShouldBeJSAlertAbonnementInvalid() { $this->user->setDateFin('2000-03-01'); - $url = $this->menu->getDynamiqueUrl(); - $this->assertContains('Votre abonnement est terminé', $this->menu->getMessage()); + $url = $this->menu->getDynamiqueUrl(); + $this->assertContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.', $this->menu->getMessage()); } } ?> \ No newline at end of file diff --git a/tests/library/Class/Systeme/ModulesMenu/VodeclicTest.php b/tests/library/Class/Systeme/ModulesMenu/VodeclicTest.php index 2f67a00ebc189ac22af67ccf1c24116b2df967bb..3dccd2fdb48b87c456b442a9d59b87e6726113c8 100644 --- a/tests/library/Class/Systeme/ModulesMenu/VodeclicTest.php +++ b/tests/library/Class/Systeme/ModulesMenu/VodeclicTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -25,18 +25,20 @@ class Class_Systeme_ModulesMenu_VodeclicTest extends Storm_Test_ModelTestCase { parent::setUp(); RessourcesNumeriquesFixtures::activate(); $this->menu = new Class_Systeme_ModulesMenu_Vodeclic(); - $this->user = $this->fixture('Class_Users', [ - 'id'=> 34 , - 'password' => 'toto' , - 'login' => '34', - 'idabon' => 34, - 'date_debut' => '1999-02-10', - 'date_fin' => '2025-09-12', - 'user_groups' => [$this->fixture('Class_UserGroup', [ - 'id' => 20, - 'libelle' => 'Vodeclic' - ])->addRight(Class_UserGroup::RIGHT_ACCES_VODECLIC)] - ])->beAbonneSIGB(); + $this->user = + $this->fixture('Class_Users', + ['id'=> 34 , + 'password' => 'toto' , + 'login' => '34', + 'idabon' => 34, + 'date_debut' => '1999-02-10', + 'date_fin' => '2025-09-12', + 'user_groups' => [$this->fixture('Class_UserGroup', + ['id' => 20, + 'libelle' => 'Vodeclic' + ]) + ->addRight(Class_UserGroup::RIGHT_ACCES_VODECLIC)] + ])->beAbonneSIGB(); ZendAfi_Auth::getInstance()->logUser($this->user); } @@ -51,7 +53,6 @@ class Class_Systeme_ModulesMenu_VodeclicTest extends Storm_Test_ModelTestCase { public function withAbonnementInvalidShouldBeJSAlertAbonnementInvalid() { $this->user->setDateFin('2000-03-01'); $this->menu->getDynamiqueUrl(); - $this->assertContains('Votre abonnement est terminé', $this->menu->getMessage()); + $this->assertContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.', $this->menu->getMessage()); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php b/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php index 44fdbcb638cd69e05185cc49f4c5ff25cd29f485..432c78cdd1fe7e06d2baab00ed75d807d2d9bbee 100644 --- a/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php +++ b/tests/scenarios/CiteDeLaMusique/CiteDeLaMusiqueTest.php @@ -156,7 +156,7 @@ class CiteDeLaMusiqueModulesControllerTest extends AbstractControllerTestCase { ->assertSave(); $this->dispatch('/modules/cite-de-la-musique', true); - $this->assertFlashMessengerContentContains('Vous devez être connecté'); + $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas d\'accéder à la ressource. Merci de contacter la médiathèque.'); }