Exemplo n.º 1
0
 /**
  * Test creating an object with metadata but no content.
  */
 public function testGetAllMetadata()
 {
     $mlist = new MetadataList();
     $listable = new Metadata('listable', 'foo', true);
     $unlistable = new Metadata('unlistable', 'bar', false);
     $listable2 = new Metadata('listable2', 'foo2 foo2', true);
     $unlistable2 = new Metadata('unlistable2', 'bar2 bar2', false);
     $mlist->addMetadata($listable);
     $mlist->addMetadata($unlistable);
     $mlist->addMetadata($listable2);
     $mlist->addMetadata($unlistable2);
     $acl = new Acl();
     $acl->addGrant(new Grant(new Grantee($this->uid, Grantee::USER), Permission::FULL_CONTROL));
     $acl->addGrant(new Grant(Grantee::$OTHER, Permission::READ));
     $id = $this->esu->createObject($acl, $mlist, null, null);
     PHPUnit_Framework_Assert::assertNotNull($id, 'null ID returned');
     $this->cleanup[] = $id;
     // Read and validate the metadata
     list($meta, $newacl) = $this->esu->getAllMetadata($id);
     PHPUnit_Framework_Assert::assertEquals('foo', $meta->getMetadata('listable')->getValue(), "value of 'listable' wrong");
     PHPUnit_Framework_Assert::assertEquals('foo2 foo2', $meta->getMetadata('listable2')->getValue(), "value of 'listable2' wrong");
     PHPUnit_Framework_Assert::assertEquals('bar', $meta->getMetadata('unlistable')->getValue(), "value of 'unlistable' wrong");
     PHPUnit_Framework_Assert::assertEquals('bar2 bar2', $meta->getMetadata('unlistable2')->getValue(), "value of 'unlistable2' wrong");
     PHPUnit_Framework_Assert::assertEquals($acl, $newacl, "ACLs don't match");
 }
Exemplo n.º 2
0
 /**
  * Parses the value of an ACL response header and builds an ACL
  * @param Acl $acl a reference to the ACL to append to
  * @param string $header the acl response header
  * @param string $type the type of Grantees in the header (user or group)
  */
 private function readAcl(&$acl, $header, $type)
 {
     $this->trace('readAcl: ' . $header);
     $grants = explode(',', $header);
     foreach ($grants as $grant) {
         $nvpair = explode('=', $grant, 2);
         $grantee = ltrim($nvpair[0], ' ');
         $permission = $nvpair[1];
         // Older versions of Atmos may return "FULL" instead of "FULL_CONTROL".
         // For consistency, change this to value used in the request
         if ($permission == 'FULL') {
             $permission = Permission::FULL_CONTROL;
         }
         $this->trace('grant: ' . $grantee . '->' . $permission . ' (' . $type . ')');
         $ge = new Grantee($grantee, $type);
         $gr = new Grant($ge, $permission);
         $this->trace('Grant: ' . $gr);
         $acl->addGrant($gr);
     }
 }