feat: rename ROLE_ADMIN to ROLE_TEAM_ADMIN since being too broad
This commit is contained in:
@@ -186,7 +186,7 @@ class ResponseParserTest extends TestCase
|
||||
private function getParserInstance(): ResponseParser
|
||||
{
|
||||
return new ResponseParser([
|
||||
'bpn_crm_id_admin' => 1292,
|
||||
'bpn_crm_id_team_admin' => 1292,
|
||||
'bpn_crm_id_manager' => 1293,
|
||||
'bpn_crm_id_teamer' => 1070,
|
||||
// Deliberately a small excerpt of the configured map: the fixtures only carry
|
||||
|
||||
@@ -44,7 +44,7 @@ class UserDataHandlerTest extends TestCase
|
||||
{
|
||||
yield 'admin only yields the pending marker' => [
|
||||
(new CrmAttributesResponse())->setAdmin(true),
|
||||
[User::PENDING_ROLES['ROLE_ADMIN']],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN']],
|
||||
];
|
||||
|
||||
yield 'manager only yields the pending marker' => [
|
||||
@@ -64,12 +64,12 @@ class UserDataHandlerTest extends TestCase
|
||||
|
||||
yield 'admin and teamer' => [
|
||||
(new CrmAttributesResponse())->setAdmin(true)->setTeamer(true),
|
||||
[User::PENDING_ROLES['ROLE_ADMIN'], 'ROLE_TEAMER'],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN'], 'ROLE_TEAMER'],
|
||||
];
|
||||
|
||||
yield 'admin and manager yield both markers' => [
|
||||
(new CrmAttributesResponse())->setAdmin(true)->setManager(true),
|
||||
[User::PENDING_ROLES['ROLE_ADMIN'], User::PENDING_ROLES['ROLE_MANAGER']],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN'], User::PENDING_ROLES['ROLE_MANAGER']],
|
||||
];
|
||||
|
||||
yield 'manager and house manager yield both markers, the roles stand on their own' => [
|
||||
@@ -100,9 +100,9 @@ class UserDataHandlerTest extends TestCase
|
||||
public static function toPendingRolesProvider(): iterable
|
||||
{
|
||||
yield 'admin' => [
|
||||
['ROLE_ADMIN'],
|
||||
['ROLE_TEAM_ADMIN'],
|
||||
(new CrmAttributesResponse())->setAdmin(true),
|
||||
[User::PENDING_ROLES['ROLE_ADMIN']],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN']],
|
||||
];
|
||||
|
||||
yield 'manager and house manager are marked independently' => [
|
||||
@@ -118,9 +118,9 @@ class UserDataHandlerTest extends TestCase
|
||||
];
|
||||
|
||||
yield 'admin and house manager' => [
|
||||
['ROLE_ADMIN', 'ROLE_HOUSE_MANAGER'],
|
||||
['ROLE_TEAM_ADMIN', 'ROLE_HOUSE_MANAGER'],
|
||||
(new CrmAttributesResponse())->setAdmin(true)->setHouseManager(true),
|
||||
[User::PENDING_ROLES['ROLE_ADMIN'], User::PENDING_ROLES['ROLE_HOUSE_MANAGER']],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN'], User::PENDING_ROLES['ROLE_HOUSE_MANAGER']],
|
||||
];
|
||||
|
||||
yield 'teamer has no marker' => [
|
||||
@@ -144,7 +144,7 @@ class UserDataHandlerTest extends TestCase
|
||||
->setEmail('[email protected]')
|
||||
->setBusProAddressId(1)
|
||||
->setBusProPersonId(2)
|
||||
->setRoles(['ROLE_ADMIN'])
|
||||
->setRoles(['ROLE_TEAM_ADMIN'])
|
||||
->setHotelCodes(['XYZ'])
|
||||
;
|
||||
|
||||
@@ -172,7 +172,7 @@ class UserDataHandlerTest extends TestCase
|
||||
$profileResponse,
|
||||
true,
|
||||
['team' => ['selected' => true]],
|
||||
['ROLE_ADMIN', 'ROLE_TEAMER'],
|
||||
['ROLE_TEAM_ADMIN', 'ROLE_TEAMER'],
|
||||
['DKS'],
|
||||
);
|
||||
|
||||
@@ -182,7 +182,7 @@ class UserDataHandlerTest extends TestCase
|
||||
|
||||
// the CRM leads: the still claimed role survives, the houses are replaced by its own
|
||||
$this->assertSame(['DKS'], $user->getHotelCodes());
|
||||
$this->assertTrue($user->hasRole('ROLE_ADMIN'));
|
||||
$this->assertTrue($user->hasRole('ROLE_TEAM_ADMIN'));
|
||||
|
||||
$this->assertSame('New', $teamer->getFirstName());
|
||||
$this->assertSame('Lastname', $teamer->getLastName());
|
||||
@@ -248,9 +248,9 @@ class UserDataHandlerTest extends TestCase
|
||||
|
||||
yield 'a claim beyond the approved role stays pending' => [
|
||||
['ROLE_MANAGER'],
|
||||
['ROLE_ADMIN', 'ROLE_MANAGER'],
|
||||
['ROLE_TEAM_ADMIN', 'ROLE_MANAGER'],
|
||||
['ROLE_MANAGER'],
|
||||
[User::PENDING_ROLES['ROLE_ADMIN']],
|
||||
[User::PENDING_ROLES['ROLE_TEAM_ADMIN']],
|
||||
];
|
||||
|
||||
yield 'the claimed role changes' => [
|
||||
@@ -261,7 +261,7 @@ class UserDataHandlerTest extends TestCase
|
||||
];
|
||||
|
||||
yield 'a granted role is revoked once the CRM stops claiming it' => [
|
||||
['ROLE_ADMIN', 'ROLE_TEAMER'],
|
||||
['ROLE_TEAM_ADMIN', 'ROLE_TEAMER'],
|
||||
['ROLE_TEAMER'],
|
||||
['ROLE_TEAMER'],
|
||||
[],
|
||||
@@ -282,14 +282,14 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles([User::PENDING_ROLES['ROLE_ADMIN']])
|
||||
->setRoles([User::PENDING_ROLES['ROLE_TEAM_ADMIN']])
|
||||
;
|
||||
|
||||
$handler = new UserDataHandler($this->entityManager, $this->logger);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), true, [], ['ROLE_ADMIN', 'ROLE_TEAMER']);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), true, [], ['ROLE_TEAM_ADMIN', 'ROLE_TEAMER']);
|
||||
|
||||
$this->assertSame(['ROLE_TEAMER'], $user->getAssignedRoles());
|
||||
$this->assertSame([User::PENDING_ROLES['ROLE_ADMIN']], $user->getPendingRoles());
|
||||
$this->assertSame([User::PENDING_ROLES['ROLE_TEAM_ADMIN']], $user->getPendingRoles());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,13 +302,13 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles(['ROLE_ADMIN', 'ROLE_TEAMER'])
|
||||
->setRoles(['ROLE_TEAM_ADMIN', 'ROLE_TEAMER'])
|
||||
;
|
||||
|
||||
$handler = new UserDataHandler($this->entityManager, $this->logger);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), false, [], ['ROLE_ADMIN']);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), false, [], ['ROLE_TEAM_ADMIN']);
|
||||
|
||||
$this->assertSame(['ROLE_ADMIN'], $user->getAssignedRoles());
|
||||
$this->assertSame(['ROLE_TEAM_ADMIN'], $user->getAssignedRoles());
|
||||
}
|
||||
|
||||
public function testUpdateLocalUserGrantsTheTeamerRoleOnlyOnce(): void
|
||||
@@ -327,8 +327,8 @@ class UserDataHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* ROLE_SUPER_ADMIN is not a stored role but a flag getRoles() turns into one, so
|
||||
* revoking ROLE_ADMIN has to take it down explicitly - otherwise the highest privilege
|
||||
* ROLE_TEAM_SUPER_ADMIN is not a stored role but a flag getRoles() turns into one, so
|
||||
* revoking ROLE_TEAM_ADMIN has to take it down explicitly - otherwise the highest privilege
|
||||
* in the application would outlive the role it depends on.
|
||||
*/
|
||||
public function testUpdateLocalUserTakesTheSuperAdminFlagDownWithRoleAdmin(): void
|
||||
@@ -337,7 +337,7 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles(['ROLE_ADMIN', 'ROLE_TEAMER'])
|
||||
->setRoles(['ROLE_TEAM_ADMIN', 'ROLE_TEAMER'])
|
||||
->setSuperAdmin(true)
|
||||
;
|
||||
|
||||
@@ -346,7 +346,7 @@ class UserDataHandlerTest extends TestCase
|
||||
|
||||
$this->assertSame(['ROLE_TEAMER'], $user->getAssignedRoles());
|
||||
$this->assertFalse($user->isSuperAdmin());
|
||||
$this->assertFalse($user->hasRole('ROLE_SUPER_ADMIN'));
|
||||
$this->assertFalse($user->hasRole('ROLE_TEAM_SUPER_ADMIN'));
|
||||
}
|
||||
|
||||
public function testUpdateLocalUserKeepsTheSuperAdminFlagOfAStillClaimedAdmin(): void
|
||||
@@ -355,15 +355,15 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles(['ROLE_ADMIN', 'ROLE_TEAMER'])
|
||||
->setRoles(['ROLE_TEAM_ADMIN', 'ROLE_TEAMER'])
|
||||
->setSuperAdmin(true)
|
||||
;
|
||||
|
||||
$handler = new UserDataHandler($this->entityManager, $this->logger);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), false, [], ['ROLE_ADMIN']);
|
||||
$handler->updateLocalUser($user, $this->createProfileResponse(), false, [], ['ROLE_TEAM_ADMIN']);
|
||||
|
||||
$this->assertTrue($user->isSuperAdmin());
|
||||
$this->assertTrue($user->hasRole('ROLE_SUPER_ADMIN'));
|
||||
$this->assertTrue($user->hasRole('ROLE_TEAM_SUPER_ADMIN'));
|
||||
}
|
||||
|
||||
public function testUpdateLocalUserReplacesTheHotelCodesWithTheOnesTheCrmReports(): void
|
||||
@@ -394,7 +394,7 @@ class UserDataHandlerTest extends TestCase
|
||||
->setEmail('[email protected]')
|
||||
->setRoles([
|
||||
'ROLE_TEAMER',
|
||||
User::PENDING_ROLES['ROLE_ADMIN'],
|
||||
User::PENDING_ROLES['ROLE_TEAM_ADMIN'],
|
||||
User::PENDING_ROLES['ROLE_HOUSE_MANAGER'],
|
||||
])
|
||||
;
|
||||
@@ -403,8 +403,8 @@ class UserDataHandlerTest extends TestCase
|
||||
|
||||
$handler = new UserDataHandler($this->entityManager, $this->logger);
|
||||
|
||||
$this->assertTrue($handler->approveRole($user, 'ROLE_ADMIN'));
|
||||
$this->assertSame(['ROLE_TEAMER', 'ROLE_ADMIN'], $user->getAssignedRoles());
|
||||
$this->assertTrue($handler->approveRole($user, 'ROLE_TEAM_ADMIN'));
|
||||
$this->assertSame(['ROLE_TEAMER', 'ROLE_TEAM_ADMIN'], $user->getAssignedRoles());
|
||||
|
||||
// the other nomination is untouched: one decision at a time
|
||||
$this->assertSame([User::PENDING_ROLES['ROLE_HOUSE_MANAGER']], $user->getPendingRoles());
|
||||
@@ -437,13 +437,13 @@ class UserDataHandlerTest extends TestCase
|
||||
{
|
||||
yield 'the CRM never claimed it' => [['ROLE_TEAMER'], 'ROLE_MANAGER'];
|
||||
|
||||
yield 'a different role is nominated' => [[User::PENDING_ROLES['ROLE_MANAGER']], 'ROLE_ADMIN'];
|
||||
yield 'a different role is nominated' => [[User::PENDING_ROLES['ROLE_MANAGER']], 'ROLE_TEAM_ADMIN'];
|
||||
|
||||
yield 'already granted, so there is no marker left' => [['ROLE_ADMIN'], 'ROLE_ADMIN'];
|
||||
yield 'already granted, so there is no marker left' => [['ROLE_TEAM_ADMIN'], 'ROLE_TEAM_ADMIN'];
|
||||
|
||||
yield 'teamer has no nomination to approve' => [['ROLE_TEAMER'], 'ROLE_TEAMER'];
|
||||
|
||||
yield 'not a role at all' => [[User::PENDING_ROLES['ROLE_ADMIN']], 'ROLE_SUPER_ADMIN'];
|
||||
yield 'not a role at all' => [[User::PENDING_ROLES['ROLE_TEAM_ADMIN']], 'ROLE_TEAM_SUPER_ADMIN'];
|
||||
}
|
||||
|
||||
public function testDisableForRevokedCrmRolesBlocksTheUserAndDropsThePendingMarkers(): void
|
||||
@@ -452,7 +452,7 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles(['ROLE_ADMIN', User::PENDING_ROLES['ROLE_MANAGER']])
|
||||
->setRoles(['ROLE_TEAM_ADMIN', User::PENDING_ROLES['ROLE_MANAGER']])
|
||||
;
|
||||
|
||||
$this->entityManager
|
||||
@@ -468,7 +468,7 @@ class UserDataHandlerTest extends TestCase
|
||||
$this->assertSame('Automatisch gesperrt: keine Rollen in BusPro.', $user->getDisabledReasonInternal());
|
||||
|
||||
// the granted role is kept so the user stays reviewable, the marker is not
|
||||
$this->assertSame(['ROLE_ADMIN'], $user->getAssignedRoles());
|
||||
$this->assertSame(['ROLE_TEAM_ADMIN'], $user->getAssignedRoles());
|
||||
$this->assertSame([], $user->getPendingRoles());
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ class UserDataHandlerTest extends TestCase
|
||||
->setFirstName('First')
|
||||
->setLastName('Last')
|
||||
->setEmail('[email protected]')
|
||||
->setRoles(['ROLE_ADMIN'])
|
||||
->setRoles(['ROLE_TEAM_ADMIN'])
|
||||
->setDisabledAt($disabledAt)
|
||||
->setDisabledReason('Wegen Fehlverhaltens gesperrt.')
|
||||
->setDisabledReasonInternal('Siehe Vorgang 4711.')
|
||||
|
||||
Reference in New Issue
Block a user