예제 #1
0
 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;
 }
예제 #2
0
 public function testSetter()
 {
     $s = new Secret();
     $s->setUsername(TEST_API_USERNAME);
     $s->setPassword(TEST_API_PASSWORD);
     $s->setTenantName(TEST_API_TENANT_NAME);
     $s->setTenantId(TEST_API_TENANT_ID);
     $s->setAuthUrl(TEST_IDENTITY_ENDPOINT);
     $this->assertEquals(TEST_API_USERNAME, $s->getUsername());
     $this->assertEquals(TEST_API_PASSWORD, $s->getPassword());
     $this->assertEquals(TEST_API_TENANT_NAME, $s->getTenantName());
     $this->assertEquals(TEST_API_TENANT_ID, $s->getTenantId());
     $this->assertEquals(TEST_IDENTITY_ENDPOINT, $s->getAuthUrl());
 }