diff --git a/README-LABINVENT.md b/README-LABINVENT.md
index 3658c6a..1806ef6 100755
--- a/README-LABINVENT.md
+++ b/README-LABINVENT.md
@@ -47,8 +47,8 @@ Logiciel testé et validé sur les configurations suivantes :
VERSION ACTUELLE
-Date: 28/08/2017
-Version: 2.7.6
+Date: 29/08/2017
+Version: 2.7.7
Grosse amelioration des tests (refactorisation, généralisation)
Version majeure en cours (2.7): https://projects.irap.omp.eu/versions/162
@@ -65,6 +65,10 @@ CHANGEMENTS IMPORTANTS (MILESTONES)
Liste complète des évolutions: https://gitlab.irap.omp.eu/epallier/labinvent/commits/master
+28/08/2017 Version: 2.7.6
+ - renforcement important des TESTS : généralisation, refactorisation, simplification + numérotation systématique (cf doc ACL)
+ - nouvelle philo mise en place : 1 fichier tests par Controleur (c'était déjà le cas), puis pour un controleur donné, tri des tests par ACTION, puis pour chaque action, tests systématique de tous les ROLES (profils) avec les cas particuliers de chacun
+
06/07/2017 Version: 2.7.3
- suppression du contenu de vendor/ => désormais ignoré car autogénéré
- update des plugins phpqrcode et fpdf => désormais via composer.json
diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php
index 25f1057..7587770 100755
--- a/src/Controller/AppController.php
+++ b/src/Controller/AppController.php
@@ -49,6 +49,9 @@ class AppController extends Controller {
'Super Administrateur' => self::PROFILE_SUPERADMIN
];
+ // Current role (profile) of the user
+ private $CURRENT_ROLE = null;
+
public static function getRoleLevel($role) {
//return $this->allProfiles[$role];
@@ -105,12 +108,15 @@ class AppController extends Controller {
}
public function getUserRole() {
- $configuration = $this->confLabinvent;
- $user = TableRegistry::get('Users')->find()
- ->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])
- //->where(['username' => $this->LdapAuth->user('cn')[0]])
- ->first();
- return $user['role'];
+ if (! $this->CURRENT_ROLE) {
+ $configuration = $this->confLabinvent;
+ $user = TableRegistry::get('Users')->find()
+ ->where(['username' => $this->LdapAuth->user($configuration->authentificationType_ldap)[0]])
+ //->where(['username' => $this->LdapAuth->user('cn')[0]])
+ ->first();
+ $this->CURRENT_ROLE = $user['role'];
+ }
+ return $this->CURRENT_ROLE;
}
public function userHasRole($expectedRole, $ORMORE=false) {
diff --git a/src/Template/Layout/default.ctp b/src/Template/Layout/default.ctp
index fc52edc..80653aa 100755
--- a/src/Template/Layout/default.ctp
+++ b/src/Template/Layout/default.ctp
@@ -115,7 +115,7 @@ $cakeDescription = 'Labinvent 2';
- VERSION 2.7.6 (28/08/2017)
+ VERSION 2.7.7 (29/08/2017)
tearDown();
+ //$this->tearDown();
}
@@ -260,13 +275,19 @@ class MaterielsControllerTest extends General {
*
* @return void
*/
+ /*
public function testMat30AccessCreateForm() {
foreach ($this->ROLES as $role) $this->_testMatAccessCreateFormAs($role);
}
-
+ */
+ public function testMat30AccessCreateFormAsUser() { $this->_testMatAccessCreateFormAs('USER'); }
+ public function testMat30AccessCreateFormAsResp() { $this->_testMatAccessCreateFormAs('RESP'); }
+ public function testMat30AccessCreateFormAsAdmin() { $this->_testMatAccessCreateFormAs('ADMIN'); }
+ public function testMat30AccessCreateFormAsAdminPlus() { $this->_testMatAccessCreateFormAs('ADMINP'); }
+ public function testMat30AccessCreateFormAsSuperAdmin() { $this->_testMatAccessCreateFormAs('SUPER'); }
private function _testMatAccessCreateFormAs($role)
{
- $this->setUp();
+ //$this->setUp();
// On doit pouvoir accéder à la page une fois authentifié
$this->authAs($role);
@@ -283,7 +304,7 @@ class MaterielsControllerTest extends General {
$this->assertResponseContains('EOTP', 'Le profil admin+ n\'a pas accès à la partie administrative sur le formulaire add.');
*/
- $this->tearDown();
+ //$this->tearDown();
}
@@ -458,6 +479,8 @@ class MaterielsControllerTest extends General {
* @return void
*/
+ // ACTION 'edit'
+ /*
public function testUpdate() { // ACTION 'edit'
foreach ($this->ROLES as $role) {
$this->authAs($role);
@@ -465,10 +488,15 @@ class MaterielsControllerTest extends General {
$this->_testUpdates($role);
} // foreach
}
-
-
- private function _testUpdates($role) {
-
+ */
+ //TODO: test as USER
+ //public function testUpdateAsUser() { $this->_testUpdatesAs('USER'); }
+ public function testUpdateAsResp() { $this->_testUpdatesAs('RESP'); }
+ public function testUpdateAsAdmin() { $this->_testUpdatesAs('ADMIN'); }
+ public function testUpdateAsAdminPlus() { $this->_testUpdatesAs('ADMINP'); }
+ public function testUpdateAsSuperAdmin() { $this->_testUpdatesAs('SUPER'); }
+ private function _testUpdatesAs($role) {
+ $this->authAs($role);
// 1) Test qu'on peut modifier un materiel CREATED
// Toutes les donnees passees sont modifiees
$data = [
diff --git a/tests/TestCase/Controller/PagesControllerTest.php b/tests/TestCase/Controller/PagesControllerTest.php
index 8e9fcff..cea62f0 100755
--- a/tests/TestCase/Controller/PagesControllerTest.php
+++ b/tests/TestCase/Controller/PagesControllerTest.php
@@ -61,12 +61,18 @@ class PagesControllerTest extends General
* @return void
*/
+ //public function testDisplay()
+ /*
public function testPage10AccessHome() {
foreach ($this->ROLES as $role) $this->subtestPageAccessHomeAs($role);
}
- //public function testDisplay()
- private function subtestPageAccessHomeAs($role)
- {
+ */
+ public function testPage10AccessHomeAsUser() { $this->_testPageAccessHomeAs('USER'); }
+ public function testPage10AccessHomeAsResp() { $this->_testPageAccessHomeAs('RESP'); }
+ public function testPage10AccessHomeAsAdmin() { $this->_testPageAccessHomeAs('ADMIN'); }
+ public function testPage10AccessHomeAsAdminPlus() { $this->_testPageAccessHomeAs('ADMINP'); }
+ public function testPage10AccessHomeAsSuperAdmin() { $this->_testPageAccessHomeAs('SUPER'); }
+ private function _testPageAccessHomeAs($role) {
//$this->authUser();
$this->authAs($role);
@@ -96,12 +102,18 @@ class PagesControllerTest extends General
}
-
+ //public function testDisplay()
+ /*
public function testPage20AccessTools() {
foreach ($this->ROLES as $role) $this->subtestPageAccessToolsAs($role);
}
- //public function testDisplay()
- private function subtestPageAccessToolsAs($role)
+ */
+ public function testPage20AccessToolsAsUser() { $this->_testPageAccessToolsAs('USER'); }
+ public function testPage20AccessToolsAsResp() { $this->_testPageAccessToolsAs('RESP'); }
+ public function testPage20AccessToolsAsAdmin() { $this->_testPageAccessToolsAs('ADMIN'); }
+ public function testPage20AccessToolsAsAdminPlus() { $this->_testPageAccessToolsAs('ADMINP'); }
+ public function testPage20AccessToolsAsSuperAdmin() { $this->_testPageAccessToolsAs('SUPER'); }
+ private function _testPageAccessToolsAs($role)
{
$this->authAs($role);
$this->get('/pages/tools');
@@ -113,7 +125,8 @@ class PagesControllerTest extends General
$this->assertResponseOk();
$this->assertResponseContains('Outils', $role.' should be allowed to access the Tools page');
$this->assertResponseContains('Gérer le contenu variable de ', $role);
- if ($role == 'SUPER')
+ if ($this->USER_IS_SUPERADMIN())
+ //if ($role == 'SUPER')
$this->assertResponseContains('Passer en mode DEBUG');
else
$this->assertResponseNotContains('Passer en mode DEBUG');
--
libgit2 0.21.2 |