aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-02-07 15:57:14 +0100
committerGitHub <noreply@github.com>2019-02-07 15:57:14 +0100
commit0e9903c420aee76648e61c4c14b750ea01125bb1 (patch)
tree4869d5a2df8054b416103855fe951989aaf03afd /tests
parent6dc21fff45abbb2bde2611a82c746f873389bfd7 (diff)
parentb68567e9ba5b4b081378061bf938b5b505638fb3 (diff)
downloadnextcloud-server-0e9903c420aee76648e61c4c14b750ea01125bb1.tar.gz
nextcloud-server-0e9903c420aee76648e61c4c14b750ea01125bb1.zip
Merge pull request #13969 from nextcloud/enh/additional_scripts_no_on_public_pages
No need to emit additonalscript event on public pages
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php10
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php27
3 files changed, 35 insertions, 8 deletions
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index 9230cfb4af2..eddcc1bbdb9 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -30,7 +30,7 @@ use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Defaults;
use OCP\IL10N;
use OCP\IRequest;
@@ -108,7 +108,7 @@ class ClientFlowLoginControllerTest extends TestCase {
}
public function testShowAuthPickerPageNoClientOrOauthRequest() {
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'error',
[
@@ -166,7 +166,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('getServerProtocol')
->willReturn('https');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'loginflow/authpicker',
[
@@ -225,7 +225,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('getServerProtocol')
->willReturn('https');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'loginflow/authpicker',
[
@@ -253,7 +253,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('remove')
->with('client.flow.state.token');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'403',
[
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index 6a01c510ed2..a405914cc47 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -27,7 +27,7 @@ use OC\Authentication\TwoFactorAuth\ProviderSet;
use OC\Core\Controller\TwoFactorChallengeController;
use OC_Util;
use OCP\AppFramework\Http\RedirectResponse;
-use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\TwoFactorException;
use OCP\IRequest;
@@ -100,7 +100,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
->with($user)
->will($this->returnValue($providerSet));
- $expected = new TemplateResponse('core', 'twofactorselectchallenge', [
+ $expected = new StandaloneTemplateResponse('core', 'twofactorselectchallenge', [
'providers' => [
$p1,
],
@@ -151,7 +151,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('fetchPage')
->will($this->returnValue('<html/>'));
- $expected = new TemplateResponse('core', 'twofactorshowchallenge', [
+ $expected = new StandaloneTemplateResponse('core', 'twofactorshowchallenge', [
'error' => true,
'provider' => $provider,
'backupProvider' => $backupProvider,
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
index 27a6e70c641..7f817e03c1e 100644
--- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
@@ -27,7 +27,9 @@ namespace Test\AppFramework\Middleware;
use OC\AppFramework\Middleware\AdditionalScriptsMiddleware;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\PublicShareController;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -67,6 +69,31 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
$this->middleWare->afterController($this->controller, 'myMethod', $this->createMock(Response::class));
}
+ public function testPublicShareController() {
+ $this->dispatcher->expects($this->never())
+ ->method($this->anything());
+ $this->userSession->expects($this->never())
+ ->method($this->anything());
+
+ $this->middleWare->afterController($this->createMock(PublicShareController::class), 'myMethod', $this->createMock(Response::class));
+ }
+
+ public function testStandaloneTemplateResponse() {
+ $this->dispatcher->expects($this->once())
+ ->method('dispatch')
+ ->willReturnCallback(function($eventName) {
+ if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) {
+ return;
+ }
+
+ $this->fail('Wrong event dispatched');
+ });
+ $this->userSession->expects($this->never())
+ ->method($this->anything());
+
+ $this->middleWare->afterController($this->controller, 'myMethod', $this->createMock(StandaloneTemplateResponse::class));
+ }
+
public function testTemplateResponseNotLoggedIn() {
$this->dispatcher->expects($this->once())
->method('dispatch')