Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
afi
opacce
Commits
b8cae5e7
Commit
b8cae5e7
authored
Apr 26, 2018
by
Ghislain Loas
Browse files
dev #59224 fix rt comments
parent
5c342a3c
Pipeline
#4030
failed with stage
in 33 minutes and 54 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
43 deletions
+42
-43
application/modules/opac/controllers/AbonneController.php
application/modules/opac/controllers/AbonneController.php
+0
-10
library/Class/WebService/SIGB/AbstractService.php
library/Class/WebService/SIGB/AbstractService.php
+5
-3
library/Class/WebService/SIGB/Koha/RestfulService.php
library/Class/WebService/SIGB/Koha/RestfulService.php
+5
-20
library/Class/WebService/SIGB/Koha/Service.php
library/Class/WebService/SIGB/Koha/Service.php
+7
-6
tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php
...s/opac/controllers/AbonneControllerChangePasswordTest.php
+12
-0
tests/library/Class/WebService/SIGB/KohaRestfulTest.php
tests/library/Class/WebService/SIGB/KohaRestfulTest.php
+13
-4
No files found.
application/modules/opac/controllers/AbonneController.php
View file @
b8cae5e7
...
@@ -605,8 +605,6 @@ class AbonneController extends ZendAfi_Controller_Action {
...
@@ -605,8 +605,6 @@ class AbonneController extends ZendAfi_Controller_Action {
->
setPassword
(
$password
)
->
setPassword
(
$password
)
->
setNewsletters
(
$newsletters
);
->
setNewsletters
(
$newsletters
);
$this
->
_updatePasswordInILS
();
if
(
$this
->
_user
->
save
())
{
if
(
$this
->
_user
->
save
())
{
$this
->
_helper
->
notify
(
$this
->
_
(
'Vos modifications ont bien été enregistrées'
));
$this
->
_helper
->
notify
(
$this
->
_
(
'Vos modifications ont bien été enregistrées'
));
$this
->
_redirect
(
'/abonne/fiche'
);
$this
->
_redirect
(
'/abonne/fiche'
);
...
@@ -622,14 +620,6 @@ class AbonneController extends ZendAfi_Controller_Action {
...
@@ -622,14 +620,6 @@ class AbonneController extends ZendAfi_Controller_Action {
}
}
protected
function
_updatePasswordInILS
()
{
if
(
!
$comm
=
$this
->
_user
->
getSIGBComm
())
return
;
$comm
->
changePasswordOfBy
(
$this
->
_user
,
$this
->
_user
->
getPassword
());
}
public
function
authenticateAction
()
{
public
function
authenticateAction
()
{
$this
->
getHelper
(
'ViewRenderer'
)
->
setNoRender
();
$this
->
getHelper
(
'ViewRenderer'
)
->
setNoRender
();
...
...
library/Class/WebService/SIGB/AbstractService.php
View file @
b8cae5e7
...
@@ -104,6 +104,11 @@ abstract class Class_WebService_SIGB_AbstractService {
...
@@ -104,6 +104,11 @@ abstract class Class_WebService_SIGB_AbstractService {
}
}
public
function
providesChangePasswordService
()
{
return
false
;
}
public
function
pickupLocationsFor
(
$user
,
$item
)
{
public
function
pickupLocationsFor
(
$user
,
$item
)
{
return
[];
return
[];
}
}
...
@@ -199,9 +204,6 @@ abstract class Class_WebService_SIGB_AbstractService {
...
@@ -199,9 +204,6 @@ abstract class Class_WebService_SIGB_AbstractService {
}
}
public
function
changePasswordOfBy
(
$user
,
$new_password
)
{}
abstract
public
function
getServerRoot
();
abstract
public
function
getServerRoot
();
abstract
public
function
getEmprunteur
(
$user
);
abstract
public
function
getEmprunteur
(
$user
);
...
...
library/Class/WebService/SIGB/Koha/RestfulService.php
View file @
b8cae5e7
...
@@ -141,27 +141,12 @@ class Class_WebService_SIGB_Koha_RestfulService
...
@@ -141,27 +141,12 @@ class Class_WebService_SIGB_Koha_RestfulService
}
}
public
function
changePasswordOfBy
(
$user
,
$new_password
)
{
public
function
saveEmprunteur
(
$emprunteur
)
{
if
(
!
$user
)
$this
->
restfulPut
(
'auth/change_password'
,
return
;
[
'user_name'
=>
$emprunteur
->
getId
(),
'new_password'
=>
$emprunteur
->
getPassword
()]);
if
(
!
$new_password
)
return
$emprunteur
;
return
;
$response
=
$this
->
restfulPut
(
'auth/change_password'
,
[
'user_name'
=>
$user
->
getLogin
(),
'new_password'
=>
$new_password
]);
if
(
null
===
(
$json
=
json_decode
(
$response
,
true
)))
throw
new
Class_WebService_Exception
(
$this
->
_
(
'Échec de la connexion au webservice, le SIGB a répondu "%s"'
,
trim
(
$response
)));
$json
=
reset
(
$json
);
if
(
!
array_key_exists
(
'success'
,
$json
))
throw
new
Class_WebService_Exception
(
$this
->
_
(
'Échec du changement de mot de passe le SIGB à répondu "%s"'
,
trim
(
$response
)));
return
$this
->
_success
();
}
}
...
...
library/Class/WebService/SIGB/Koha/Service.php
View file @
b8cae5e7
...
@@ -259,12 +259,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
...
@@ -259,12 +259,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
}
}
public
function
changePasswordOfBy
(
$user
,
$new_password
)
{
return
$this
->
providesChangePasswordService
()
?
$this
->
getRestfulService
()
->
changePasswordOfBy
(
$user
,
$new_password
)
:
null
;
}
public
function
getRestfulService
()
{
public
function
getRestfulService
()
{
return
Class_WebService_SIGB_Koha_RestfulService
::
newFromIlsdi
(
$this
);
return
Class_WebService_SIGB_Koha_RestfulService
::
newFromIlsdi
(
$this
);
...
@@ -330,4 +324,11 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
...
@@ -330,4 +324,11 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
->
getRestfulService
()
->
getRestfulService
()
->
branches
(
$int_bib
);
->
branches
(
$int_bib
);
}
}
public
function
saveEmprunteur
(
$emprunteur
)
{
return
$this
->
providesChangePasswordService
()
?
$this
->
getRestfulService
()
->
saveEmprunteur
(
$emprunteur
)
:
parent
::
saveEmprunteur
(
$emprunteur
);
}
}
}
\ No newline at end of file
tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php
View file @
b8cae5e7
...
@@ -59,6 +59,12 @@ class AbonneControllerChangePasswordOnKohaTest extends AbstractControllerTestCas
...
@@ -59,6 +59,12 @@ class AbonneControllerChangePasswordOnKohaTest extends AbstractControllerTestCas
$sigb_comm
=
Class_IntBib
::
find
(
3
)
->
getSIGBComm
();
$sigb_comm
=
Class_IntBib
::
find
(
3
)
->
getSIGBComm
();
$sigb_comm
->
setWebClient
(
$mock_web_client
);
$sigb_comm
->
setWebClient
(
$mock_web_client
);
$borrower
=
new
Class_WebService_SIGB_Emprunteur
(
'ml34'
,
'ml34'
);
$koha_user
->
setFicheSigb
([
'type_comm'
=>
Class_IntBib
::
COM_KOHA
,
'fiche'
=>
$borrower
]);
ZendAfi_Auth
::
getInstance
()
->
logUser
(
$koha_user
);
ZendAfi_Auth
::
getInstance
()
->
logUser
(
$koha_user
);
$logger
=
$this
->
mock
()
$logger
=
$this
->
mock
()
...
@@ -117,6 +123,12 @@ class AbonneControllerChangePasswordOnNanookTest extends AbstractControllerTestC
...
@@ -117,6 +123,12 @@ class AbonneControllerChangePasswordOnNanookTest extends AbstractControllerTestC
'idabon'
=>
'123456'
,
'idabon'
=>
'123456'
,
'role_level'
=>
ZendAfi_Acl_AdminControllerRoles
::
ABONNE_SIGB
]);
'role_level'
=>
ZendAfi_Acl_AdminControllerRoles
::
ABONNE_SIGB
]);
$borrower
=
new
Class_WebService_SIGB_Emprunteur
(
'ml34'
,
'ml34'
);
$nanook_user
->
setFicheSigb
([
'type_comm'
=>
Class_IntBib
::
COM_KOHA
,
'fiche'
=>
$borrower
]);
$mock_web_client
=
$this
->
mock
()
$mock_web_client
=
$this
->
mock
()
->
whenCalled
(
'open_url'
)
->
whenCalled
(
'open_url'
)
->
with
(
'http://plage.com/cgi-bin/nanook/ilsdi.pl/service/AuthenticatePatron/username/ml34/password/achanger'
)
->
with
(
'http://plage.com/cgi-bin/nanook/ilsdi.pl/service/AuthenticatePatron/username/ml34/password/achanger'
)
...
...
tests/library/Class/WebService/SIGB/KohaRestfulTest.php
View file @
b8cae5e7
...
@@ -436,11 +436,18 @@ class KohaRestGetUserHistoryTest extends KohaRestfulTestCase {
...
@@ -436,11 +436,18 @@ class KohaRestGetUserHistoryTest extends KohaRestfulTestCase {
class
KohaRestfulChangePasswordTest
extends
KohaRestfulTestCase
{
class
KohaRestfulChangePasswordTest
extends
KohaRestfulTestCase
{
public
function
setUp
()
{
public
function
setUp
()
{
parent
::
setUp
();
parent
::
setUp
();
$borrower
=
new
Class_WebService_SIGB_Emprunteur
(
'1'
,
'harlock'
);
$borrower
->
setService
(
$this
->
service
);
$user
=
$this
->
fixture
(
'Class_Users'
,
$user
=
$this
->
fixture
(
'Class_Users'
,
[
'id'
=>
34
,
[
'id'
=>
34
,
'login'
=>
'harlock'
,
'login'
=>
'harlock'
,
'password'
=>
'arcadia'
,
'password'
=>
'arcadia'
,
'idabon'
=>
'AO989IE'
]);
'idabon'
=>
'AO989IE'
]);
$user
->
setFicheSIGB
([
'fiche'
=>
$borrower
]);
$this
->
mock_web_client
$this
->
mock_web_client
->
whenCalled
(
'putData'
)
->
whenCalled
(
'putData'
)
->
with
(
'http://cat-aficg55.biblibre.com/cgi-bin/koha/rest.pl/auth/change_password'
,
->
with
(
'http://cat-aficg55.biblibre.com/cgi-bin/koha/rest.pl/auth/change_password'
,
...
@@ -448,13 +455,15 @@ class KohaRestfulChangePasswordTest extends KohaRestfulTestCase {
...
@@ -448,13 +455,15 @@ class KohaRestfulChangePasswordTest extends KohaRestfulTestCase {
'new_password'
=>
'ce1snm2p'
])
'new_password'
=>
'ce1snm2p'
])
->
answers
(
json_encode
([[
'success'
=>
[
'password'
=>
'$2a$08$o0BrhvBevJBbWcYJElH3IevoytrdwnkZUQLwNcxQt3GhAjtht3RoK'
]]]))
->
answers
(
json_encode
([[
'success'
=>
[
'password'
=>
'$2a$08$o0BrhvBevJBbWcYJElH3IevoytrdwnkZUQLwNcxQt3GhAjtht3RoK'
]]]))
->
beStrict
();
->
beStrict
();
$this
->
response
=
$this
->
service
->
changePasswordOfBy
(
$user
,
'ce1snm2p'
);
$user
->
setPassword
(
'ce1snm2p'
)
->
save
();
}
}
/** @test */
/** @test */
public
function
responseShouldReturnSuccess
()
{
public
function
userPasswordShouldBeCe1snm2p
()
{
$this
->
assertEquals
([
'statut'
=>
true
,
$this
->
assertEquals
(
'ce1snm2p'
,
Class_Users
::
find
(
34
)
->
getPassword
());
'erreur'
=>
''
],
$this
->
response
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment