From 4ced59868ad4e238e1481d3f4f8ea357f343bf97 Mon Sep 17 00:00:00 2001 From: joelmoss Date: Fri, 18 Apr 2008 13:25:47 +0000 Subject: [PATCH] Adding test cases for additional require methods or the remaining HTTP verbs/methods. Refs #4231 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6698 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../controller/components/security.test.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index 014f67b04..32a3a80d2 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -65,6 +65,46 @@ class SecurityComponentTest extends CakeTestCase { $this->assertTrue($this->Controller->Session->check('_Token')); } + function testRequirePost() + { + $this->Controller->action = 'posted'; + $this->Controller->Security->startup($this->Controller); + $this->Controller->Security->requirePost('posted'); + $this->assertNull($this->Controller->Security->__postRequired($this->Controller)); + $_SERVER['REQUEST_METHOD'] = 'POST'; + $this->assertTrue($this->Controller->Security->__postRequired($this->Controller)); + } + + function testRequireGet() + { + $this->Controller->action = 'getted'; + $this->Controller->Security->startup($this->Controller); + $this->Controller->Security->requireGet('getted'); + $this->assertNull($this->Controller->Security->__getRequired($this->Controller)); + $_SERVER['REQUEST_METHOD'] = 'GET'; + $this->assertTrue($this->Controller->Security->__getRequired($this->Controller)); + } + + function testRequirePut() + { + $this->Controller->action = 'putted'; + $this->Controller->Security->startup($this->Controller); + $this->Controller->Security->requirePut('putted'); + $this->assertNull($this->Controller->Security->__putRequired($this->Controller)); + $_SERVER['REQUEST_METHOD'] = 'PUT'; + $this->assertTrue($this->Controller->Security->__putRequired($this->Controller)); + } + + function testRequireDelete() + { + $this->Controller->action = 'deleted'; + $this->Controller->Security->startup($this->Controller); + $this->Controller->Security->requireDelete('deleted'); + $this->assertNull($this->Controller->Security->__deleteRequired($this->Controller)); + $_SERVER['REQUEST_METHOD'] = 'DELETE'; + $this->assertTrue($this->Controller->Security->__deleteRequired($this->Controller)); + } + function testValidatePostNoModel() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key'];