diff --git a/src/azure-cli/azure/cli/command_modules/appservice/custom.py b/src/azure-cli/azure/cli/command_modules/appservice/custom.py index fe3ec65ac8b..571c333645a 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/custom.py @@ -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: diff --git a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py index cc19fbcb865..22c56edfad5 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py @@ -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