mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 11:48:49 +02:00
Allow to select the priority of SAML role mapping based on the order in the configuration option
This commit is contained in:
parent
bbe4de996a
commit
8fad743e85
4 changed files with 22 additions and 10 deletions
|
@ -66,18 +66,20 @@ class SamlUserFactoryTest extends WebTestCase
|
|||
public function testMapSAMLRolesToLocalGroupID()
|
||||
{
|
||||
$mapping = [
|
||||
'admin' => 2, //This comes first, as this should have higher priority
|
||||
'employee' => 1,
|
||||
'admin' => 2,
|
||||
'manager' => 3,
|
||||
'administrator' => 2,
|
||||
'*' => 4,
|
||||
];
|
||||
|
||||
//Test if mapping works
|
||||
$this->assertEquals(1, $this->service->mapSAMLRolesToLocalGroupID(['employee'], $mapping));
|
||||
$this->assertSame(1, $this->service->mapSAMLRolesToLocalGroupID(['employee'], $mapping));
|
||||
//Only the first valid mapping should be used
|
||||
$this->assertEquals(1, $this->service->mapSAMLRolesToLocalGroupID(['employee', 'admin'], $mapping));
|
||||
$this->assertSame(2, $this->service->mapSAMLRolesToLocalGroupID(['employee', 'admin'], $mapping));
|
||||
$this->assertSame(2, $this->service->mapSAMLRolesToLocalGroupID(['does_not_matter', 'admin', 'employee'], $mapping));
|
||||
$this->assertSame(1, $this->service->mapSAMLRolesToLocalGroupID(['employee', 'does_not_matter', 'manager'], $mapping));
|
||||
$this->assertSame(3, $this->service->mapSAMLRolesToLocalGroupID(['administrator', 'does_not_matter', 'manager'], $mapping));
|
||||
//Test if mapping is case sensitive
|
||||
$this->assertEquals(4, $this->service->mapSAMLRolesToLocalGroupID(['ADMIN'], $mapping));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue