From b27c281f1419f9d0a0f7a66e4c321a03adbf6478 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Wed, 17 Jul 2013 14:03:43 +0000
Subject: [PATCH] Music Me : developpement du SSO

---
 .gitattributes                                |  3 +
 .../opac/controllers/CasServerController.php  | 41 +++++++++++
 .../opac/controllers/ModulesController.php    |  6 ++
 library/Class/AdminVar.php                    | 12 +++-
 library/Class/MusicMeLink.php                 | 62 ++++++++++++++++
 library/Class/NumilogLink.php                 |  3 -
 library/Class/Systeme/ModulesMenu.php         |  1 +
 library/Class/Systeme/ModulesMenu/MusicMe.php | 69 ++++++++++++++++++
 library/Class/UserGroup.php                   |  4 +-
 library/Class/Users.php                       |  7 ++
 library/Class/WebService/Abstract.php         |  5 ++
 .../controllers/CasServerControllerTest.php   | 39 ++++++++++
 tests/library/Class/MusicMeLinkTest.php       | 71 +++++++++++++++++++
 .../Class/RessourcesNumeriquesFixtures.php    | 15 ++++
 .../library/Class/Systeme/ModulesMenuTest.php | 57 +++++++++++++--
 15 files changed, 386 insertions(+), 9 deletions(-)
 create mode 100644 library/Class/MusicMeLink.php
 create mode 100644 library/Class/Systeme/ModulesMenu/MusicMe.php
 create mode 100644 tests/library/Class/MusicMeLinkTest.php

diff --git a/.gitattributes b/.gitattributes
index 011898845ed..a280624d7a3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2287,6 +2287,7 @@ library/Class/Multimedia/DeviceGroup.php -text
 library/Class/Multimedia/DeviceHold.php -text
 library/Class/Multimedia/Location.php -text
 library/Class/Multimedia/ReservationBean.php -text
+library/Class/MusicMeLink.php -text
 library/Class/NatureDoc.php -text
 library/Class/Newsletter.php -text
 library/Class/NewsletterSubscription.php -text
@@ -2404,6 +2405,7 @@ library/Class/Systeme/ModulesMenu/Etagere.php -text
 library/Class/Systeme/ModulesMenu/FormulaireContact.php -text
 library/Class/Systeme/ModulesMenu/LastNews.php -text
 library/Class/Systeme/ModulesMenu/Menu.php -text
+library/Class/Systeme/ModulesMenu/MusicMe.php -text
 library/Class/Systeme/ModulesMenu/News.php -text
 library/Class/Systeme/ModulesMenu/Null.php -text
 library/Class/Systeme/ModulesMenu/Numilog.php -text
@@ -5948,6 +5950,7 @@ tests/library/Class/MultiUploadTest.php -text
 tests/library/Class/Multimedia/DeviceTest.php -text
 tests/library/Class/Multimedia/LocationTest.php -text
 tests/library/Class/MultimediaTest.php -text
+tests/library/Class/MusicMeLinkTest.php -text
 tests/library/Class/NewsletterMailingTest.php -text
 tests/library/Class/NewsletterSubscriptionTest.php -text
 tests/library/Class/NewsletterTest.php -text
diff --git a/application/modules/opac/controllers/CasServerController.php b/application/modules/opac/controllers/CasServerController.php
index 194a9273886..15d13e454d2 100644
--- a/application/modules/opac/controllers/CasServerController.php
+++ b/application/modules/opac/controllers/CasServerController.php
@@ -49,6 +49,26 @@ class CasServerController extends Zend_Controller_Action {
 
 
 
+	public function returnValidMusicMeResponse($session) {
+
+		$this->getResponse()->setHeader('Content-Type', 'application/xml;charset=utf-8');
+		$this->getResponse()->setBody( '<User>
+<ID>'.$session->ID_USER.'.</ID>
+<FirstName>'.(isset($session->PRENOM) ? $session->PRENOM:'').'</FirstName>
+<LastName>'.(isset($session->NOM) ? $session->NOM:'').'</LastName>
+<AccountDisabled>false</AccountDisabled>
+<AccountExpired>false</AccountExpired>
+</User>'
+);
+	}
+
+
+
+	public function returnMusicMeFailureTicketResponse($error,$ticket=null) {
+		$this->getResponse()->setHeader('Content-Type', 'application/xml;charset=utf-8');
+		$xml="<User />";
+		$this->getResponse()->setBody($xml);
+	}
 	public function returnFailureTicketResponse($error,$ticket=null) {
 		$this->getResponse()->setHeader('Content-Type', 'application/xml;charset=utf-8');
 		$xml='<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">';
@@ -69,6 +89,27 @@ class CasServerController extends Zend_Controller_Action {
 		
 	}
 
+	function validateMusicmeAction() {
+		$bibid=$this->_request->getParam('MediaLibraryID');
+		$ticket=$this->_request->getParam('SessionID');
+
+		if (strlen($ticket)<1 || strlen($bibid)<1) {
+			return $this->returnMusicMeFailureTicketResponse('INVALID_REQUEST');
+		}
+		xdebug_break();
+
+		$serialized_session=Zend_Registry::get('cache')->load($ticket);
+		if ($serialized_session) {
+			$session = unserialize($serialized_session);
+			if ($session)
+			return $this->returnValidMusicMeResponse($session);
+
+		}
+		return $this->returnMusicMeFailureTicketResponse('INVALID_TICKET',$ticket);
+
+	}
+
+
 /* To be implemented :  INVALID_SERVICE - the ticket provided was valid, but the service specified did not match the service associated with the ticket. CAS MUST invalidate the ticket and disallow future validation of that same ticket. */
 /* INTERNAL_ERROR - an internal error occurred during ticket validation */
 
diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php
index 1843d227d46..e6b18fb6d95 100644
--- a/application/modules/opac/controllers/ModulesController.php
+++ b/application/modules/opac/controllers/ModulesController.php
@@ -39,6 +39,12 @@ class ModulesController extends Zend_Controller_Action {
 	}
 
 
+	public function musicmeAction() {
+		$musicme = new Class_Systeme_ModulesMenu_MusicMe();
+		return $this->checkNotifyMessage($musicme,$musicme->getDynamiqueUrl());
+	}
+
+
 	public function checkNotifyMessage($ressource_link, $url) {
 		if (strlen($url)>0)
 			return $this->_redirect($url);
diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php
index 2e63d9a564c..f07fa77506c 100644
--- a/library/Class/AdminVar.php
+++ b/library/Class/AdminVar.php
@@ -91,7 +91,9 @@ class Class_AdminVar extends Storm_Model_Abstract {
 		'AFFICHER_DISPONIBILITE_SUR_RECHERCHE',
 		'NOM_DOMAINE',
 		'TOUTAPPRENDRE_BIB_ID',
-		'TOUTAPPRENDRE_KEY'
+		'TOUTAPPRENDRE_KEY',
+		'MUSICME_URL',
+		'MUSICME_BIB_ID'
 	);
 
 
@@ -265,6 +267,14 @@ class Class_AdminVar extends Storm_Model_Abstract {
 	}	
 
 
+	/**
+	 * @return bool
+	 */
+	public static function isMusicMeEnabled() {
+		return ('' != self::get('MUSICME_URL'));
+	}	
+
+
 	/**
 	 * @return bool
 	 */
diff --git a/library/Class/MusicMeLink.php b/library/Class/MusicMeLink.php
new file mode 100644
index 00000000000..c7096d87c7a
--- /dev/null
+++ b/library/Class/MusicMeLink.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+class Class_MusicMeLink extends Class_WebService_Abstract {
+	use Trait_TimeSource;
+
+	const CVS_SOURCEXPIRATIONTIME = 30;
+
+	protected $_user;
+
+	public static function forUser($user) {
+		return new self($user);
+	}
+
+	public function __construct($user) {
+		$this->_user = $user;
+	}
+
+	public static function staticLink() {
+		return BASE_URL.'/modules/musicme';
+	}
+
+	public function baseUrl() {
+		$url = Class_AdminVar::get('MUSICME_URL');
+		return $url;
+	}
+
+	public function url() {
+
+		$bib_id = Class_AdminVar::get('MUSICME_BIB_ID');
+		$iduser = strtolower($this->_user->getLogin());
+		$formatted_date=date('YmdHi',$this->getCurrentTime());
+		$params = ['iduser' => $iduser,
+							 'ticket' => $this->getTicket(),
+							 'MediaLibraryID' => $bib_id
+			];
+		$params['service'] = $this->baseUrl().'?'.http_build_query(array_filter($params));
+		return $this->baseUrl().'?'.http_build_query(array_filter($params));
+	}
+
+
+
+
+}
\ No newline at end of file
diff --git a/library/Class/NumilogLink.php b/library/Class/NumilogLink.php
index 403c7559720..96c301ed101 100644
--- a/library/Class/NumilogLink.php
+++ b/library/Class/NumilogLink.php
@@ -47,9 +47,6 @@ class Class_NumilogLink extends Class_WebService_Abstract {
 
 
 	
-	function getTicket() {
-		return md5(Zend_Session::getId());
-	}
 
 	function urlExternal($url_external){
 		if ($this->_user)
diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php
index 3189bc8f5e0..b0501278f70 100644
--- a/library/Class/Systeme/ModulesMenu.php
+++ b/library/Class/Systeme/ModulesMenu.php
@@ -121,6 +121,7 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
 			"CVS" => new Class_Systeme_ModulesMenu_CVS(),
 			"NUMILOG" => new Class_Systeme_ModulesMenu_Numilog(),
 			"ARTEVOD" => new Class_Systeme_ModulesMenu_ArteVod(),
+			"MUSICME" => new Class_Systeme_ModulesMenu_MusicMe(),
 			"RESERVER_POSTE" => new Class_Systeme_ModulesMenu_ReserverPoste(),
 			'SUGGESTION_ACHAT' => new Class_Systeme_ModulesMenu_SuggestionAchat()
 		];
diff --git a/library/Class/Systeme/ModulesMenu/MusicMe.php b/library/Class/Systeme/ModulesMenu/MusicMe.php
new file mode 100644
index 00000000000..80ae217e1a8
--- /dev/null
+++ b/library/Class/Systeme/ModulesMenu/MusicMe.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+class Class_Systeme_ModulesMenu_MusicMe extends Class_Systeme_ModulesMenu_Null {
+	use Trait_Translator;
+
+	/** @var string */
+	protected $_type_module = 'MusicMe';
+
+	/** @var string */
+	protected $_libelle = '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 getUrl($preferences=[]) {
+		return BASE_URL.'/modules/musicme';
+	}
+
+
+	public function getDynamiqueUrl($docid=null) {
+		$user = Class_Users::getIdentity();
+		if (!$user) {
+			$musicme_link=new Class_MusicMeLink();
+			return $musicme_link->baseUrl();
+		}
+		$url=$this->getMusicMeUrlForUser($user);
+		return $url;
+	}
+
+	public function shouldOpenInNewWindow($preferences) {
+		return null != Class_Users::getIdentity();
+	}
+
+
+	public function isVisibleForProfil($profil) {
+		return Class_AdminVar::isMusicMeEnabled();
+	}
+}
+?>
\ No newline at end of file
diff --git a/library/Class/UserGroup.php b/library/Class/UserGroup.php
index dd7935958f4..ef35b591771 100644
--- a/library/Class/UserGroup.php
+++ b/library/Class/UserGroup.php
@@ -35,6 +35,7 @@ class Class_UserGroup extends Storm_Model_Abstract {
 	const RIGHT_ACCES_CVS = 16;
 	const RIGHT_ACCES_VODECLIC = 32;
 	const RIGHT_ACCES_TOUTAPPRENDRE = 64;
+	const RIGHT_ACCES_MUSICME = 128;
 
 	// Type de groupe
 	const TYPE_MANUAL = 0;
@@ -46,7 +47,8 @@ class Class_UserGroup extends Storm_Model_Abstract {
 																					 self::RIGHT_ACCES_NUMILOG => 'Accéder à Numilog',
 																					 self::RIGHT_ACCES_CVS => 'Accéder à CVS',
 																					 self::RIGHT_ACCES_VODECLIC => 'Accéder à Vodéclic',
-																					 self::RIGHT_ACCES_TOUTAPPRENDRE => 'Accéder à Tout Apprendre'
+																					 self::RIGHT_ACCES_TOUTAPPRENDRE => 'Accéder à Tout Apprendre',
+																					 self::RIGHT_ACCES_MUSICME => 'Accéder à Music Me'
 		];
 
 
diff --git a/library/Class/Users.php b/library/Class/Users.php
index 998e69d96d7..c2d27f32bd7 100644
--- a/library/Class/Users.php
+++ b/library/Class/Users.php
@@ -543,6 +543,13 @@ class Class_Users extends Storm_Model_Abstract {
 	}
 
 
+	public function hasRightAccesMusicMe() {
+		if ($this->isAbonne() && !$this->isAbonnementValid())
+			return false;
+		return in_array(Class_UserGroup::RIGHT_ACCES_MUSICME, $this->getRights());
+	}
+
+
 	public function getFirstAvisByIdNotice($id_notice) {
 		$notice = Class_Notice::getLoader()->find($id_notice);
 		$avis = $notice->getAvisByUser($this);
diff --git a/library/Class/WebService/Abstract.php b/library/Class/WebService/Abstract.php
index 8d4d329d153..39733fe99fb 100644
--- a/library/Class/WebService/Abstract.php
+++ b/library/Class/WebService/Abstract.php
@@ -50,6 +50,11 @@ abstract class Class_WebService_Abstract {
 	function getMessage() {
 		return $this->_message;
 	}
+
+	function getTicket() {
+		return md5(Zend_Session::getId());
+	}
+
 }
 
 ?>
\ No newline at end of file
diff --git a/tests/application/modules/opac/controllers/CasServerControllerTest.php b/tests/application/modules/opac/controllers/CasServerControllerTest.php
index c50463f7a60..f9d7d17eaad 100644
--- a/tests/application/modules/opac/controllers/CasServerControllerTest.php
+++ b/tests/application/modules/opac/controllers/CasServerControllerTest.php
@@ -56,3 +56,42 @@ class CasServerControllerValidateActionTest extends AbstractControllerTestCase {
 	}
 
 }
+
+
+class CasServerControllerMusicMeValidateActionTest extends AbstractControllerTestCase {
+	protected $session_file_contents_logged;
+	protected $session_file_contents_nologin;
+
+	public function setUp() {
+		parent::setUp();
+		$user = new StdClass();
+		$user->ID_USER=300;
+		$user->PRENOM='Tom';
+		$user->NOM = 'Ate';
+		Zend_Registry::get('cache')->save(serialize($user),md5(Zend_Session::getId()));
+	}
+
+	
+	/** @test */
+	public function requestMusicMeWithNoTicketShouldRespondAccountDisabledXML() {		
+		$this->dispatch('/opac/cas-server/validate-musicme?MediaLibraryID=150&SessionID=0a1b2c3d');
+		$this->assertContains('<User />',$this->_response->getBody());
+	}
+
+
+	/** @test */
+	public function requestMusicMeWithExpiredTicketShouldRespondInvalidTicketFailureXML() {		
+		$this->dispatch('/opac/cas-server/validate-musicme?MediaLibraryID=STmarchepo&SessionID=28282');
+		$this->assertContains('<AccountExpired>true',$this->_response->getBody());
+	}
+
+
+	/** @test */
+	public function requestMusicMeWithValidTicketShouldRespondValidXML() {		
+	
+		$this->dispatch('/opac/cas-server/validate-musicme?SessionID='.md5(Zend_Session::getId()).'&MediaLibraryID=http://test.com');
+		$this->assertContains('<ID>',$this->_response->getBody());
+
+	}
+
+}
diff --git a/tests/library/Class/MusicMeLinkTest.php b/tests/library/Class/MusicMeLinkTest.php
new file mode 100644
index 00000000000..48263971272
--- /dev/null
+++ b/tests/library/Class/MusicMeLinkTest.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+abstract class MusicMeLinkTestCase extends Storm_Test_ModelTestCase {
+	protected 	$_http_client;
+	protected $_jerry;
+	public function setUp() {
+		parent::setUp();
+		$this->_http_client = Storm_Test_ObjectWrapper::mock();
+
+		Class_MusicMeLink::setDefaultHttpClient($this->_http_client);
+		RessourcesNumeriquesFixtures::activateMusicMe();
+		$this->_jerry = Class_Users::getLoader()
+			->newInstanceWithId(4)
+			->setIdabon(34)
+			->setLogin(34)
+			->setPseudo('JKhan')
+			->setPrenom('Jerry')
+			->setNom('Khan')
+			->setMail('feu@essence.fr')
+			->setPassword('secret')
+			->setDateFin('2023-09-02')
+			->setNaissance('1977-06-27')
+			->setBib(Class_Bib::newInstanceWithId(34, ['libelle' => 'Annecy']));
+
+		$this->_musicme = Class_MusicMeLink::forUser($this->_jerry);
+
+	}
+}
+
+
+
+class MusicMeLinkWithAbonTest extends MusicMeLinkTestCase {
+
+	public function setUp() {
+		parent::setUp();
+	
+	}
+
+	/** @test */ 
+	public function urlWithLogginShouldBeMusicmeSSO() {
+		$this->assertEquals('http://musicmeurl/',
+												$this->_musicme->baseUrl());
+	}
+
+/** @test */
+	public function musicMeUrlShouldExtractUrlFromResponse() {
+		$ticket=md5( Zend_Session::getId());
+		$this->assertEquals('http://musicmeurl/?iduser=34&ticket='.$ticket.
+												'&MediaLibraryID=888&service=http%3A%2F%2Fmusicmeurl%2F%3Fiduser%3D34%26ticket%3D'.$ticket.'%26MediaLibraryID%3D888',
+												$this->_musicme->url());
+	}
+}
diff --git a/tests/library/Class/RessourcesNumeriquesFixtures.php b/tests/library/Class/RessourcesNumeriquesFixtures.php
index 96f6a736d57..fc86cdc673d 100644
--- a/tests/library/Class/RessourcesNumeriquesFixtures.php
+++ b/tests/library/Class/RessourcesNumeriquesFixtures.php
@@ -82,6 +82,21 @@ class RessourcesNumeriquesFixtures {
 
 
 
+	public static function activateMusicMe() {
+		Class_AdminVar::newInstanceWithId('MUSICME_URL',['valeur' => 'http://musicmeurl/']);
+		Class_AdminVar::newInstanceWithId('MUSICME_BIB_ID',['valeur' => '888']);
+	}
+
+
+
+
+	public static function deactivateMusicMe() {
+		Class_AdminVar::newInstanceWithId('MUSICME_URL',['valeur' => '']);
+		Class_AdminVar::newInstanceWithId('MUSICME_BIB_ID',['valeur' => '']);
+	}
+
+
+
 	public static function deactivateNumilog() {
 		Class_AdminVar::newInstanceWithId('NUMILOG_URL',['valeur' => '']);
 	}
diff --git a/tests/library/Class/Systeme/ModulesMenuTest.php b/tests/library/Class/Systeme/ModulesMenuTest.php
index c6fb9274960..779375a2344 100644
--- a/tests/library/Class/Systeme/ModulesMenuTest.php
+++ b/tests/library/Class/Systeme/ModulesMenuTest.php
@@ -27,6 +27,7 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 		RessourcesNumeriquesFixtures::activateArteVod();
 		Class_AdminVar::newInstanceWithId('MULTIMEDIA_KEY', ['valeur' => 'zork']);
 		RessourcesNumeriquesFixtures::activateNumilog();
+		RessourcesNumeriquesFixtures::activateMusicMe();
 		RessourcesNumeriquesFixtures::activateToutApprendre();
 		$this->module_menu = new Class_Systeme_ModulesMenu();
 
@@ -46,8 +47,6 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 	}
 
 
-
-
 	/** @test */
 	public function menuShouldNotContainsVodeclicWhenDisabled() {
 		$menu = $this->module_menu->getFonction('VODECLIC');
@@ -55,6 +54,13 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 	}
 
 
+	/** @test */
+	public function menuShouldNotContainsMusicMeWhenDisabled() {
+		$menu = $this->module_menu->getFonction('MUSICME');
+		$this->assertEquals('Lien vers MusicMe', $menu->getLibelle());
+	}
+
+
 
 	/** @test */
 	public function cvsUrlShouldBeStaticPage() {
@@ -100,6 +106,7 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 			->setLogin(34)
 			->setNom('Lagaffe')
 			->setPrenom('Gaston')
+			->setPseudo('gaffe')
 			->setUserGroups([]);
 	}
 
@@ -122,6 +129,24 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 	}
 
 
+	/** @test */
+	public function musicMeUrlWithUserLoggedShouldBeMusicMeSSO() {
+		$this->group_musicme = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia',
+																																				'rights_token' => Class_UserGroup::RIGHT_ACCES_MUSICME]);
+
+		$this->_logUserGaston()
+			->beAbonneSIGB()
+			->setDateDebut('1999-02-10')
+			->setDateFin('2025-09-12')
+			->setUserGroups([$this->group_musicme]);
+		$musicme= new Class_Systeme_ModulesMenu_MusicMe();
+		
+		$url = $musicme->getDynamiqueUrl();
+		$this->assertContains('musicme', $url);
+
+	}
+
+
 	/** @test */
 	public function toutapprendreUrlWithUserLoggedShouldBeToutApprendreSSO() {
 		$this->group_toutapprendre = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia',
@@ -132,9 +157,9 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 			->setDateDebut('1999-02-10')
 			->setDateFin('2025-09-12')
 			->setUserGroups([$this->group_toutapprendre]);
-		$vodeclic= new Class_Systeme_ModulesMenu_ToutApprendre();
+		$toutapprendre= new Class_Systeme_ModulesMenu_ToutApprendre();
 		
-		$url = $vodeclic->getDynamiqueUrl();
+		$url = $toutapprendre->getDynamiqueUrl();
 		$this->assertContains('toutapprendre', $url);
 
 	}
@@ -230,6 +255,30 @@ class ModulesMenuTest extends Storm_Test_ModelTestCase {
 												$this->module_menu->getUrl('TOUTAPPRENDRE', []));
 	}
 
+
+
+	/** @test */
+	public function menuShouldContainsMusicMe() {
+		$this->module_menu = new Class_Systeme_ModulesMenu();
+		$menu = $this->module_menu->getFonction('MUSICME');
+		$this->assertContains('/modules/musicme', $menu->getUrl());
+	}
+
+	/** @test */
+	public function menuShouldNotContainsMusicMeWhenDeactivated() {
+		RessourcesNumeriquesFixtures::deactivateMusicMe();
+		$this->module_menu = new Class_Systeme_ModulesMenu();
+		$menu = $this->module_menu->getFonction('MUSICME');
+		$this->assertNotContains('/modules/musicme', $menu->getUrl());
+	}
+
+/** @test */
+	public function musicmeUrlShouldBeStaticPage() {
+		ZendAfi_Auth::getInstance()->clearIdentity();
+		$this->assertEquals(['url' => BASE_URL.'/modules/musicme', 'target' => ''], 
+												$this->module_menu->getUrl('MUSICME', []));
+	}
+
 }
 
 
-- 
GitLab