public function test_createPiwikUserEntryForLdapUser_UsesExistingPassword_WhenGenerateRandomTokenAuthIsUsed()
 {
     $this->userMapper->setIsRandomTokenAuthGenerationEnabled(true);
     $existingUser = array('login' => 'broken', 'alias' => 'alias', 'email' => 'wrongmail', 'password' => 'existingpass');
     $result = $this->userMapper->createPiwikUserFromLdapUser(array('uid' => 'leela', 'cn' => 'Leela of the Sevateem', 'mail' => 'leela@gallifrey.???', 'userpassword' => 'pass'), $existingUser);
     $this->assertEquals(array('login' => 'leela', 'alias' => 'Leela of the Sevateem', 'password' => 'existingpass', 'email' => 'leela@gallifrey.???'), $result);
 }
Example #2
0
 /**
  * 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;
 }