Exemplo n.º 1
0
 /**
  * @param Token $token
  *
  * @throws TokenException
  *
  * @return string
  */
 private function getEndpointUrlFromToken(Token $token)
 {
     $catalog = $token->getServiceCatalog($this->tenant->getServiceType(), $this->tenant->getServiceName());
     // use the first endpoint that has was requested
     $endpointType = $this->tenant->getServiceEndpoint() . 'url';
     foreach ($catalog as $endpoint) {
         $endpoint = array_change_key_case($endpoint, CASE_LOWER);
         if (array_key_exists($endpointType, $endpoint)) {
             return $endpoint[$endpointType];
         }
     }
     throw new TokenException('No endpoint with a ' . $this->tenant->getServiceEndpoint() . ' url found');
 }
Exemplo n.º 2
0
 /**
  * @test
  * @expectedException \TreeHouse\Keystone\Client\Exception\TokenException
  */
 public function it_throws_exception_on_undefined_service_catalog_name()
 {
     $token = new Token(uniqid(), new \DateTime('+ 1 minute'));
     $token->addServiceCatalog('compute', 'test', [['adminurl' => 'https://admin.example.org', 'publicurl' => 'https://example.org']]);
     $token->getServiceCatalog('compute', 'api');
 }