Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions plugins/Authentication/Shibboleth/ShibbolethOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function GetShibbolethOptions()
protected function InitShibbolethOptions()
{
$this->_options = [];
$this->SetOption('shibboleth.username', $this->GetConfig(ShibbolethConfigKeys::USERNAME));
$this->SetOption('shibboleth.firstname', $this->GetConfig(ShibbolethConfigKeys::FIRSTNAME));
$this->SetOption('shibboleth.lastname', $this->GetConfig(ShibbolethConfigKeys::LASTNAME));
$this->SetOption('shibboleth.email', $this->GetConfig(ShibbolethConfigKeys::EMAIL));
$this->SetOption('shibboleth.phone', $this->GetConfig(ShibbolethConfigKeys::PHONE));
$this->SetOption('shibboleth.organization', $this->GetConfig(ShibbolethConfigKeys::ORGANIZATION));
$this->SetOption(ShibbolethConfigKeys::USERNAME['key'], $this->GetConfig(ShibbolethConfigKeys::USERNAME));
$this->SetOption(ShibbolethConfigKeys::FIRSTNAME['key'], $this->GetConfig(ShibbolethConfigKeys::FIRSTNAME));
$this->SetOption(ShibbolethConfigKeys::LASTNAME['key'], $this->GetConfig(ShibbolethConfigKeys::LASTNAME));
$this->SetOption(ShibbolethConfigKeys::EMAIL['key'], $this->GetConfig(ShibbolethConfigKeys::EMAIL));
$this->SetOption(ShibbolethConfigKeys::PHONE['key'], $this->GetConfig(ShibbolethConfigKeys::PHONE));
$this->SetOption(ShibbolethConfigKeys::ORGANIZATION['key'], $this->GetConfig(ShibbolethConfigKeys::ORGANIZATION));
}

/**
Expand Down
40 changes: 40 additions & 0 deletions tests/Plugins/Authentication/Shibboleth/ShibbolethUserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

require_once(ROOT_DIR . 'plugins/Authentication/Shibboleth/namespace.php');

class ShibbolethUserTest extends TestBase
{
public function testMapsValuesFromConfiguredServerAttributeKeys()
{
$options = new TestShibbolethOptions();

$user = new ShibbolethUser([
'REMOTE_USER' => 'jdoe',
'givenName' => 'John',
'sn' => 'Doe',
'mail' => 'jdoe@example.com',
'telephone' => '555-1234',
'ou' => 'Engineering',
], $options);

$this->assertEquals('jdoe', $user->GetUsername());
$this->assertEquals('John', $user->GetFirstName());
$this->assertEquals('Doe', $user->GetLastName());
$this->assertEquals('jdoe@example.com', $user->GetEmailAddress());
$this->assertEquals('555-1234', $user->GetPhone());
$this->assertEquals('Engineering', $user->GetOrganization());
}
}

class TestShibbolethOptions extends ShibbolethOptions
{
public function __construct()
{
// Intentionally bypass parent constructor to avoid file I/O in unit tests.
}

protected function GetConfig($configDef, $converter = null)
{
return $configDef['default'] ?? null;
}
}