diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-25 21:36:17 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-25 22:03:10 +0200 |
commit | e351ba56f13f82a9d5a8f95ee42f5343a167d5f4 (patch) | |
tree | 2d3c33df8c1114ee976df15ba8fb689e73ff249f /tests | |
parent | d5589a15d5c681bb26cb8717e0e5abdb5021a1b1 (diff) | |
download | nextcloud-server-e351ba56f13f82a9d5a8f95ee42f5343a167d5f4.tar.gz nextcloud-server-e351ba56f13f82a9d5a8f95ee42f5343a167d5f4.zip |
Move browserSupportsCspV3 to CSPNonceManager
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php | 15 | ||||
-rw-r--r-- | tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php | 4 |
2 files changed, 13 insertions, 6 deletions
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index b597317fca4..1fdcf485c28 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -36,6 +36,7 @@ use OC\AppFramework\Middleware\Security\SecurityMiddleware; use OC\AppFramework\Utility\ControllerMethodReflector; use OC\Security\CSP\ContentSecurityPolicy; use OC\Security\CSP\ContentSecurityPolicyManager; +use OC\Security\CSP\ContentSecurityPolicyNonceManager; use OC\Security\CSRF\CsrfToken; use OC\Security\CSRF\CsrfTokenManager; use OCP\AppFramework\Controller; @@ -76,6 +77,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { private $contentSecurityPolicyManager; /** @var CsrfTokenManager|\PHPUnit_Framework_MockObject_MockObject */ private $csrfTokenManager; + /** @var ContentSecurityPolicyNonceManager|\PHPUnit_Framework_MockObject_MockObject */ + private $cspNonceManager; protected function setUp() { parent::setUp(); @@ -88,6 +91,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->request = $this->createMock(IRequest::class); $this->contentSecurityPolicyManager = $this->createMock(ContentSecurityPolicyManager::class); $this->csrfTokenManager = $this->createMock(CsrfTokenManager::class); + $this->cspNonceManager = $this->createMock(ContentSecurityPolicyNonceManager::class); $this->middleware = $this->getMiddleware(true, true); $this->secException = new SecurityException('hey', false); $this->secAjaxException = new SecurityException('hey', true); @@ -109,7 +113,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { $isLoggedIn, $isAdminUser, $this->contentSecurityPolicyManager, - $this->csrfTokenManager + $this->csrfTokenManager, + $this->cspNonceManager ); } @@ -559,9 +564,9 @@ class SecurityMiddlewareTest extends \Test\TestCase { } public function testAfterController() { - $this->request + $this->cspNonceManager ->expects($this->once()) - ->method('isUserAgent') + ->method('browserSupportsCspV3') ->willReturn(false); $response = $this->createMock(Response::class); $defaultPolicy = new ContentSecurityPolicy(); @@ -603,9 +608,9 @@ class SecurityMiddlewareTest extends \Test\TestCase { } public function testAfterControllerWithContentSecurityPolicy3Support() { - $this->request + $this->cspNonceManager ->expects($this->once()) - ->method('isUserAgent') + ->method('browserSupportsCspV3') ->willReturn(true); $token = $this->createMock(CsrfToken::class); $token diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php index 39d24807d5b..3211a5284f8 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php @@ -24,6 +24,7 @@ namespace Test\Security\CSP; use OC\Security\CSP\ContentSecurityPolicyNonceManager; use OC\Security\CSRF\CsrfToken; use OC\Security\CSRF\CsrfTokenManager; +use OCP\IRequest; use Test\TestCase; class ContentSecurityPolicyNonceManagerTest extends TestCase { @@ -35,7 +36,8 @@ class ContentSecurityPolicyNonceManagerTest extends TestCase { public function setUp() { $this->csrfTokenManager = $this->createMock(CsrfTokenManager::class); $this->nonceManager = new ContentSecurityPolicyNonceManager( - $this->csrfTokenManager + $this->csrfTokenManager, + $this->createMock(IRequest::class) ); } |