Add canRename & name to tests

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2019-01-20 21:30:51 +01:00
parent 86f0f867ec
commit db49e0fdae
No known key found for this signature in database
GPG Key ID: 36E3664E099D0614
2 changed files with 9 additions and 5 deletions

View File

@ -118,6 +118,7 @@ class AuthSettingsController extends Controller {
$data['canRename'] = $token instanceof DefaultToken || $token instanceof PublicKeyToken;
if ($sessionToken->getId() === $token->getId()) {
$data['canDelete'] = false;
$data['canRename'] = false;
$data['current'] = true;
}
return $data;
@ -155,6 +156,7 @@ class AuthSettingsController extends Controller {
$deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN);
$tokenData = $deviceToken->jsonSerialize();
$tokenData['canDelete'] = true;
$tokenData['canRename'] = true;
$this->publishActivity(Provider::APP_TOKEN_CREATED, $deviceToken->getId(), $deviceToken->getName());

View File

@ -109,7 +109,8 @@ class AuthSettingsControllerTest extends TestCase {
'type' => 0,
'canDelete' => false,
'current' => true,
'scope' => ['filesystem' => true]
'scope' => ['filesystem' => true],
'canRename' => true,
],
[
'id' => 200,
@ -117,7 +118,8 @@ class AuthSettingsControllerTest extends TestCase {
'lastActivity' => 0,
'type' => 0,
'canDelete' => true,
'scope' => ['filesystem' => true]
'scope' => ['filesystem' => true],
'canRename' => true,
]
], $this->controller->index());
}
@ -260,7 +262,7 @@ class AuthSettingsControllerTest extends TestCase {
->method('updateToken')
->with($this->equalTo($token));
$this->assertSame([], $this->controller->update($tokenId, ['filesystem' => true]));
$this->assertSame([], $this->controller->update($tokenId, ['filesystem' => true], 'App password'));
}
public function testUpdateTokenWrongUser() {
@ -278,7 +280,7 @@ class AuthSettingsControllerTest extends TestCase {
$this->tokenProvider->expects($this->never())
->method('updateToken');
$response = $this->controller->update($tokenId, ['filesystem' => true]);
$response = $this->controller->update($tokenId, ['filesystem' => true], 'App password');
$this->assertSame([], $response->getData());
$this->assertSame(\OCP\AppFramework\Http::STATUS_NOT_FOUND, $response->getStatus());
}
@ -292,7 +294,7 @@ class AuthSettingsControllerTest extends TestCase {
$this->tokenProvider->expects($this->never())
->method('updateToken');
$response = $this->controller->update(42, ['filesystem' => true]);
$response = $this->controller->update(42, ['filesystem' => true], 'App password');
$this->assertSame([], $response->getData());
$this->assertSame(\OCP\AppFramework\Http::STATUS_NOT_FOUND, $response->getStatus());
}