Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11361,7 +11361,10 @@ def _build_deploymentstatus_url(cmd, resource_group_name, webapp_name, slot, dep

def _get_ondeploy_headers(params):
if params.src_path:
content_type = 'application/octet-stream'
if params.artifact_type == 'zip':
content_type = 'application/zip'
else:
content_type = 'application/octet-stream'
elif params.src_url:
content_type = 'application/json'
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,36 @@ def _make_params(self):
params.slot = None
return params

@mock.patch('azure.cli.command_modules.appservice.custom._populate_cached_scm_headers')
@mock.patch('azure.cli.command_modules.appservice.custom.get_scm_site_headers', return_value={})
def test_get_ondeploy_headers_uses_zip_content_type_for_zip_artifact(
self, get_scm_site_headers_mock, _populate_cached_headers_mock):
from azure.cli.command_modules.appservice.custom import _get_ondeploy_headers
params = self._make_params()
params.src_path = '/tmp/package.zip'
params.artifact_type = 'zip'

_get_ondeploy_headers(params)

sent_additional_headers = get_scm_site_headers_mock.call_args.kwargs['additional_headers']
self.assertEqual(sent_additional_headers['Content-Type'], 'application/zip')
self.assertEqual(sent_additional_headers['Cache-Control'], 'no-cache')

@mock.patch('azure.cli.command_modules.appservice.custom._populate_cached_scm_headers')
@mock.patch('azure.cli.command_modules.appservice.custom.get_scm_site_headers', return_value={})
def test_get_ondeploy_headers_keeps_octet_stream_for_non_zip_artifact(
self, get_scm_site_headers_mock, _populate_cached_headers_mock):
from azure.cli.command_modules.appservice.custom import _get_ondeploy_headers
params = self._make_params()
params.src_path = '/tmp/package.war'
params.artifact_type = 'war'

_get_ondeploy_headers(params)

sent_additional_headers = get_scm_site_headers_mock.call_args.kwargs['additional_headers']
self.assertEqual(sent_additional_headers['Content-Type'], 'application/octet-stream')
self.assertEqual(sent_additional_headers['Cache-Control'], 'no-cache')

def test_get_or_fetch_scm_url_derives_from_cached_site(self):
from azure.cli.command_modules.appservice.custom import _get_or_fetch_scm_url
from azure.mgmt.web.models import HostType
Expand Down
Loading