Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 /**
  * Check that when using server->setSession you get an amf header that has an append to gateway sessionID
  * @group ZF-5381
  */
 public function testSessionAmf3()
 {
     \fproject\amf\session\Session::$_unitTestEnabled = true;
     \fproject\amf\session\Session::start();
     $this->_server->setClass('Zend_Amf_testSession');
     $this->_server->setSession();
     // create a mock remoting message
     $message = new RemotingMessage();
     $message->operation = 'getCount';
     $message->source = 'Zend_Amf_testSession';
     $message->body = array();
     // 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
     $result = $this->_server->handle($request);
     $response = $this->_server->getResponse();
     $responseBody = $response->getAmfBodies();
     // Now check if the return data was properly set.
     $acknowledgeMessage = $responseBody[0]->getData();
     // check that we have a message beening returned
     $this->assertEquals(1, $acknowledgeMessage->body);
     // check that a header is being returned for the session id
     $headerBody = $response->getAmfHeaders();
     $this->assertEquals('AppendToGatewayUrl', $headerBody[0]->name);
     // Do not stop session since it still can be used by other tests
     // \fproject\amf\session\Session::stop();
 }