def test_set_static_website_properties_missing_field(self): # Case1: Arrange both missing static_website = StaticWebsite(enabled=True) # Act self.bsc.set_service_properties(static_website=static_website) # Assert received_props = self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, static_website) # Case2: Arrange index document missing static_website = StaticWebsite( enabled=True, error_document404_path="errors/error/404error.html") # Act self.bsc.set_service_properties(static_website=static_website) # Assert received_props = self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, static_website) # Case3: Arrange error document missing static_website = StaticWebsite(enabled=True, index_document="index.html") # Act self.bsc.set_service_properties(static_website=static_website) # Assert received_props = self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, static_website)
async def test_set_static_web_props_missing_field(self, storage_account_name, storage_account_key): # Case1: Arrange both missing bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key, transport=AiohttpTestTransport()) static_website = StaticWebsite(enabled=True) # Act await bsc.set_service_properties(static_website=static_website) # Assert received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website) # Case2: Arrange index document missing static_website = StaticWebsite(enabled=True, error_document404_path="errors/error/404error.html") # Act await bsc.set_service_properties(static_website=static_website) # Assert received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website) # Case3: Arrange error document missing static_website = StaticWebsite(enabled=True, index_document="index.html") # Act await bsc.set_service_properties(static_website=static_website) # Assert received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website)
def test_set_static_website_properties_missing_field(self, resource_group, location, storage_account, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account.name, "blob"), credential=storage_account_key) # Case1: Arrange both missing static_website = StaticWebsite(enabled=True) # Act bsc.set_service_properties(static_website=static_website) # Assert received_props = bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website) # Case2: Arrange index document missing static_website = StaticWebsite(enabled=True, error_document404_path="errors/error/404error.html") # Act bsc.set_service_properties(static_website=static_website) # Assert received_props = bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website) # Case3: Arrange error document missing static_website = StaticWebsite(enabled=True, index_document="index.html") # Act bsc.set_service_properties(static_website=static_website) # Assert received_props = bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website)
async def test_disabled_static_website_properties(self, storage_account_name, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key, transport=AiohttpTestTransport()) static_website = StaticWebsite(enabled=False, index_document="index.html", error_document404_path="errors/error/404error.html") # Act await bsc.set_service_properties(static_website=static_website) # Assert received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], StaticWebsite(enabled=False))
def test_disabled_static_website_properties(self, resource_group, location, storage_account, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account.name, "blob"), credential=storage_account_key) static_website = StaticWebsite(enabled=False, index_document="index.html", error_document404_path="errors/error/404error.html") # Act bsc.set_service_properties(static_website=static_website) # Assert received_props = bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], StaticWebsite(enabled=False))
def test_disabled_static_website_properties(self): # Arrange static_website = StaticWebsite(enabled=False, index_document="index.html", error_document404_path="errors/error/404error.html") # Act self.bsc.set_service_properties(static_website=static_website) # Assert received_props = self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, StaticWebsite(enabled=False))
def test_set_static_website_properties_with_default_index_document_path(self, storage_account_name, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) static_website = StaticWebsite( enabled=True, error_document404_path="errors/error/404error.html", default_index_document_path="index.html") # Act bsc.set_service_properties(static_website=static_website) # Assert received_props = bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website)
async def test_set_static_webprops_no_impact_other_props( self, resource_group, location, storage_account, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport()) cors_rule1 = CorsRule(['www.xyz.com'], ['GET']) allowed_origins = ['www.xyz.com', "www.ab.com", "www.bc.com"] allowed_methods = ['GET', 'PUT'] max_age_in_seconds = 500 exposed_headers = [ "x-ms-meta-data*", "x-ms-meta-source*", "x-ms-meta-abc", "x-ms-meta-bcd" ] allowed_headers = [ "x-ms-meta-data*", "x-ms-meta-target*", "x-ms-meta-xyz", "x-ms-meta-foo" ] cors_rule2 = CorsRule(allowed_origins, allowed_methods, max_age_in_seconds=max_age_in_seconds, exposed_headers=exposed_headers, allowed_headers=allowed_headers) cors = [cors_rule1, cors_rule2] # Act await bsc.set_service_properties(cors=cors) # Assert cors is updated received_props = await bsc.get_service_properties() self._assert_cors_equal(received_props['cors'], cors) bsc = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport()) static_website = StaticWebsite( enabled=True, index_document="index.html", error_document404_path="errors/error/404error.html") # Act to set static website await bsc.set_service_properties(static_website=static_website) # Assert static website was updated was cors was unchanged received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website) self._assert_cors_equal(received_props['cors'], cors)
async def _test_set_static_website_properties_async(self): # Arrange static_website = StaticWebsite( enabled=True, index_document="index.html", error_document404_path="errors/error/404error.html") # Act await self.bsc.set_service_properties(static_website=static_website) # Assert received_props = await self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, static_website)
def test_set_static_website_properties_does_not_impact_other_properties( self): # Arrange to set cors cors_rule1 = CorsRule(['www.xyz.com'], ['GET']) allowed_origins = ['www.xyz.com', "www.ab.com", "www.bc.com"] allowed_methods = ['GET', 'PUT'] max_age_in_seconds = 500 exposed_headers = [ "x-ms-meta-data*", "x-ms-meta-source*", "x-ms-meta-abc", "x-ms-meta-bcd" ] allowed_headers = [ "x-ms-meta-data*", "x-ms-meta-target*", "x-ms-meta-xyz", "x-ms-meta-foo" ] cors_rule2 = CorsRule(allowed_origins, allowed_methods, max_age_in_seconds=max_age_in_seconds, exposed_headers=exposed_headers, allowed_headers=allowed_headers) cors = [cors_rule1, cors_rule2] # Act to set cors self.bsc.set_service_properties(cors=cors) # Assert cors is updated received_props = self.bsc.get_service_properties() self._assert_cors_equal(received_props.cors, cors) # Arrange to set static website properties static_website = StaticWebsite( enabled=True, index_document="index.html", error_document404_path="errors/error/404error.html") # Act to set static website self.bsc.set_service_properties(static_website=static_website) # Assert static website was updated was cors was unchanged received_props = self.bsc.get_service_properties() self._assert_static_website_equal(received_props.static_website, static_website) self._assert_cors_equal(received_props.cors, cors)
async def test_set_static_website_properties_with_default_index_document_path( self, resource_group, location, storage_account, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport()) static_website = StaticWebsite( enabled=True, error_document404_path="errors/error/404error.html", default_index_document_path="index.html") # Act await bsc.set_service_properties(static_website=static_website) # Assert received_props = await bsc.get_service_properties() self._assert_static_website_equal(received_props['static_website'], static_website)