public function testLoginSynchronizesInfoAndCallsAuthLogin() { $timezone = 'UTC'; $this->fakeConfig->SetKey(ConfigKeys::DEFAULT_TIMEZONE, $timezone); $languageCode = 'en_US'; $this->fakeConfig->SetKey(ConfigKeys::LANGUAGE, $languageCode); $expectedUser = new AuthenticatedUser($this->username, $this->ldapUser->GetEmail(), $this->ldapUser->GetFirstName(), $this->ldapUser->GetLastName(), $this->password, $languageCode, $timezone, $this->ldapUser->GetPhone(), $this->ldapUser->GetInstitution(), $this->ldapUser->GetTitle()); $auth = new ActiveDirectory($this->fakeAuth, $this->fakeLdap, $this->fakeLdapOptions); $auth->SetRegistration($this->fakeRegistration); $auth->Validate($this->username, $this->password); $auth->Login($this->username, $this->loginContext); $this->assertTrue($this->fakeRegistration->_SynchronizeCalled); $this->assertEquals($expectedUser, $this->fakeRegistration->_LastSynchronizedUser); $this->assertEquals($this->loginContext, $this->fakeAuth->_LastLoginContext); }
private function Synchronize($username) { $registration = $this->GetRegistration(); $userGroups = $this->user->GetGroups(); $groupsToSync = null; if ($userGroups != null) { $lowercaseGroups = array_map('strtolower', $userGroups); $groupsToSync = array(); $groups = $this->GetGroupRepository()->GetList()->Results(); /** @var GroupItemView $group */ foreach ($groups as $group) { if (in_array(strtolower($group->Name()), $lowercaseGroups)) { Log::Debug('ActiveDirectory: Syncing group %s for user %s', $group->Name(), $username); $groupsToSync[] = new UserGroup($group->Id(), $group->Name()); } else { Log::Debug('ActiveDirectory: User %s is not part of group %s, sync skipped', $group->Name(), $username); } } } $registration->Synchronize(new AuthenticatedUser($username, $this->user->GetEmail(), $this->user->GetFirstName(), $this->user->GetLastName(), $this->password, Configuration::Instance()->GetKey(ConfigKeys::LANGUAGE), Configuration::Instance()->GetDefaultTimezone(), $this->user->GetPhone(), $this->user->GetInstitution(), $this->user->GetTitle(), $groupsToSync)); }
private function Synchronize($username) { $registration = $this->GetRegistration(); $registration->Synchronize(new AuthenticatedUser($username, $this->user->GetEmail(), $this->user->GetFirstName(), $this->user->GetLastName(), $this->password, Configuration::Instance()->GetKey(ConfigKeys::LANGUAGE), Configuration::Instance()->GetDefaultTimezone(), $this->user->GetPhone(), $this->user->GetInstitution(), $this->user->GetTitle())); }