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); }
/** * @group ZF-6130 */ public function testServerShouldCastObjectArgumentsToAppropriateType() { $server = new Server(); $server->addDirectory(dirname(__FILE__) . '/_files/zf-6130/services'); // Create a mock message $message = new RemotingMessage(); $message->operation = 'createEmployee'; $message->source = 'EmployeeService'; // original raw request used "destination" $message->body = array(array('office' => 322, 'departmentid' => 3, 'street' => 32, 'zipcode' => 32, 'state' => 32, 'lastname' => 4, 'firstname' => 2, 'photofile' => 322, 'city' => 32, 'id' => 1, 'title' => 4, 'officephone' => 233, 'email' => 32, 'cellphone' => 22)); $body = new MessageBody(null, "", $message); $request = new Request(); $request->addAmfBody($body); $request->setObjectEncoding(0x3); $response = $server->handle($request); $employee = EmployeeService::$employee; $this->assertNotNull($employee); $this->assertNotEquals(1, $employee->id); $this->assertRegexp('/[a-z0-9]{3,}/', $employee->id); }