public function test_createPiwikUserFromLdapUser_CreatesCorrectPiwikUser_WhenCustomLdapAttributesAreUsedAndPresent() { $this->userMapper->setLdapAliasField('testfield1'); $this->userMapper->setLdapUserIdField('testfield2'); $this->userMapper->setLdapMailField('testfield3'); $this->userMapper->setLdapFirstNameField('testfield4'); $this->userMapper->setLdapLastNameField('testfield5'); $this->userMapper->setLdapUserPasswordField('testfield6'); $result = $this->userMapper->createPiwikUserFromLdapUser(array('testfield1' => 'am i bovvered?', 'testfield2' => 'donna', 'testfield3' => '*****@*****.**', 'testfield4' => 'Donna', 'testfield5' => 'Noble', 'testfield6' => 'pass', 'other3' => 'sdlfdsf')); $this->assertEquals(array('login' => 'donna', 'password' => '{LDAP}1a1dc91c907325c69271ddf0c9', 'email' => '*****@*****.**', 'alias' => 'am i bovvered?'), $result); $result = $this->userMapper->createPiwikUserFromLdapUser(array('testfield2' => 'donna', 'testfield3' => '*****@*****.**', 'testfield4' => 'Donna', 'testfield5' => 'Noble', 'testfield6' => 'pass', 'other3' => 'sdlfdsf')); $this->assertEquals(array('login' => 'donna', 'password' => '{LDAP}1a1dc91c907325c69271ddf0c9', 'email' => '*****@*****.**', 'alias' => 'Donna Noble'), $result); }
/** * Creates a UserMapper instance configured using INI options. * * @return UserMapper */ public static function makeConfigured() { $result = new UserMapper(); $uidField = Config::getLdapUserIdField(); if (!empty($uidField)) { $result->setLdapUserIdField($uidField); } $lastNameField = Config::getLdapLastNameField(); if (!empty($lastNameField)) { $result->setLdapLastNameField($lastNameField); } $firstNameField = Config::getLdapFirstNameField(); if (!empty($firstNameField)) { $result->setLdapFirstNameField($firstNameField); } $aliasField = Config::getLdapAliasField(); if (!empty($aliasField)) { $result->setLdapAliasField($aliasField); } $mailField = Config::getLdapMailField(); if (!empty($mailField)) { $result->setLdapMailField($mailField); } $userPasswordField = Config::getLdapPasswordField(); if (!empty($userPasswordField)) { $result->setLdapUserPasswordField($userPasswordField); } $userEmailSuffix = Config::getLdapUserEmailSuffix(); if (!empty($userEmailSuffix)) { $result->setUserEmailSuffix($userEmailSuffix); } $isRandomTokenAuthGenerationEnabled = Config::isRandomTokenAuthGenerationEnabled(); if (!empty($isRandomTokenAuthGenerationEnabled)) { $result->setIsRandomTokenAuthGenerationEnabled($isRandomTokenAuthGenerationEnabled); } $appendUserEmailSuffixToUsername = Config::shouldAppendUserEmailSuffixToUsername(); if (!empty($appendUserEmailSuffixToUsername)) { $result->setAppendUserEmailSuffixToUsername($appendUserEmailSuffixToUsername); } Log::debug("UserMapper::%s: configuring with uidField = %s, aliasField = %s firstNameField = %s, lastNameField = %s" . " mailField = %s, ldapUserPasswordField = %s, userEmailSuffix = %s, isRandomTokenAuthGenerationEnabled = %s", __FUNCTION__, $uidField, $aliasField, $firstNameField, $lastNameField, $mailField, $userPasswordField, $userEmailSuffix, $isRandomTokenAuthGenerationEnabled); return $result; }
/** * Creates a UserMapper instance configured using INI options. * * @return UserMapper */ public static function makeConfigured() { $result = new UserMapper(); $uidField = Config::getLdapUserIdField(); if (!empty($uidField)) { $result->setLdapUserIdField($uidField); } $lastNameField = Config::getLdapLastNameField(); if (!empty($lastNameField)) { $result->setLdapLastNameField($lastNameField); } $firstNameField = Config::getLdapFirstNameField(); if (!empty($firstNameField)) { $result->setLdapFirstNameField($firstNameField); } $aliasField = Config::getLdapAliasField(); if (!empty($aliasField)) { $result->setLdapAliasField($aliasField); } $mailField = Config::getLdapMailField(); if (!empty($mailField)) { $result->setLdapMailField($mailField); } $userPasswordField = Config::getLdapPasswordField(); if (!empty($userPasswordField)) { $result->setLdapUserPasswordField($userPasswordField); } $userEmailSuffix = Config::getLdapUserEmailSuffix(); if (!empty($userEmailSuffix)) { $result->setUserEmailSuffix($userEmailSuffix); } $isRandomTokenAuthGenerationEnabled = Config::isRandomTokenAuthGenerationEnabled(); if (!empty($isRandomTokenAuthGenerationEnabled)) { $result->setIsRandomTokenAuthGenerationEnabled($isRandomTokenAuthGenerationEnabled); } $appendUserEmailSuffixToUsername = Config::shouldAppendUserEmailSuffixToUsername(); if (!empty($appendUserEmailSuffixToUsername)) { $result->setAppendUserEmailSuffixToUsername($appendUserEmailSuffixToUsername); } return $result; }