protected function _callService($method, $class = 'ZendTest\\AMF\\TestAsset\\testclass') { $request = new \Zend\AMF\Request\StreamRequest(); $request->setObjectEncoding(0x3); $this->_server->setClass($class); $newBody = new \Zend\AMF\Value\MessageBody("{$class}.{$method}", "/1", array("test")); $request->addAmfBody($newBody); $this->_server->handle($request); $response = $this->_server->getResponse(); return $response; }
protected function _callService($method, $class = 'Zend_Amf_Resource_testclass') { $request = new Zend_Amf_Request(); $request->setObjectEncoding(0x3); $this->_server->setClass($class); $newBody = new Zend_Amf_Value_MessageBody("{$class}.{$method}", "/1", array("test")); $request->addAmfBody($newBody); $this->_server->handle($request); $response = $this->_server->getResponse(); return $response; }
public function testLogout() { Zend_Session::$_unitTestEnabled = true; $this->_server->setAuth(new RightPassword("testuser", "testrole")); $this->_acl->addRole(new Zend_Acl_Role("testrole")); $this->_acl->allow("testrole", null, null); $this->_server->setAcl($this->_acl); $resp = $this->_callServiceAuth("testuser", ""); $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage); $this->assertContains("hello", $resp[1]->getData()); // After logout same request should not be allowed $this->setUp(); $this->_server->setAuth(new RightPassword("testuser", "testrole")); $this->_server->setAcl($this->_acl); $request = new Zend_Amf_Request(); $request->setObjectEncoding(0x3); $this->_addLogout($request); $this->_addServiceCall($request); $this->_server->handle($request); $resp = $this->_server->getResponse()->getAmfBodies(); $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage); $data = $resp[1]->getData(); $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage); $this->assertContains("not allowed", $data->faultString); }
public function testLogout() { $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole")); $this->_acl->addRole(new Role\GenericRole("testrole")); $this->_acl->allow("testrole", null, null); $this->_server->setAcl($this->_acl); $resp = $this->_callServiceAuth("testuser", ""); $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage); $this->assertContains("hello", $resp[1]->getData()); // After logout same request should not be allowed $this->setUp(); $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole")); $this->_server->setAcl($this->_acl); $request = new Request\StreamRequest(); $request->setObjectEncoding(0x03); $this->_addLogout($request); $this->_addServiceCall($request); $this->_server->handle($request); $resp = $this->_server->getResponse()->getAmfBodies(); $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage); $data = $resp[1]->getData(); $this->assertTrue($data instanceof Messaging\ErrorMessage); $this->assertContains("not allowed", $data->faultString); }