Exemplo n.º 1
0
 public function testSetupServerSide()
 {
     $this->keyManagerMock->expects($this->exactly(2))->method('userHasKeys')->with('admin')->willReturnOnConsecutiveCalls(true, false);
     $this->assertTrue($this->instance->setupServerSide('admin', 'password'));
     $this->keyManagerMock->expects($this->once())->method('storeKeyPair')->with('admin', 'password')->willReturn(false);
     $this->assertFalse($this->instance->setupServerSide('admin', 'password'));
 }
Exemplo n.º 2
0
 /**
  * @dataProvider dataTestSetupUser
  *
  * @param bool $hasKeys
  * @param bool $expected
  */
 public function testSetupUser($hasKeys, $expected)
 {
     $this->keyManagerMock->expects($this->once())->method('userHasKeys')->with('uid')->willReturn($hasKeys);
     if ($hasKeys) {
         $this->keyManagerMock->expects($this->never())->method('storeKeyPair');
     } else {
         $this->cryptMock->expects($this->once())->method('createKeyPair')->willReturn('keyPair');
         $this->keyManagerMock->expects($this->once())->method('storeKeyPair')->with('uid', 'password', 'keyPair')->willReturn(true);
     }
     $this->assertSame($expected, $this->instance->setupUser('uid', 'password'));
 }
Exemplo n.º 3
0
 /**
  * create key-pair for every user
  */
 protected function createKeyPairs()
 {
     $this->output->writeln("\n");
     $progress = new ProgressBar($this->output);
     $progress->setFormat(" %message% \n [%bar%]");
     $progress->start();
     foreach ($this->userManager->getBackends() as $backend) {
         $limit = 500;
         $offset = 0;
         do {
             $users = $backend->getUsers('', $limit, $offset);
             foreach ($users as $user) {
                 if ($this->keyManager->userHasKeys($user) === false) {
                     $progress->setMessage('Create key-pair for ' . $user);
                     $progress->advance();
                     $this->setupUserFS($user);
                     $password = $this->generateOneTimePassword($user);
                     $this->userSetup->setupUser($user, $password);
                 } else {
                     // users which already have a key-pair will be stored with a
                     // empty password and filtered out later
                     $this->userPasswords[$user] = '';
                 }
             }
             $offset += $limit;
         } while (count($users) >= $limit);
     }
     $progress->setMessage('Key-pair created for all users');
     $progress->finish();
 }
Exemplo n.º 4
0
 /**
  * after password reset we create a new key pair for the user
  *
  * @param array $params
  */
 public function postPasswordReset($params)
 {
     $password = $params['password'];
     $this->keyManager->replaceUserKeys($params['uid']);
     $this->userSetup->setupServerSide($params['uid'], $password);
 }
Exemplo n.º 5
0
 /**
  * after password reset we create a new key pair for the user
  *
  * @param array $params
  */
 public function postPasswordReset($params)
 {
     $password = $params['password'];
     $this->keyManager->deleteUserKeys($params['uid']);
     $this->userSetup->setupUser($params['uid'], $password);
 }