mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Use Member::actAs rather than setting and unsetting member
This commit is contained in:
parent
6b618b44c9
commit
fe5b431200
@ -179,15 +179,15 @@ class ControllerTest extends FunctionalTest
|
||||
'Access denied on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention'
|
||||
);
|
||||
|
||||
Security::setCurrentUser($adminUser);
|
||||
$response = $this->get("AccessSecuredController/templateaction");
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
'Access granted for logged in admin on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention'
|
||||
);
|
||||
Member::actAs($adminUser, function () {
|
||||
$response = $this->get("AccessSecuredController/templateaction");
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
'Access granted for logged in admin on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention'
|
||||
);
|
||||
});
|
||||
|
||||
Security::setCurrentUser(null);
|
||||
$response = $this->get("AccessSecuredController/adminonly");
|
||||
$this->assertEquals(
|
||||
403,
|
||||
@ -209,15 +209,15 @@ class ControllerTest extends FunctionalTest
|
||||
"Access denied to protected method even if its listed in allowed_actions"
|
||||
);
|
||||
|
||||
Security::setCurrentUser($adminUser);
|
||||
$response = $this->get("AccessSecuredController/adminonly");
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
"Permission codes are respected when set in \$allowed_actions"
|
||||
);
|
||||
Member::actAs($adminUser, function () {
|
||||
$response = $this->get("AccessSecuredController/adminonly");
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
"Permission codes are respected when set in \$allowed_actions"
|
||||
);
|
||||
});
|
||||
|
||||
Security::setCurrentUser(null);
|
||||
$response = $this->get('AccessBaseController/extensionmethod1');
|
||||
$this->assertEquals(
|
||||
200,
|
||||
@ -253,14 +253,14 @@ class ControllerTest extends FunctionalTest
|
||||
"Access denied when index action is limited through allowed_actions, " . "and doesn't satisfy checks"
|
||||
);
|
||||
|
||||
Security::setCurrentUser($adminUser);
|
||||
$response = $this->get('IndexSecuredController/');
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
"Access granted when index action is limited through allowed_actions, " . "and does satisfy checks"
|
||||
);
|
||||
Security::setCurrentUser(null);
|
||||
Member::actAs($adminUser, function () {
|
||||
$response = $this->get('IndexSecuredController/');
|
||||
$this->assertEquals(
|
||||
200,
|
||||
$response->getStatusCode(),
|
||||
"Access granted when index action is limited through allowed_actions, " . "and does satisfy checks"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user