コード例 #1
0
 private static function getAllAccessConditions()
 {
     $ret = self::getTemporalAccessConditions();
     array_push($ret, AccessCondition::ifMatch(null));
     array_push($ret, AccessCondition::ifMatch(self::$badETag));
     array_push($ret, AccessCondition::ifNoneMatch(null));
     array_push($ret, AccessCondition::ifNoneMatch(self::$badETag));
     return $ret;
 }
コード例 #2
0
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::createPageBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlobProperties
  */
 public function testGetBlobWithIfNoneMatchETagAccessConditionWorks()
 {
     // Act
     $this->restProxy->createPageBlob(self::$_test_container_for_blobs, 'test', 4096);
     $props = $this->restProxy->getBlobProperties(self::$_test_container_for_blobs, 'test');
     try {
         $opts = new GetBlobOptions();
         $opts->setAccessCondition(AccessCondition::ifNoneMatch($props->getProperties()->getETag()));
         $this->restProxy->getBlob(self::$_test_container_for_blobs, 'test', $opts);
         $this->fail('getBlob should throw an exception');
     } catch (ServiceException $e) {
         if (!$this->hasSecureEndpoint() && $e->getCode() == TestResources::STATUS_FORBIDDEN) {
             // Proxies can eat the access condition headers of
             // unsecured (http) requests, which causes the authentication
             // to fail, with a 403:Forbidden. There is nothing much that
             // can be done about this, other than ignore it.
             $this->markTestSkipped('Appears that a proxy ate your access condition');
         } else {
             $this->assertEquals(TestResources::STATUS_NOT_MODIFIED, $e->getCode(), 'got the expected exception');
         }
     }
 }
コード例 #3
0
 /**
  * @covers WindowsAzure\Blob\Models\AccessCondition::ifNoneMatch
  * @covers WindowsAzure\Blob\Models\AccessCondition::getHeader
  * @covers WindowsAzure\Blob\Models\AccessCondition::getValue
  */
 public function testIfNoneMatch()
 {
     // Setup
     $expectedHeader = Resources::IF_NONE_MATCH;
     $expectedValue = '0x8CAFB82EFF70C46';
     // Test
     $actual = AccessCondition::ifNoneMatch($expectedValue);
     // Assert
     $this->assertEquals($expectedHeader, $actual->getHeader());
     $this->assertEquals($expectedValue, $actual->getValue());
 }
コード例 #4
0
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::createPageBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlobProperties
  */
 public function testGetBlobWithIfNoneMatchETagAccessConditionWorks()
 {
     // Act
     $this->restProxy->createPageBlob(self::$_test_container_for_blobs, 'test', 4096);
     $props = $this->restProxy->getBlobProperties(self::$_test_container_for_blobs, 'test');
     try {
         $opts = new GetBlobOptions();
         $opts->setAccessCondition(AccessCondition::ifNoneMatch($props->getProperties()->getEtag()));
         $this->restProxy->getBlob(self::$_test_container_for_blobs, 'test', $opts);
         $this->fail('getBlob should throw an exception');
     } catch (ServiceException $e) {
         $this->assertEquals(304, $e->getCode(), 'got the expected exception');
     }
 }