Example #1
0
 public function testErrorsAreParsedCorrectly()
 {
     try {
         $this->client->deleteIdentityPool(array('IdentityPoolId' => 'abc:abc'));
         $this->fail('An exception should have been thrown.');
     } catch (ServiceResponseException $e) {
         $this->assertEquals('ResourceNotFoundException', $e->getExceptionCode(), 'Caught a ' . $e->getExceptionCode() . ' exception instead.');
     }
 }
 public function __invoke()
 {
     return Promise\coroutine(function () {
         $params = $this->logins ? ['Logins' => $this->logins] : [];
         $getIdParams = $params + ['IdentityPoolId' => $this->identityPoolId];
         if ($this->accountId) {
             $getIdParams['AccountId'] = $this->accountId;
         }
         $id = (yield $this->client->getId($getIdParams));
         $result = (yield $this->client->getCredentialsForIdentity(['IdentityId' => $id['IdentityId']] + $params));
         (yield new Credentials($result['Credentials']['AccessKeyId'], $result['Credentials']['SecretKey'], $result['Credentials']['SessionToken'], (int) $result['Credentials']['Expiration']->format('U')));
     });
 }
 public function testThatAssumeRoleWithWebIdentityRequestsDoNotGetSigned()
 {
     $client = CognitoIdentityClient::factory(array('region' => 'us-east-1'));
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200));
     $client->addSubscriber($mock);
     $command = $client->getCommand('GetId', array('AccountId' => '1234567890', 'IdentityPoolId' => 'abc:abc'));
     $request = $command->prepare();
     $command->execute();
     $this->assertFalse($request->hasHeader('Authorization'));
 }
 /**
  * Developer Cognito token (Used for AWS Micro services)
  */
 public function developerToken()
 {
     App::uses('CakeSession', 'Model/Datasource');
     $admin = CakeSession::read('admin_user');
     if (!empty($admin)) {
         if (YOUNIQUE_TESTSERVER === true) {
             if (defined('TEST_AWS_KEY') && defined('TEST_AWS_SECRET')) {
                 $options = ['key' => TEST_AWS_KEY, 'secret' => TEST_AWS_SECRET, 'region' => 'us-east-1'];
             } else {
                 return;
             }
         } else {
             $options = ['region' => 'us-east-1'];
         }
         $client = CognitoIdentityClient::factory($options);
         $result = $client->getOpenIdTokenForDeveloperIdentity(['IdentityPoolId' => "us-east-1:28eb7b2a-b494-4226-bbc6-5fbc059caee7", 'IdentityId' => null, 'Logins' => ['admin.youniqueproducts.com' => $admin->id], 'TokenDuration' => 960]);
         $result = ['identityId' => $result['IdentityId'], 'token' => $result['Token']];
     } else {
         $result = false;
     }
     $this->set(['result' => $result, '_serialize' => ['result']]);
 }