public function testCreatesOrigins() { $command = $this->client->getCommand('CreateCloudFrontOriginAccessIdentity', array('CallerReference' => 'foo', 'Comment' => 'Hello!')); $result = $command->getResult(); $this->assertInstanceOf('Guzzle\\Service\\Resource\\Model', $result); $result = $result->toArray(); $this->assertArrayHasKey('Id', $result); self::$originId = $result['Id']; $this->assertArrayHasKey('S3CanonicalUserId', $result); $this->assertArrayHasKey('CloudFrontOriginAccessIdentityConfig', $result); $this->assertEquals(array('CallerReference' => 'foo', 'Comment' => 'Hello!'), $result['CloudFrontOriginAccessIdentityConfig']); $this->assertArrayHasKey('Location', $result); $this->assertArrayHasKey('ETag', $result); $this->assertEquals($result['Location'], (string) $command->getResponse()->getHeader('Location')); $this->assertEquals($result['ETag'], (string) $command->getResponse()->getHeader('ETag')); // Ensure that the RequestId model value is being populated correctly $this->assertEquals((string) $command->getResponse()->getHeader('x-amz-request-id'), $result['RequestId']); // Grant CF to read from the bucket $s3 = $this->getServiceBuilder()->get('s3'); $s3->putObjectAcl(array('Bucket' => self::$bucketName, 'Key' => 'foo.txt', 'GrantRead' => 'id="' . $result['S3CanonicalUserId'] . '"')); }