summaryrefslogtreecommitdiffstats
path: root/tests/Core
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-10-05 13:06:59 +0200
committerGitHub <noreply@github.com>2021-10-05 13:06:59 +0200
commitd68f0282515cb5122cdbd834217b62079dcad9bc (patch)
tree194113d2fbaef56e5faee18fa3f64b02991e7e66 /tests/Core
parentee32c7c3282407c4cc714dc7e00a374781d9ef56 (diff)
parent1684fd0b6f9a79641f4558ad33c30b185d5d0bd0 (diff)
downloadnextcloud-server-d68f0282515cb5122cdbd834217b62079dcad9bc.tar.gz
nextcloud-server-d68f0282515cb5122cdbd834217b62079dcad9bc.zip
Merge pull request #27733 from PhrozenByte/enhancement/noid/IURLGenerator-linkToDefaultPageUrl
Diffstat (limited to 'tests/Core')
-rw-r--r--tests/Core/Controller/LoginControllerTest.php32
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php7
2 files changed, 25 insertions, 14 deletions
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index e3469621eec..fe42b55db15 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -211,8 +211,12 @@ class LoginControllerTest extends TestCase {
->expects($this->once())
->method('isLoggedIn')
->willReturn(true);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expectedResponse = new RedirectResponse(\OC_Util::getDefaultPageUrl());
+ $expectedResponse = new RedirectResponse('/default/foo');
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}
@@ -443,7 +447,7 @@ class LoginControllerTest extends TestCase {
'direct' => 1,
])
->willReturn($loginPageUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl);
+ $expected = new RedirectResponse($loginPageUrl);
$expected->throttle(['user' => 'MyUserName']);
$response = $this->loginController->tryLogin($user, $password, '/apps/files');
@@ -454,7 +458,6 @@ class LoginControllerTest extends TestCase {
public function testLoginWithValidCredentials() {
$user = 'MyUserName';
$password = 'secret';
- $indexPageUrl = \OC_Util::getDefaultPageUrl();
$this->request
->expects($this->once())
@@ -470,11 +473,13 @@ class LoginControllerTest extends TestCase {
->method('process')
->with($this->equalTo($loginData))
->willReturn($loginResult);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl);
-
- $response = $this->loginController->tryLogin($user, $password);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $this->assertEquals($expected, $response);
+ $expected = new RedirectResponse('/default/foo');
+ $this->assertEquals($expected, $this->loginController->tryLogin($user, $password));
}
public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() {
@@ -498,8 +503,12 @@ class LoginControllerTest extends TestCase {
->method('deleteUserValue');
$this->userSession->expects($this->never())
->method('createRememberMeToken');
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expected = new \OCP\AppFramework\Http\RedirectResponse(\OC_Util::getDefaultPageUrl());
+ $expected = new RedirectResponse('/default/foo');
$this->assertEquals($expected, $this->loginController->tryLogin('Jane', $password, $originalUrl));
}
@@ -534,14 +543,13 @@ class LoginControllerTest extends TestCase {
->with('remember_login_cookie_lifetime')
->willReturn(1234);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($redirectUrl);
+ $expected = new RedirectResponse($redirectUrl);
$this->assertEquals($expected, $this->loginController->tryLogin('Jane', $password, $originalUrl));
}
public function testLoginWithValidCredentialsAndRedirectUrl() {
$user = 'MyUserName';
$password = 'secret';
- $indexPageUrl = \OC_Util::getDefaultPageUrl();
$redirectUrl = 'https://next.cloud/apps/mail';
$this->request
@@ -566,7 +574,7 @@ class LoginControllerTest extends TestCase {
->method('getAbsoluteURL')
->with('/apps/mail')
->willReturn($redirectUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($redirectUrl);
+ $expected = new RedirectResponse($redirectUrl);
$response = $this->loginController->tryLogin($user, $password, '/apps/mail');
@@ -601,7 +609,7 @@ class LoginControllerTest extends TestCase {
'direct' => 1,
])
->willReturn($loginPageUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl);
+ $expected = new RedirectResponse($loginPageUrl);
$expected->throttle(['user' => 'john']);
$response = $this->loginController->tryLogin(
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index b899a1b236a..2cb8d4bd50f 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -25,7 +25,6 @@ namespace Test\Core\Controller;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Authentication\TwoFactorAuth\ProviderSet;
use OC\Core\Controller\TwoFactorChallengeController;
-use OC_Util;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin;
@@ -212,8 +211,12 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('verifyChallenge')
->with('myprovider', $user, 'token')
->willReturn(true);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expected = new RedirectResponse(OC_Util::getDefaultPageUrl());
+ $expected = new RedirectResponse('/default/foo');
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token'));
}