예제 #1
0
    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);
    }
예제 #2
0
파일: AuthTest.php 프로젝트: jsnshrmn/Suma
 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 indexAction()
	{			
		$acl = new Zend_Acl();
		$acl->addRole(new Zend_Acl_Role('administrator'));
		Zend_Session::regenerateId();
		
		$server = new Zend_Amf_Server();
		
		//set amf server session namespace
		$server->setSession();
		$server->setProduction(false);
		$server->setAcl($acl);
		
		//set service root directory
		$server->addDirectory(realpath(dirname(__FILE__) . '/../services/amf/'));
		
		echo($server->handle());
	}