Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Made login form redirection test in SecurityTest explicit, rath…

…er than implicit through testLogInAsSomeoneElse()
  • Loading branch information...
commit 65e7b8342159f0ad0e659f5aae9f68a1a6f9d8db 1 parent 519f062
@chillu chillu authored
Showing with 23 additions and 1 deletion.
  1. +23 −1 tests/security/SecurityTest.php
View
24 tests/security/SecurityTest.php
@@ -52,6 +52,21 @@ function tearDown() {
parent::tearDown();
}
+ function testAccessingAuthenticatedPageRedirectsToLoginForm() {
+ $this->autoFollowRedirection = false;
+
+ $response = $this->get('SecurityTest_SecuredController');
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertContains('Security/login', $response->getHeader('Location'));
+
+ $this->logInWithPermission('ADMIN');
+ $response = $this->get('SecurityTest_SecuredController');
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertContains('Success', $response->getBody());
+
+ $this->autoFollowRedirection = true;
+ }
+
function testLogInAsSomeoneElse() {
$member = DataObject::get_one('Member');
@@ -408,4 +423,11 @@ function loginErrorMessage() {
}
}
-?>
+
+class SecurityTest_SecuredController extends Controller implements TestOnly {
+ function index() {
+ if(!Permission::check('ADMIN')) return Security::permissionFailure($this);
+
+ return 'Success';
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.