Fix several minor things
This commit is contained in:
parent
d0a6fb1f2c
commit
3f96662609
|
@ -19,14 +19,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace OCA\Encryption\Controller;
|
namespace OCA\Encryption\Controller;
|
||||||
|
|
||||||
|
|
||||||
use OCA\Encryption\Crypto\Crypt;
|
use OCA\Encryption\Crypto\Crypt;
|
||||||
use OCA\Encryption\KeyManager;
|
use OCA\Encryption\KeyManager;
|
||||||
use OCA\Encryption\Session;
|
use OCA\Encryption\Session;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
@ -110,31 +109,28 @@ class SettingsController extends Controller {
|
||||||
$result = true;
|
$result = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = false;
|
$errorMessage = $this->l->t('The old password was not correct, please try again.');
|
||||||
$errorMessage = $this->l->t(
|
|
||||||
'The old password was not correct, please try again.');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = false;
|
$errorMessage = $this->l->t('The current log-in password was not correct, please try again.');
|
||||||
$errorMessage = $this->l->t(
|
|
||||||
'The current log-in password was not correct, please try again.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$this->session->setStatus(Session::INIT_SUCCESSFUL);
|
$this->session->setStatus(Session::INIT_SUCCESSFUL);
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
array(
|
['data' => [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => array(
|
'message' => (string) $this->l->t('Private key password successfully updated.'),
|
||||||
'message' => (string) $this->l->t('Private key password successfully updated.'))
|
],
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
array(
|
['data' => [
|
||||||
'data' => array
|
'message' => (string) $errorMessage,
|
||||||
('message' => (string) $errorMessage)
|
],
|
||||||
)
|
],
|
||||||
|
Http::STATUS_BAD_REQUEST
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,11 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace OCA\Encryption\Tests\Controller;
|
namespace OCA\Encryption\Tests\Controller;
|
||||||
|
|
||||||
|
|
||||||
use OCA\Encryption\Controller\SettingsController;
|
use OCA\Encryption\Controller\SettingsController;
|
||||||
use OCA\Encryption\Session;
|
use OCA\Encryption\Session;
|
||||||
|
use OCP\AppFramework\Http;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class SettingsControllerTest extends TestCase {
|
class SettingsControllerTest extends TestCase {
|
||||||
|
@ -53,7 +52,7 @@ class SettingsControllerTest extends TestCase {
|
||||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $sessionMock;
|
private $sessionMock;
|
||||||
|
|
||||||
public function setUp() {
|
protected function setUp() {
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -65,7 +64,8 @@ class SettingsControllerTest extends TestCase {
|
||||||
$this->l10nMock->expects($this->any())
|
$this->l10nMock->expects($this->any())
|
||||||
->method('t')
|
->method('t')
|
||||||
->will($this->returnCallback(function($message) {
|
->will($this->returnCallback(function($message) {
|
||||||
return $message; }));
|
return $message;
|
||||||
|
}));
|
||||||
|
|
||||||
$this->userManagerMock = $this->getMockBuilder('OCP\IUserManager')
|
$this->userManagerMock = $this->getMockBuilder('OCP\IUserManager')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
|
@ -85,7 +85,7 @@ class SettingsControllerTest extends TestCase {
|
||||||
'logout',
|
'logout',
|
||||||
'setUser',
|
'setUser',
|
||||||
'getUser',
|
'getUser',
|
||||||
'canChangePassword'
|
'canChangePassword',
|
||||||
])
|
])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ class SettingsControllerTest extends TestCase {
|
||||||
|
|
||||||
$data = $result->getData();
|
$data = $result->getData();
|
||||||
|
|
||||||
|
$this->assertSame(Http::STATUS_BAD_REQUEST, $result->getStatus());
|
||||||
$this->assertSame('The current log-in password was not correct, please try again.',
|
$this->assertSame('The current log-in password was not correct, please try again.',
|
||||||
$data['data']['message']);
|
$data['data']['message']);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +156,7 @@ class SettingsControllerTest extends TestCase {
|
||||||
|
|
||||||
$data = $result->getData();
|
$data = $result->getData();
|
||||||
|
|
||||||
|
$this->assertSame(Http::STATUS_BAD_REQUEST, $result->getStatus());
|
||||||
$this->assertSame('The old password was not correct, please try again.',
|
$this->assertSame('The old password was not correct, please try again.',
|
||||||
$data['data']['message']);
|
$data['data']['message']);
|
||||||
}
|
}
|
||||||
|
@ -212,8 +214,7 @@ class SettingsControllerTest extends TestCase {
|
||||||
|
|
||||||
$data = $result->getData();
|
$data = $result->getData();
|
||||||
|
|
||||||
$this->assertSame('success', $data['status']);
|
$this->assertSame(Http::STATUS_OK, $result->getStatus());
|
||||||
|
|
||||||
$this->assertSame('Private key password successfully updated.',
|
$this->assertSame('Private key password successfully updated.',
|
||||||
$data['data']['message']);
|
$data['data']['message']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue