예제 #1
0
 public function testChangeRecoveryKeyPassword()
 {
     $this->assertFalse($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
     $this->keyManagerMock->expects($this->once())->method('getSystemPrivateKey');
     $this->cryptMock->expects($this->once())->method('decryptPrivateKey');
     $this->cryptMock->expects($this->once())->method('symmetricEncryptFileContent')->willReturn(true);
     $this->assertTrue($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
 }
예제 #2
0
 /**
  * @param string $newPassword
  * @param string $oldPassword
  * @param string $confirmPassword
  * @return DataResponse
  */
 public function changeRecoveryPassword($newPassword, $oldPassword, $confirmPassword)
 {
     //check if both passwords are the same
     if (empty($oldPassword)) {
         $errorMessage = (string) $this->l->t('Please provide the old recovery password');
         return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
     }
     if (empty($newPassword)) {
         $errorMessage = (string) $this->l->t('Please provide a new recovery password');
         return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
     }
     if (empty($confirmPassword)) {
         $errorMessage = (string) $this->l->t('Please repeat the new recovery password');
         return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
     }
     if ($newPassword !== $confirmPassword) {
         $errorMessage = (string) $this->l->t('Repeated recovery key password does not match the provided recovery key password');
         return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
     }
     $result = $this->recovery->changeRecoveryKeyPassword($newPassword, $oldPassword);
     if ($result) {
         return new DataResponse(['data' => ['message' => (string) $this->l->t('Password successfully changed.')]]);
     }
     return new DataResponse(['data' => ['message' => (string) $this->l->t('Could not change the password. Maybe the old password was not correct.')]], Http::STATUS_BAD_REQUEST);
 }
예제 #3
0
파일: RecoveryTest.php 프로젝트: kenwi/core
 public function testChangeRecoveryKeyPasswordCouldNotDecryptPrivateRecoveryKey()
 {
     $this->assertFalse($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
     $this->keyManagerMock->expects($this->once())->method('getSystemPrivateKey');
     $this->cryptMock->expects($this->once())->method('decryptPrivateKey')->will($this->returnValue(false));
     $this->assertFalse($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
 }