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

Merge branch 'hotline#177152_mel_cas3_archimed_page_blanche' into 'master'

Hotline#177152 mel cas3 archimed page blanche

See merge request !4706
parents f1ffb7b2 270e27ab
Branches
Tags
1 merge request!4706Hotline#177152 mel cas3 archimed page blanche
Pipeline #22520 failed with stage
in 25 minutes and 53 seconds
- correctif #177152 : CAS3 : import correct des dates au format UTC
\ No newline at end of file
......@@ -95,7 +95,8 @@ class Class_User_ILSSubscription {
public function ilsExpireIn() :string {
$date_expiry = new DateTime($this->_user->getDateFin());
if (!($date_expiry = new DateTime($this->_user->getDateFin())))
return '';
$today = new DateTime($this->getTimeSource()->dateYmd());
return $today->diff($date_expiry)->format("%r%a");
}
......
......@@ -21,6 +21,7 @@
class Class_WebService_Cas3 extends Class_WebService_Cas2 {
use Trait_TimeSource;
protected $_user_attributes = [];
protected function _mappingResponse(string $body) :self {
......@@ -40,10 +41,16 @@ class Class_WebService_Cas3 extends Class_WebService_Cas2 {
}
protected function _validateValue($value, string $function_name) {
return (($function_name == 'naissance')
&& (strlen($value) <= 4))
? sprintf('%04d-01-01',$value)
: $value;
protected function _validateValue(?string $value, string $function_name): string {
if (!$value)
return '';
if (!(($function_name == 'naissance') ||($function_name == 'date_fin')) )
return $value;
if (strlen($value) <= 4)
return sprintf('%04d-01-01',$value);
return self::tryFormatDate($value);
}
}
......@@ -77,6 +77,18 @@ trait Trait_TimeSource {
}
public static function tryFormatDate( string $date_str, string $return_format= 'Y-m-d'): string {
$date_str = str_replace( '.0Z', '', $date_str);
$formats=['Y','Y-m-d', 'Y/m/d', 'Ymd', 'YmdHis', 'd-m-Y', 'd/m/Y'];
foreach ($formats as $format) {
if ($date = DateTime::createFromFormat($format, $date_str))
return $date->format($return_format);
}
return '';
}
public static function addIntervalToDate($interval, $date){
$date= $date
? strtotime($date)
......
......@@ -78,6 +78,7 @@ abstract class IdentityProviderAuthenticationCas3BokehToBokehTestCase extends Ab
];
}
protected function _addPdJames(){
$this->fixture(Class_Users::class,
['id' => 98134,
......@@ -95,7 +96,6 @@ abstract class IdentityProviderAuthenticationCas3BokehToBokehTestCase extends Ab
abstract public function mappingDatas();
/**
* @test
* @dataProvider mappingDatas
......@@ -153,6 +153,56 @@ class IdentityProviderAuthenticationCas3WrongMappingTest extends IdentityProvide
class IdentityProviderAuthenticationCas3Bokeh2BokehWithUTCDateTest extends IdentityProviderAuthenticationCas3BokehToBokehTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/auth/login/provider/1?ticket=testticket');
}
protected function _getAnswer() {
return file_get_contents(__DIR__.'/cas3archimed.xml');
}
/** @test */
public function userShouldBeRemotelyLogged() {
$this->assertTrue($this->_provider->isRemotelyLogged());
}
public function mappingDatas() : array {
return [
['Nom', 'Pouce'],
['Prenom' , 'Tom'],
['Mail', 'tom@pouce.fr'],
['IdSigb', '22345'],
['NomRole', 'abonne'],
['LibraryId', '3'],
['LibelleBib', 'Annecy'],
['DateFin', '2023-02-15'],
['LibelleBib', 'Annecy'],
['Naissance', '1972-02-14'],
['CodePostal', '38123'],
['Ville', 'Laval'],
];
}
/**
* @test
* @dataProvider mappingDatas
*/
public function userShouldGetMapping($key, $value) {
$this->assertEquals($value, Class_Users::getIdentity()->{'get' . $key}());
}
}
class IdentityProviderAuthenticationCas3Bokeh2BokehTest extends IdentityProviderAuthenticationCas3BokehToBokehTestCase {
public function setUp() {
......@@ -229,6 +279,7 @@ class IdentityProviderAuthenticationCas3PMBToBokehTest extends IdentityProviderA
];
}
protected function _getAnswer() {
return'<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
<cas:authenticationSuccess>
......@@ -244,6 +295,7 @@ class IdentityProviderAuthenticationCas3PMBToBokehTest extends IdentityProviderA
</cas:serviceResponse>';
}
public function mappingDatas() : array {
return [
['Nom', 'Pouce'],
......@@ -258,6 +310,7 @@ class IdentityProviderAuthenticationCas3PMBToBokehTest extends IdentityProviderA
class IdentityProviderAuthenticationCas3Bokeh2BokehWithoutAutoCreateUsersTest extends IdentityProviderAuthenticationCas3BokehToBokehTestCase {
public function setUp() {
......@@ -336,6 +389,7 @@ class IdentityProviderAuthenticationCas3Bokeh2BokehWithAutoUpdateUsersTest exten
];
}
public function mappingDatas(){
return [
['Id', '98134'],
......
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
<cas:authenticationSuccess>
<cas:user>mysuperid</cas:user>
<cas:proxyGrantingTicket>ST-a51b1ae3e8b2319bba4e90841a40cf4b</cas:proxyGrantingTicket>
<cas:attributes>
<cas:lastname>Pouce</cas:lastname>
<cas:firstname>Tom</cas:firstname>
<cas:mail>tom@pouce.fr</cas:mail>
<cas:expire_at>20230215000000.0Z</cas:expire_at>
<cas:card_number>123XPE</cas:card_number>
<cas:ils_number>22345</cas:ils_number>
<cas:birth_date>19720214000000.0Z</cas:birth_date>
<cas:postal_code>38123</cas:postal_code>
<cas:city>Laval</cas:city>
<cas:affiliation>supremes</cas:affiliation>
<cas:affiliation>temptations</cas:affiliation>
</cas:attributes>
</cas:authenticationSuccess>
</cas:serviceResponse>
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