Skip to content

Commit

Permalink
feat: add Consultant Administrator option to add users page (#363)
Browse files Browse the repository at this point in the history
* feat: add operator-tc to permission list

* feat: add `user_type` and `permission_type` of operator-tc

* chore: php.xml

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: removed 2 roles have same permissions

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: add `operator-tc` to user type `transport-manager`

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: re-added 2 roles on same permission

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* feat: give the role-entity `operator-tc` its own permission

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: allowed `operator-tc` permission to be passed as admin

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* chore: removed php.xml

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: removed `operator-tc` user type to follow [ROLE]=[USER_TYPE][PERMISSION]

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* fix: changed `operator-tc` to `tc` when refrencing the `tc` permission

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>

* wip: unit testing of selfserverCreateUser commandhandler

* fix: removed testing for selfserverCreateUser commandhandler

* fix: fixed tests

* chore: update lock files

---------

Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>
Co-authored-by: Shaun Hare <shaun.hare@dvsa.gov.uk>
  • Loading branch information
gabrielg2020 and sdh100shaun authored Oct 9, 2024
1 parent 1168502 commit 9703d68
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 1,547 deletions.
592 changes: 0 additions & 592 deletions .idea/php.xml

This file was deleted.

12 changes: 6 additions & 6 deletions app/api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions app/api/module/Api/src/Entity/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class User extends AbstractUser implements OrganisationProviderInterface
public const PERMISSION_ADMIN = 'admin';
public const PERMISSION_USER = 'user';
public const PERMISSION_TM = 'tm';
public const PERMISSION_TC = 'tc';

public const USER_TYPE_INTERNAL = 'internal';
public const USER_TYPE_ANON = 'anon';
Expand Down Expand Up @@ -97,12 +98,14 @@ class User extends AbstractUser implements OrganisationProviderInterface
self::PERMISSION_USER => [RoleEntity::ROLE_LOCAL_AUTHORITY_USER],
],
self::USER_TYPE_OPERATOR => [
self::PERMISSION_ADMIN => [RoleEntity::ROLE_OPERATOR_ADMIN, RoleEntity::ROLE_OPERATOR_TC],
self::PERMISSION_TC => [RoleEntity::ROLE_OPERATOR_TC],
self::PERMISSION_ADMIN => [RoleEntity::ROLE_OPERATOR_ADMIN],
self::PERMISSION_USER => [RoleEntity::ROLE_OPERATOR_USER],
self::PERMISSION_TM => [RoleEntity::ROLE_OPERATOR_TM],
],
self::USER_TYPE_TRANSPORT_MANAGER => [
self::PERMISSION_ADMIN => [RoleEntity::ROLE_OPERATOR_ADMIN, RoleEntity::ROLE_OPERATOR_TC],
self::PERMISSION_TC => [RoleEntity::ROLE_OPERATOR_TC],
self::PERMISSION_ADMIN => [RoleEntity::ROLE_OPERATOR_ADMIN],
self::PERMISSION_USER => [RoleEntity::ROLE_OPERATOR_USER],
self::PERMISSION_TM => [RoleEntity::ROLE_OPERATOR_TM],
],
Expand Down Expand Up @@ -502,7 +505,9 @@ private function isAdministrator()
// is admin if has roles for admin permission
return $this->hasRoles(
self::getRolesByUserType($this->getUserType(), self::PERMISSION_ADMIN)
);
) || $this->hasRoles(
self::getRolesByUserType($this->getUserType(), self::PERMISSION_TC)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Dvsa\Olcs\Api\Entity\Organisation\Organisation as OrganisationEntity;
use Dvsa\Olcs\Api\Entity\Organisation\OrganisationUser as OrganisationUserEntity;
use Dvsa\Olcs\Api\Entity\Tm\TransportManager as TransportManagerEntity;
use Dvsa\Olcs\Api\Entity\User\Role as RoleEntity;
use Dvsa\Olcs\Api\Entity\User\User as UserEntity;
use Dvsa\Olcs\Auth\Service\PasswordService;
use Dvsa\Olcs\Transfer\Command\User\CreateUserSelfserve as Cmd;
Expand Down Expand Up @@ -255,6 +256,7 @@ public function testHandleCommandForTm()
$savedUser = $this->commonHandleCommandTest();

$this->assertEquals(UserEntity::USER_TYPE_OPERATOR, $savedUser->getUserType());

}

public function testHandleCommandThrowsIncorrectUserTypeException()
Expand Down
Loading

0 comments on commit 9703d68

Please sign in to comment.