protected function _callService($method, $class = 'Zend_Amf_Resource_testclass') { $request = new Request(); $request->setObjectEncoding(0x3); $this->_server->setClass($class); $newBody = new MessageBody("{$class}.{$method}", "/1", array("test")); $request->addAmfBody($newBody); $this->_server->handle($request); $response = $this->_server->getResponse(); return $response; }
public function testLogout() { \fproject\amf\session\Session::$_unitTestEnabled = true; $this->_server->setAuth(new RightPassword("testuser", "testrole")); $this->_acl->addRole(new \fproject\amf\acl\Role("testrole")); $this->_acl->allow("testrole", null, null); $this->_server->setAcl($this->_acl); $resp = $this->_callServiceAuth("testuser", ""); $this->assertTrue($resp[0]->getData() instanceof 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 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 AcknowledgeMessage); $data = $resp[1]->getData(); $this->assertTrue($data instanceof ErrorMessage); $this->assertContains("not allowed", $data->faultString); }
public function testCtorExcection() { $this->_server->setClass('Zend_Amf_testException'); $this->_server->setProduction(false); $message = new RemotingMessage(); $message->operation = 'hello'; $message->source = 'Zend_Amf_testException'; $message->body = array("123"); // create a mock message body to place th remoting message inside $newBody = new MessageBody(null, "/1", $message); $request = new Request(); // at the requested service to a request $request->addAmfBody($newBody); $request->setObjectEncoding(0x3); // let the server handle mock request $this->_server->handle($request); $response = $this->_server->getResponse()->getAMFBodies(); $this->assertTrue($response[0]->getData() instanceof ErrorMessage); $this->assertContains("Oops, exception!", $response[0]->getData()->faultString); }