Skip to content
Snippets Groups Projects
Commit c040a764 authored by efalcy's avatar efalcy
Browse files

dev#94557 : connector Whisperies

parent 3a2e22b1
Branches
Tags
5 merge requests!3297WIP: Master,!3288Dev#94557 contractuel connecteur whisperies,!3286Dev#94557 contractuel connecteur whisperies,!3278Dev#94557 contractuel connecteur whisperies,!3268dev#94557 : connector Whisperies
Pipeline #8432 failed with stage
in 32 minutes and 29 seconds
Showing
with 943 additions and 0 deletions
'94557' =>
['Label' => $this->_('[Explo] [Contractuel] connecteur Whisperies'),
'Desc' => '',
'Image' => '',
'Video' => '',
'Category' => '',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2019-09-27'],
\ No newline at end of file
- ticket #94557 : connecteur Whisperies
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Batch extends Class_DigitalResource_Batch {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Config extends Class_DigitalResource_Config {
const WHISPERIES_HARVEST_URL = 'https://vgr9zkquwh.execute-api.eu-west-1.amazonaws.com/prod/oai?verb=ListRecords';
protected function _getConfig() {
return ['Introduction' => $this->_('Whisperies'),
'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Whisperies',
'Url' => '',
'Icon' => '',
'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource Whisperies'),
'NotAllowedMessage' => $this->_('Votre compte n\'est pas autorisé à accéder à cette ressource.'),
'SsoAction' => true,
'Harvesting' => true,
'MenuLabel' => $this->_('Lien vers Whisperies'),
'ModuleMenu' => $this->withNameSpace('ModuleMenu'),
'Service' => $this->withNameSpace('Service'),
'Batch' => $this->withNameSpace('Batch'),
'DocTypeLabel' => $this->_('ressource Whisperies'),
'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme Whisperies'),
['value' => ''])->bePrivate()]
];
}
public function isEnabled() {
return '' != $this->getAdminVar('SSO_URL');
}
public function getSsoUrl($user) {
if(!$user)
return '';
return $this->getAdminVar('SSO_URL');
}
public function getAlbumSsoUrl($user, $album) {
if(!$album)
return '';
return $this->getAdminVar('SSO_URL');
}
public function getHarvestUrl($page = 1) {
return static::WHISPERIES_HARVEST_URL;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_ModuleMenu extends Class_DigitalResource_ModuleMenu {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Service extends Class_DigitalResource_Service {
protected function loadPage($page_number = 1) {
$xml = $this->httpGet($this->_config->getHarvestUrl());
$this->_parser = new Whisperies_Service_Parser();
$this->_parser->parseXML($xml);
$this->_albums = $this->_parser->getAlbums();
return $this;
}
public function getPageCount() {
return 1;
}
public function getRessourcesNumeriques() {
return $this->_albums;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique {
public function getBaseUrl() {
return Whisperies_Config::getInstance()->getAdminVar('SSO_URL');
}
protected function getTypeDoc() {
return Whisperies_Config::getInstance()->getDocType();
}
public function fillAlbum($album) {
$album
->setTypeDocId($this->getTypeDoc());
return $this;
}
public function getRessourceCategorieLibelle() {
return Whisperies_Config::getInstance()->getDocTypeLabel();
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Service_Parser {
protected
$_albums = [],
$_current_album;
public function parseXML($xml) {
$this->_parser = new Class_WebService_FasterXMLParser();
$this->_parser->setElementHandler($this);
$this->_parser->parse($xml);
return $this;
}
public function endidentifier($data) {
$this->_current_album->setId($data);
}
public function endTitle($data) {
$this->_current_album->setTitle($data);
}
public function endPublisher($data) {
$this->_current_album->setEditeur($data);
}
public function endYearOfPublication($data) {
$this->_current_album->setYear($data);
}
public function endContentDescription($data) {
$this->_current_album->setDescription($data);
}
public function endPrimaryDocUrl($data) {
$this->_current_album->setExternalUri($data);
}
public function endTypeOfDocument($data) {
$this->_current_album->addMatiere($data);
}
public function endThumbMedium($data) {
$this->_current_album->addPoster($data);
}
public function endAuthor($data) {
$this->_current_album->addAuthor(new Class_Notice_Author($data, '005'));
}
public function startRecord($attributes) {
$this->_current_album = new Whisperies_Service_Album();
}
public function endRecord() {
$this->_albums[] = $this->_current_album;
}
public function getAlbums() {
return $this->_albums;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_View_Helper_Album extends Class_DigitalResource_AlbumViewHelper {}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Whisperies_Plugin_IndexController extends Class_DigitalResource_Controller {}
\ No newline at end of file
library/digital_resources/Whisperies/images/icon.png

3.53 KiB

<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class WhisperiesFixtures {
use Storm_Test_THelpers;
public function prepare() {
Class_AdminVar::set('Whisperies_ENABLE', '1');
$whisperies_xml = file_get_contents(__DIR__ . '/export.xml');
$http_client = $this->mock()
->whenCalled('open_url')
->with('https://vgr9zkquwh.execute-api.eu-west-1.amazonaws.com/prod/oai?verb=ListRecords')
->answers($whisperies_xml)
->whenCalled('open_url')
->answers('a picture');
Whisperies_Service::setDefaultHttpClient($http_client);
return Whisperies_Service::getInstance();
}
}
abstract class WhisperiesActivatedTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_user;
public function setUp() {
parent::setUp();
Class_AdminVar::set('Whisperies_SSO_URL', 'https://test.org/api/bokeh/login');
$group = $this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Digital resources']);
$this->_user = $this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd'])
->setUserGroups([$group]);
$this->fixture('Class_Permission',
['id' => 1,
'code' => 'Whisperies'])
->permitTo($group, new Class_Entity());
}
}
class WhisperiesSsoTest extends WhisperiesActivatedTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->logUser($this->_user);
$this->dispatch('/opac/modules/' . Class_DigitalResource::getInstance()->getSsoActionForPlugin('Whisperies'), true);
}
/** @test */
public function shouldRedirectToResource() {
$this->assertXPathContentContains('//script' , 'document.location.href="PLACEHOLDER', $this->_response->getBody());
}
/** @test */
public function scriptShouldContainsCheckUrl() {
$this->assertXPathContentContains('//script[contains(text(), "&check_url=")]' , '/Whisperies_Plugin/auth/validate');
}
}
class WhisperiesDashboardUnactivatedTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/Whisperies_Plugin', true);
}
/** @test */
public function shouldDisplayDeactivated() {
$this->assertXPathContentContains('//button', 'Désactivé');
}
/** @test */
public function ssoUrlShoudlBeDisplay() {
$this->assertXPathContentContains('//table', 'Whisperies_SSO_URL');
}
}
class WhisperiesDashboardActivatedTest extends WhisperiesActivatedTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 20,
'titre' => '10 moutons',
'type_doc_id' => 'Whisperies'
]);
ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
['id' => 2,
'login' => 'admin',
'password' => 'admin',
'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN]));
$this->dispatch('/Whisperies_Plugin', true);
}
/** @test */
public function shouldDisplayActivated() {
$this->assertXPathContentContains('//button', 'Activé');
}
/** @test */
public function urlSsoTitleBeDisplay() {
$this->assertXPathContentContains('//h4', 'URL SSO générée par /modules/' . Class_DigitalResource::getInstance()->getSsoActionForPlugin('Whisperies') . ' pour l\'utilisateur "Whisperies_test_user"');
}
/** @test */
public function testSsoValidateUrlMessageShoudlBeDisplay() {
$this->assertXPathContentContains('//h4', 'URL de validation du ticket de connexion générée pour l\'utilisateur "Whisperies_test_user"');
}
/** @test */
public function testSsoValidateUrlShoudlBeDisplay() {
$this->assertXPathContentContains('//pre', '/Whisperies_Plugin/auth/validate?sessionid=ST-');
}
/** @test */
public function sourceImageShouldBeValid() {
$this->assertXPathContentContains('//pre','Image source : https://preprod');
}
/** @test */
public function vignetteShouldBePresent() {
$this->assertXPath("//img[contains(@src,'userfiles/album/20/thumb_20_large_10Moutons.jpeg')]");
}
/** @test */
public function doctypeImageUrlShouldBePresent() {
$this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/Whisperies")]');
}
}
class WhisperiesHarvestTest extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_tom;
public function setUp() {
parent::setUp();
Storm_Cache::beVolatile();
(new WhisperiesFixtures())->prepare()->harvest();
Class_Album::find(1)->index();
$this->_tom = $this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd']);
ZendAfi_Auth::getInstance()->logUser($this->_tom);
}
/** @test */
public function userWithRoleInviteShouldNotHaveAccessToModulesLSQR() {
$this->dispatch('/opac/modules/whisperies', true);
$this->assertFlashMessengerContentContains('Votre compte n\'est pas autorisé à accéder à cette ressource.');
}
public function keyValues() {
return [['Aventure sans pareille d\'une boîte normale de taille moyenne', 'getTitrePrincipal'],
['Dans le sixième épisode de la saison 3 des Flashbacks', 'getResume'],
['Dans le sixième épisode de la saison 3 des Flashbacks', 'getFirstAuthor'],
['https://www.whisperies.com/mediatheques/fiche/aventure-sans-pareille-d-une-boite-normale-de-taille-moyenne' ,'getAlbum->getExternalUri()']];
}
/** @test
@dataProvider keyValues */
public function checkHarvest($key,$value) {
$this->assertContains($key,call_user_func([Class_Notice::find(1), $value]));
}
}
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment