Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-09-26 21:12:24 +0300
committernpmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>2019-09-28 16:30:34 +0300
commit9e2bb5ef36b686ec619a069c65712f2d57c3a1cc (patch)
treeb912fa5df8344f0bdad80530502a1a42b9b7704b /apps/oauth2/tests
parent17cdcfe4a819708ac7f344d7aca2220a63c40310 (diff)
Move oauth admin settings to initialstate
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
Diffstat (limited to 'apps/oauth2/tests')
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php41
-rw-r--r--apps/oauth2/tests/Settings/AdminTest.php21
2 files changed, 17 insertions, 45 deletions
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 4e4a69c9405..a14d7aad782 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -144,47 +144,6 @@ class SettingsControllerTest extends TestCase {
$this->assertEquals([], $result->getData());
}
- public function testGetClients() {
- $client1 = new Client();
- $client1->setId(123);
- $client1->setName('My Client Name');
- $client1->setRedirectUri('https://example.com/');
- $client1->setSecret('MySecret');
- $client1->setClientIdentifier('MyClientIdentifier');
-
- $client2 = new Client();
- $client2->setId(42);
- $client2->setName('My Client Name2');
- $client2->setRedirectUri('https://example.com/2');
- $client2->setSecret('MySecret2');
- $client2->setClientIdentifier('MyClientIdentifier2');
-
- $this->clientMapper->method('getClients')
- ->willReturn([$client1, $client2]);
-
- $result = $this->settingsController->getClients();
- $this->assertInstanceOf(JSONResponse::class, $result);
-
- $data = $result->getData();
-
- $this->assertSame([
- [
- 'id' => 123,
- 'name' => 'My Client Name',
- 'redirectUri' => 'https://example.com/',
- 'clientId' => 'MyClientIdentifier',
- 'clientSecret' => 'MySecret',
- ],
- [
- 'id' => 42,
- 'name' => 'My Client Name2',
- 'redirectUri' => 'https://example.com/2',
- 'clientId' => 'MyClientIdentifier2',
- 'clientSecret' => 'MySecret2',
- ],
- ], $data);
- }
-
public function testInvalidRedirectUri() {
$result = $this->settingsController->addClient('test', 'invalidurl');
diff --git a/apps/oauth2/tests/Settings/AdminTest.php b/apps/oauth2/tests/Settings/AdminTest.php
index 022ae913e1e..c09a7b3420c 100644
--- a/apps/oauth2/tests/Settings/AdminTest.php
+++ b/apps/oauth2/tests/Settings/AdminTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
*
@@ -21,26 +22,38 @@
namespace OCA\OAuth2\Tests\Settings;
+use OCA\OAuth2\Db\ClientMapper;
use OCA\OAuth2\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IInitialStateService;
use Test\TestCase;
+use PHPUnit\Framework\MockObject\MockObject;
class AdminTest extends TestCase {
- /** @var Admin|\PHPUnit_Framework_MockObject_MockObject */
+
+ /** @var Admin|MockObject */
private $admin;
+ /** @var IInitialStateService|MockObject */
+ private $initialStateService;
+
+ /** @var ClientMapper|MockObject */
+ private $clientMapper;
+
public function setUp() {
parent::setUp();
- $this->admin = new Admin();
+ $this->initialStateService = $this->createMock(IInitialStateService::class);
+ $this->clientMapper = $this->createMock(ClientMapper::class);
+
+ $this->admin = new Admin($this->initialStateService, $this->clientMapper);
}
public function testGetForm() {
$expected = new TemplateResponse(
'oauth2',
'admin',
- [
- ],
+ [],
''
);
$this->assertEquals($expected, $this->admin->getForm());