public static function getInterestingDeleteContainerOptions() { $ret = array(); $past = new \DateTime("01/01/2010"); $future = new \DateTime("01/01/2020"); $options = new DeleteContainerOptions(); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setTimeout(10); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setTimeout(-10); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setAccessCondition(AccessCondition::ifModifiedSince($past)); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setAccessCondition(AccessCondition::ifNotModifiedSince($past)); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setAccessCondition(AccessCondition::ifModifiedSince($future)); array_push($ret, $options); $options = new DeleteContainerOptions(); $options->setAccessCondition(AccessCondition::ifNotModifiedSince($future)); array_push($ret, $options); return $ret; }
/** * @covers WindowsAzure\Blob\BlobRestProxy::createPageBlob * @covers WindowsAzure\Blob\BlobRestProxy::getBlob * @covers WindowsAzure\Blob\BlobRestProxy::getBlobProperties */ public function testGetBlobWithIfModifiedSinceAccessConditionWorks() { // 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(); $lastMod = $props->getProperties()->getLastModified(); $opts->setAccessCondition(AccessCondition::ifModifiedSince($lastMod)); $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'); } } }
/** * @covers WindowsAzure\Blob\Models\AccessCondition::ifModifiedSince * @covers WindowsAzure\Blob\Models\AccessCondition::getHeader * @covers WindowsAzure\Blob\Models\AccessCondition::getValue */ public function testIfModifiedSince() { // Setup $expectedHeader = Resources::IF_MODIFIED_SINCE; $expectedValue = new \DateTime('Sun, 25 Sep 2011 00:42:49 GMT'); // Test $actual = AccessCondition::ifModifiedSince($expectedValue); // Assert $this->assertEquals($expectedHeader, $actual->getHeader()); $this->assertEquals($expectedValue, $actual->getValue()); }
/** * @covers WindowsAzure\Blob\BlobRestProxy::createPageBlob * @covers WindowsAzure\Blob\BlobRestProxy::getBlob * @covers WindowsAzure\Blob\BlobRestProxy::getBlobProperties */ public function testGetBlobWithIfModifiedSinceAccessConditionWorks() { // 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(); $lastMod = $props->getProperties()->getLastModified(); $opts->setAccessCondition(AccessCondition::ifModifiedSince($lastMod)); $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'); } }