Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Add strict types and fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Mar 13, 2018
1 parent eee72c6 commit 2c8b6f6
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion lib/Activity/Provider.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

declare(strict_types = 1);

/**
* @author Christoph Wurst <[email protected]>
* @copyright Copyright (c) 2016 Christoph Wurst <[email protected]>
* @copyright Copyright (c) 2018 Christoph Wurst <[email protected]>
*
* Two-factor U2F
*
Expand Down
4 changes: 3 additions & 1 deletion lib/Activity/Setting.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

declare(strict_types = 1);

/**
* @author Christoph Wurst <[email protected]>
* @copyright Copyright (c) 2016 Christoph Wurst <[email protected]>
* @copyright Copyright (c) 2018 Christoph Wurst <[email protected]>
*
* Two-factor U2F
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* Nextcloud - U2F 2FA
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Db/Registration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* Nextcloud - U2F 2FA
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Db/RegistrationMapper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* Nextcloud - U2F 2FA
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Provider/U2FProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* Nextcloud - U2F 2FA
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/U2FManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* Nextcloud - U2F 2FA
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* @author Christoph Wurst <[email protected]>
*
Expand Down
16 changes: 10 additions & 6 deletions tests/Unit/Controller/SettingsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use OCA\TwoFactorU2F\Controller\SettingsController;
use OCA\TwoFactorU2F\Service\U2FManager;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
Expand Down Expand Up @@ -64,10 +65,10 @@ public function testState() {
->with($this->equalTo($user))
->willReturn($devices);

$expected = [
$expected = new JSONResponse([
'devices' => $devices,
];
$this->assertSame($expected, $this->controller->state());
]);
$this->assertEquals($expected, $this->controller->state());
}

public function testStartRegister() {
Expand All @@ -81,7 +82,7 @@ public function testStartRegister() {
->with($this->equalTo($user))
->willReturn([]);

$this->assertEquals([], $this->controller->startRegister());
$this->assertEquals(new JSONResponse([]), $this->controller->startRegister());
}

public function testFinishRegister() {
Expand All @@ -94,9 +95,12 @@ public function testFinishRegister() {

$this->u2fManager->expects($this->once())
->method('finishRegistration')
->with($this->equalTo($user), $this->equalTo($registrationData), $this->equalTo($data));
->with($this->equalTo($user), $this->equalTo($registrationData), $this->equalTo($data))
->willReturn([]);

$resp = $this->controller->finishRegister($registrationData, $data);

$this->controller->finishRegister($registrationData, $data);
$this->assertEquals(new JSONResponse([]), $resp);
}

}
15 changes: 0 additions & 15 deletions tests/Unit/Service/U2FManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,4 @@ public function testStartRegistrationFirstDevice() {
$this->manager->startRegistration($user);
}

public function testFinishRegistration() {
// TODO: get a grasp of how the u2f lib works and feed it with
// realistic data or mock it.
}

public function testStartAuthenticate() {
// TODO: get a grasp of how the u2f lib works and feed it with
// realistic data or mock it.
}

public function testFinishAuthenticate() {
// TODO: get a grasp of how the u2f lib works and feed it with
// realistic data or mock it.
}

}

0 comments on commit 2c8b6f6

Please sign in to comment.