예제 #1
0
 public function setUp()
 {
     $this->bucket = self::getResourcePrefix() . '-s3-test';
     $this->client = $this->getServiceBuilder()->get('s3', true);
     //$this->client->addSubscriber(\Guzzle\Plugin\Log\LogPlugin::getDebugPlugin());
     //$this->client->addSubscriber(\Guzzle\Plugin\Log\LogPlugin::getDebugPlugin());
     $this->acp = AcpBuilder::newInstance()->setOwner(self::$ownerId, self::$displayName)->addGrantForGroup(Permission::READ, Group::AUTHENTICATED_USERS)->addGrantForGroup(Permission::READ_ACP, Group::ALL_USERS)->build();
 }
예제 #2
0
파일: Acp.php 프로젝트: loulancn/core
 /**
  * Create an Acp object from an array. This can be used to create an ACP from a response to a GetObject/Bucket ACL
  * operation.
  *
  * @param array $data Array of ACP data
  *
  * @return Acp
  */
 public static function fromArray(array $data)
 {
     $builder = new AcpBuilder();
     $builder->setOwner((string) $data['Owner']['ID'], $data['Owner']['DisplayName']);
     // Add each Grantee to the ACP
     foreach ($data['Grants'] as $grant) {
         $permission = $grant['Permission'];
         // Determine the type for response bodies that are missing the Type parameter
         if (!isset($grant['Grantee']['Type'])) {
             if (isset($grant['Grantee']['ID'])) {
                 $grant['Grantee']['Type'] = 'CanonicalUser';
             } elseif (isset($grant['Grantee']['URI'])) {
                 $grant['Grantee']['Type'] = 'Group';
             } else {
                 $grant['Grantee']['Type'] = 'AmazonCustomerByEmail';
             }
         }
         switch ($grant['Grantee']['Type']) {
             case 'Group':
                 $builder->addGrantForGroup($permission, $grant['Grantee']['URI']);
                 break;
             case 'AmazonCustomerByEmail':
                 $builder->addGrantForEmail($permission, $grant['Grantee']['EmailAddress']);
                 break;
             case 'CanonicalUser':
                 $builder->addGrantForUser($permission, $grant['Grantee']['ID'], $grant['Grantee']['DisplayName']);
         }
     }
     return $builder->build();
 }
 public function testCanSetAcpOnMultipartUploadsAndEmitsDebug()
 {
     $client = $this->getServiceBuilder()->get('s3', true);
     $this->setMockResponse($client, array('s3/list_objects_empty', 's3/initiate_multipart_upload', 's3/upload_part', 's3/complete_multipart_upload'));
     $out = fopen('php://temp', 'r+');
     UploadSyncBuilder::getInstance()->setBucket('foo')->setClient($client)->setBaseDir(__DIR__)->enableDebugOutput($out)->setSourceIterator(new \ArrayIterator(array(new \SplFileInfo(__FILE__))))->setMultipartUploadSize(filesize(__FILE__) - 1)->setAcp(AcpBuilder::newInstance()->setOwner('123')->addGrantForEmail('READ_ACP', '*****@*****.**')->build())->build()->transfer();
     $requests = $this->getMockedRequests();
     $this->assertCount(4, $requests);
     $this->assertEquals('POST', $requests[1]->getMethod());
     $this->assertContains('?uploads', $requests[1]->getResource());
     $this->assertNotNull($requests[1]->getHeader('x-amz-grant-read-acp'));
     $this->assertEquals('PUT', $requests[2]->getMethod());
     $this->assertEquals('POST', $requests[3]->getMethod());
     $this->assertContains('uploadId=', $requests[3]->getResource());
     rewind($out);
     $contents = stream_get_contents($out);
     $this->assertContains('Beginning multipart upload: ' . __FILE__ . ' -> UploadSyncBuilderTest.php (', $contents);
     $this->assertContains('- Part 1 (', $contents);
 }
예제 #4
0
 protected function getAcp()
 {
     return AcpBuilder::newInstance()->setOwner('test')->addGrantForEmail('READ', '*****@*****.**')->addGrantForEmail('READ', '*****@*****.**')->addGrantForEmail('WRITE', '*****@*****.**')->addGrantForGroup('READ_ACP', Group::ALL_USERS)->build();
 }
예제 #5
0
 public function testCanBuildAnAcp()
 {
     $acl = AcpBuilder::newInstance()->setOwner('1234567890')->addGrantForEmail(Permission::READ, '*****@*****.**')->build();
     $this->assertInstanceOf('Aws\\S3\\Model\\Acp', $acl);
 }