From ea1e2253e9c062a38cd00f8c988c2d4c6058bd2c Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Wed, 25 Oct 2017 14:32:14 +0200
Subject: [PATCH] hotline #65680 fix artevod

---
 VERSIONS_HOTLINE/65680                            |  2 ++
 library/Class/ArteVodLink.php                     |  9 ++++-----
 library/Class/WebService/BibNumerique/ArteVOD.php | 15 ++++-----------
 .../WebService/BibNumerique/ArteVOD/Film.php      |  2 +-
 .../opac/controllers/ModulesControllerTest.php    |  2 +-
 tests/library/Class/ArteVodLinkTest.php           |  8 ++++----
 6 files changed, 16 insertions(+), 22 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/65680

diff --git a/VERSIONS_HOTLINE/65680 b/VERSIONS_HOTLINE/65680
new file mode 100644
index 00000000000..b3443254613
--- /dev/null
+++ b/VERSIONS_HOTLINE/65680
@@ -0,0 +1,2 @@
+ - ticket #65680 : Ressources numériques : correction de l'accès à la ressource Arte VOD.
+ 
\ No newline at end of file
diff --git a/library/Class/ArteVodLink.php b/library/Class/ArteVodLink.php
index 9f24c23e225..e367e7fe5dd 100644
--- a/library/Class/ArteVodLink.php
+++ b/library/Class/ArteVodLink.php
@@ -25,8 +25,8 @@ class Class_ArteVodLink {
   protected $_album;
   protected $_user;
   const
-    BASE_URL = 'https://vod.mediatheque-numerique.com',
-    LOGIN_SUFFIX = '/sso_login',
+    AUTH_URL = 'https://portal.mediatheque-numerique.com/sso_login',
+    API_URL = 'https://vod.mediatheque-numerique.com',
     API_SUFFIX = '/api/v1/',
     MEDIATHEQUES_SUFFIX = '/mediatheques/';
 
@@ -57,7 +57,7 @@ class Class_ArteVodLink {
     if ($this->_album)
       return $this->_album->getExternalUri();
 
-    return static::BASE_URL . static::MEDIATHEQUES_SUFFIX . Class_AdminVar::get('ARTE_VOD_LOGIN');
+    return static::API_URL . static::MEDIATHEQUES_SUFFIX . Class_AdminVar::get('ARTE_VOD_LOGIN');
   }
 
 
@@ -78,8 +78,7 @@ class Class_ArteVodLink {
                'datout' => $this->_user->getDateFin(),
                'return_url' => $this->baseUrl()];
 
-    return static::BASE_URL
-      . static::LOGIN_SUFFIX
+    return static::AUTH_URL
       . '?'
       . http_build_query(array_filter($params));
   }
diff --git a/library/Class/WebService/BibNumerique/ArteVOD.php b/library/Class/WebService/BibNumerique/ArteVOD.php
index 4cc9d9e423b..7deb77b2e91 100644
--- a/library/Class/WebService/BibNumerique/ArteVOD.php
+++ b/library/Class/WebService/BibNumerique/ArteVOD.php
@@ -24,13 +24,8 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu
   const CATEGORY_LABEL = 'ArteVOD';
 
 
-  public function apiLink() {
-    return Class_ArteVodLink::BASE_URL . Class_ArteVodLink::API_SUFFIX;
-  }
-
-
   protected function loadPage($page_number = 1) {
-    $url =  $this->apiLink() . self::FILMS . '?page_nb=' . $page_number;
+    $url =  $this->getBaseUrl() . self::FILMS . '?page_nb=' . $page_number;
     $content = $this->open_authenticated_url($url);
     if ('' == $content) {
       $this->getLogger()->error('Erreur de communication');
@@ -79,12 +74,12 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu
   protected function _deleteNonHarvested() {
     if (0 < count($this->getHarvestedIds()))
       Class_Album::getLoader()
-        ->deleteBy(['where' => 'url_origine="' . $this->apiLink() . '" and id_origine not in (\'' . implode("', '", $this->getHarvestedIds()) . '\')']);
+        ->deleteBy(['where' => 'url_origine="' . $this->getBaseUrl() . '" and id_origine not in (\'' . implode("', '", $this->getHarvestedIds()) . '\')']);
   }
 
 
   public function getBaseUrl() {
-    return $this->apiLink();
+    return Class_ArteVodLink::API_URL . Class_ArteVodLink::API_SUFFIX;
   }
 
   public function isEnabled() {
@@ -95,6 +90,4 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu
   public function getName() {
     return 'ArteVOD';
   }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/library/Class/WebService/BibNumerique/ArteVOD/Film.php b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
index 49821c39689..82fb3c24293 100644
--- a/library/Class/WebService/BibNumerique/ArteVOD/Film.php
+++ b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
@@ -140,7 +140,7 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
 
 
   public function getBaseUrl(){
-    return (new Class_WebService_BibNumerique_ArteVOD)->apiLink();
+    return (new Class_WebService_BibNumerique_ArteVOD)->getBaseUrl();
   }
 }
 
diff --git a/tests/application/modules/opac/controllers/ModulesControllerTest.php b/tests/application/modules/opac/controllers/ModulesControllerTest.php
index 49b3526edc3..61e5b59eab7 100644
--- a/tests/application/modules/opac/controllers/ModulesControllerTest.php
+++ b/tests/application/modules/opac/controllers/ModulesControllerTest.php
@@ -144,7 +144,7 @@ class ModulesControllerArteVodTest extends AbstractControllerTestCase {
 
     $this->dispatch('/opac/modules/artevod');
     $this->assertXpathContentContains('//script',
-                                      'document.location.href="https://vod.mediatheque-numerique.com/sso_login?sso_id=afi&id=666&id_encrypted=ce04173447e59a7a3608f625b0348ccec5f4070c7c3f286b032cbe6374ec9f32&d=d8fb24f80a99bded9ed417591c5ac5cc1e123bcce10d65e1f6a83211ca18d3e8&return_url=https%3A%2F%2Fvod.mediatheque-numerique.com%2Fmediatheques%2Fuser";');
+                                      'document.location.href="https://portal.mediatheque-numerique.com/sso_login?sso_id=afi&id=666&id_encrypted=ce04173447e59a7a3608f625b0348ccec5f4070c7c3f286b032cbe6374ec9f32&d=d8fb24f80a99bded9ed417591c5ac5cc1e123bcce10d65e1f6a83211ca18d3e8&return_url=https%3A%2F%2Fvod.mediatheque-numerique.com%2Fmediatheques%2Fuser";');
   }
 }
 
diff --git a/tests/library/Class/ArteVodLinkTest.php b/tests/library/Class/ArteVodLinkTest.php
index 655221a2d2f..691a0abd00e 100644
--- a/tests/library/Class/ArteVodLinkTest.php
+++ b/tests/library/Class/ArteVodLinkTest.php
@@ -73,7 +73,7 @@ class ArteVodLinkWithUserAndAlbumTest extends Storm_Test_ModelTestCase {
   public function withKeySECRETUrlShouldContainsEncryptedDate() {
     Class_AdminVar::newInstanceWithId('ARTE_VOD_SSO_KEY')->setValeur('GOGO');
 
-    $this->assertEquals('https://vod.mediatheque-numerique.com/sso_login'
+    $this->assertEquals('https://portal.mediatheque-numerique.com/sso_login'
                         .'?sso_id=afi'
                         .'&id=45'
                         .'&id_encrypted='. hash('sha256', '45GOGO')
@@ -97,7 +97,7 @@ class ArteVodLinkWithUserAndAlbumTest extends Storm_Test_ModelTestCase {
       ->setNom('')
       ->setMail('');
 
-    $this->assertEquals('https://vod.mediatheque-numerique.com/sso_login'
+    $this->assertEquals('https://portal.mediatheque-numerique.com/sso_login'
                         .'?sso_id=afi'
                         .'&id=45'
                         .'&id_encrypted='. hash('sha256', '45secret')
@@ -120,7 +120,7 @@ class ArteVodLinkWithUserAndAlbumTest extends Storm_Test_ModelTestCase {
       ->setDateFin('')
       ->beInvite();
 
-    $this->assertEquals('https://vod.mediatheque-numerique.com/sso_login'
+    $this->assertEquals('https://portal.mediatheque-numerique.com/sso_login'
                         .'?sso_id=afi'
                         .'&id=19'
                         .'&id_encrypted='. hash('sha256', '19secret')
@@ -143,7 +143,7 @@ class ArteVodLinkWithUserAndAlbumTest extends Storm_Test_ModelTestCase {
       ->setDateFin('')
       ->setNaissance('1975-01-01');
 
-    $this->assertEquals('https://vod.mediatheque-numerique.com/sso_login'
+    $this->assertEquals('https://portal.mediatheque-numerique.com/sso_login'
                         .'?sso_id=afi'
                         .'&id=45'
                         .'&id_encrypted='. hash('sha256', '45secret')
-- 
GitLab