diff --git a/plugins/Authentication/Shibboleth/ShibbolethOptions.php b/plugins/Authentication/Shibboleth/ShibbolethOptions.php index 75661f1a3..dbfd9b383 100644 --- a/plugins/Authentication/Shibboleth/ShibbolethOptions.php +++ b/plugins/Authentication/Shibboleth/ShibbolethOptions.php @@ -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)); } /** diff --git a/tests/Plugins/Authentication/Shibboleth/ShibbolethUserTest.php b/tests/Plugins/Authentication/Shibboleth/ShibbolethUserTest.php new file mode 100644 index 000000000..c6653a79d --- /dev/null +++ b/tests/Plugins/Authentication/Shibboleth/ShibbolethUserTest.php @@ -0,0 +1,40 @@ + '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; + } +}