public function auth(Secret $secret) { $endpoint = $secret->getAuthUrl(); $ident = $this->getIdentityService($endpoint); $this->access = $ident->tokens($secret); return $this->access; }
public function tokens(Secret $secret) { $version = $this->getStableVersion(); if (!$version) { throw new ServiceNotFoundException('Stable version identity service is not found.'); } $auth = ['auth' => ['passwordCredentials' => ['username' => $secret->getUsername(), 'password' => $secret->getPassword()], 'tenantName' => $secret->getTenantName()]]; $json = json_encode($auth); $res = $this->getClient()->post($this->getUri([$version->getId(), 'tokens']), ['body' => $json]); $access = new Access(); $access->populate($res->getJson()); return $access; }
function __get_test_access() { static $access; if (!$access) { $secret = new Secret(); $secret->setUsername(TEST_API_USERNAME); $secret->setPassword(TEST_API_PASSWORD); $secret->setTenantName(TEST_API_TENANT_NAME); $secret->setTenantId(TEST_API_TENANT_ID); $secret->setAuthUrl(TEST_IDENTITY_ENDPOINT); $c = new ConoHa(); $access = $c->auth($secret); } return $access; }
/** * @expectedException ConoHa\Exception\IncorrectUrlException */ public function testInvalidUrl() { $s = new Secret(); $s->setAuthUrl("invalid url"); }