/** * @covers WindowsAzure\Blob\Models\BlobServiceOptions::getTimeout */ public function testGetTimeout() { // Setup $options = new BlobServiceOptions(); $value = 10; $options->setTimeout($value); // Test $actualValue = $options->getTimeout(); // Assert $this->assertEquals($value, $actualValue); }
/** * @covers WindowsAzure\Blob\BlobRestProxy::createBlockBlob * @covers WindowsAzure\Blob\BlobRestProxy::createContainer * @covers WindowsAzure\Blob\BlobRestProxy::deleteContainer * @covers WindowsAzure\Blob\BlobRestProxy::getContainerACL * @covers WindowsAzure\Blob\BlobRestProxy::setContainerACL */ private function setContainerACLWorker($options, $acl) { $container = BlobServiceFunctionalTestData::getInterestingContainerName(); // Make sure there is something to test $this->restProxy->createContainer($container); $blobContent = uniqid(); try { $this->restProxy->createBlockBlob($container, 'test', $blobContent); } catch (UnsupportedEncodingException $e1) { // UTF-8 should be fine. error_log($e1->getMessage()); } try { if (is_null($options)) { $this->restProxy->setContainerACL($container, $acl); $this->restProxy->setContainerACL($container, $acl); } else { $this->restProxy->setContainerACL($container, $acl, $options); $this->restProxy->setContainerACL($container, $acl, $options); } if (is_null($options)) { $options = new BlobServiceOptions(); } if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertTrue(false, 'Expect negative timeouts in $options to throw'); } $res = $this->restProxy->getContainerACL($container); $this->verifySetContainerACLWorker($res, $container, $acl, $blobContent); } catch (ServiceException $e) { if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertEquals(500, $e->getCode(), 'getCode'); } else { throw $e; } } // Clean up. $this->restProxy->deleteContainer($container); }
/** * Sets the ACL and any container-level access policies for the container. * * @param string $container name * @param Models\ContainerAcl $acl access control list for container * @param Models\BlobServiceOptions $options optional parameters * * @return none * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179391.aspx */ public function setContainerAcl($container, $acl, $options = null) { Validate::isString($container, 'container'); Validate::notNullOrEmpty($acl, 'acl'); $method = Resources::HTTP_PUT; $headers = array(); $postParams = array(); $queryParams = array(); $path = $container; $statusCode = Resources::STATUS_OK; $body = $acl->toXml($this->dataSerializer); if (is_null($options)) { $options = new BlobServiceOptions(); } $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout()); $this->addOptionalQueryParam($queryParams, Resources::QP_REST_TYPE, 'container'); $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'acl'); $this->addOptionalHeader($headers, Resources::X_MS_BLOB_PUBLIC_ACCESS, $acl->getPublicAccess()); $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE); $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body); }
/** * @covers WindowsAzure\Blob\BlobRestProxy::createBlockBlob * @covers WindowsAzure\Blob\BlobRestProxy::createContainer * @covers WindowsAzure\Blob\BlobRestProxy::deleteContainer * @covers WindowsAzure\Blob\BlobRestProxy::getContainerACL * @covers WindowsAzure\Blob\BlobRestProxy::setContainerACL */ private function setContainerACLWorker($options, $acl) { $container = BlobServiceFunctionalTestData::getInterestingContainerName(); // Make sure there is something to test $this->restProxy->createContainer($container); $blobContent = uniqid(); $this->restProxy->createBlockBlob($container, 'test', $blobContent); try { if (is_null($options)) { $this->restProxy->setContainerACL($container, $acl); $this->restProxy->setContainerACL($container, $acl); } else { $this->restProxy->setContainerACL($container, $acl, $options); $this->restProxy->setContainerACL($container, $acl, $options); } if (is_null($options)) { $options = new BlobServiceOptions(); } if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertTrue(false, 'Expect negative timeouts in $options to throw'); } $res = $this->restProxy->getContainerACL($container); $this->verifySetContainerACLWorker($res, $container, $acl, $blobContent); } catch (ServiceException $e) { if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertEquals(TestResources::STATUS_INTERNAL_SERVER_ERROR, $e->getCode(), 'getCode'); } else { throw $e; } } // Clean up. $this->restProxy->deleteContainer($container); }