Exemple #1
0
// provide aborting auth provider
$authAbortAfterHello = new AbortAfterHelloAuthProviderClient(["abortafterhello"]);
$router->addTransportProvider(new \Thruway\Transport\InternalClientTransportProvider($authAbortAfterHello));
////////////////////
// Test stuff for Authorization
$authorizationManager = new \Thruway\Authentication\AuthorizationManager('authorizing_realm');
$authorizingRealm = new \Thruway\Realm('authorizing_realm');
$authorizingRealm->setAuthorizationManager($authorizationManager);
$router->getRealmManager()->addRealm($authorizingRealm);
$router->addTransportProvider(new \Thruway\Transport\InternalClientTransportProvider($authorizationManager));
// Create a realm with Authentication also
// to test some stuff
$authAndAuthAuthorizer = new \Thruway\Authentication\AuthorizationManager("authful_realm");
$authAndAuthRealm = new \Thruway\Realm("authful_realm");
$authAndAuthRealm->setAuthorizationManager($authAndAuthAuthorizer);
$authAndAuthRealm->setAuthenticationManager($authMgr);
$router->getRealmManager()->addRealm($authAndAuthRealm);
$router->addTransportProvider(new \Thruway\Transport\InternalClientTransportProvider($authAndAuthAuthorizer));
////////////////////
$transportProvider = new RatchetTransportProvider("127.0.0.1", 8090);
$router->addTransportProvider($transportProvider);
$theInternalClient = new InternalClient('testRealm', $loop);
$theInternalClient->setRouter($router);
$internalTransportProvider = new Thruway\Transport\InternalClientTransportProvider($theInternalClient);
$router->addTransportProvider($internalTransportProvider);
//Client for Disclose Publisher Test
$dpClient = new DisclosePublisherClient('testSimpleAuthRealm', $loop);
$internalTransportProvider = new Thruway\Transport\InternalClientTransportProvider($dpClient);
$router->addTransportProvider($internalTransportProvider);
if ($timeout) {
    $loop->addTimer($timeout, function () use($loop) {
Exemple #2
0
 /**
  * This can only happen in an instance where Welcome is not sent immediately after Hello
  * (when a challenge has been sent)
  */
 public function testJoinSessionTwice()
 {
     $realm = new \Thruway\Realm("realm1");
     $authMgr = $this->getMockBuilder('\\Thruway\\Authentication\\AuthenticationManagerInterface')->getMock();
     $authMgr->expects($this->once())->method("onAuthenticationMessage")->with($this->isInstanceOf('\\Thruway\\Realm'), $this->isInstanceOf('\\Thruway\\Session'), $this->isInstanceOf('\\Thruway\\Message\\HelloMessage'));
     $realm->setAuthenticationManager($authMgr);
     $session = $this->getMockBuilder('\\Thruway\\Session')->disableOriginalConstructor()->setMethods(["sendMessage", "shutdown", "abort"])->getMock();
     $session->expects($this->once())->method("shutdown");
     $realm->onMessage($session, new \Thruway\Message\HelloMessage('realm1', ["roles" => []]));
     $realm->onMessage($session, new \Thruway\Message\HelloMessage('realm1', ["roles" => []]));
     $authMgr->expects($this->once())->method("onSessionClose")->with($this->isInstanceOf('\\Thruway\\Session'));
     $realm->leave($session);
 }