@ResourceGroupPreparer(name_prefix='cli_test_webapp_config', location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_config(self, resource_group):
    webapp_name = self.create_random_name('webapp-config-test', 40)
    plan_name = self.create_random_name('webapp-config-plan', 40)
    self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan_name))
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan_name))
    self.cmd('webapp config show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck('alwaysOn', True), JMESPathCheck('autoHealEnabled', False), JMESPathCheck('phpVersion', '5.6'), JMESPathCheck('netFrameworkVersion', 'v4.0'), JMESPathCheck('pythonVersion', ''), JMESPathCheck('use32BitWorkerProcess', True), JMESPathCheck('webSocketsEnabled', False), JMESPathCheck('minTlsVersion', '1.2'), JMESPathCheck('ftpsState', 'AllAllowed')])
    checks = [JMESPathCheck('alwaysOn', True), JMESPathCheck('autoHealEnabled', True), JMESPathCheck('phpVersion', '7.2'), JMESPathCheck('netFrameworkVersion', 'v3.0'), JMESPathCheck('pythonVersion', '3.4'), JMESPathCheck('use32BitWorkerProcess', False), JMESPathCheck('webSocketsEnabled', True), JMESPathCheck('minTlsVersion', '1.0'), JMESPathCheck('http20Enabled', True), JMESPathCheck('ftpsState', 'Disabled')]
    self.cmd('webapp config set -g {} -n {} --always-on true --auto-heal-enabled true --php-version 7.2 --net-framework-version v3.5 --python-version 3.4 --use-32bit-worker-process=false --web-sockets-enabled=true --http20-enabled true --min-tls-version 1.0 --ftps-state Disabled'.format(resource_group, webapp_name)).assert_with_checks(checks)
    self.cmd('webapp config show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks(checks)
    self.cmd('webapp config appsettings set -g {} -n {} --settings s1=foo s2=bar s3=bar2'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck("length([?name=='s1'])", 1), JMESPathCheck("length([?name=='s2'])", 1), JMESPathCheck("length([?name=='s3'])", 1), JMESPathCheck("length([?value=='foo'])", 1), JMESPathCheck("length([?value=='bar'])", 1), JMESPathCheck("length([?value=='bar2'])", 1)])
    result = self.cmd('webapp config appsettings list -g {} -n {}'.format(resource_group, webapp_name)).get_output_in_json()
    s2 = next((x for x in result if (x['name'] == 's2')))
    self.assertEqual(s2['name'], 's2')
    self.assertEqual(s2['slotSetting'], False)
    self.assertEqual(s2['value'], 'bar')
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 's2', 's3', 'WEBSITE_NODE_DEFAULT_VERSION']))
    self.cmd('webapp config appsettings delete -g {} -n {} --setting-names s1 s2'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck("length([?name=='s3'])", 1), JMESPathCheck("length([?name=='s1'])", 0), JMESPathCheck("length([?name=='s2'])", 0)])
    self.cmd('webapp config hostname list -g {} --webapp-name {}'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck('[0].name', '{0}.azurewebsites.net'.format(webapp_name))])
    runtime = 'node|10.16'
    linux_plan = self.create_random_name(prefix='webapp-linux-plan', length=24)
    linux_webapp = self.create_random_name(prefix='webapp-linux', length=24)
    self.cmd('appservice plan create -g {} -n {} -l eastus2 --sku S1 --is-linux'.format(resource_group, linux_plan), checks=[JMESPathCheck('reserved', True), JMESPathCheck('sku.name', 'S1')])
    self.cmd('webapp create -g {} -n {} --plan {} --runtime {}'.format(resource_group, linux_webapp, linux_plan, runtime), checks=[JMESPathCheck('name', linux_webapp)])
    self.cmd('webapp config storage-account add -g {} -n {} --custom-id Id --storage-type AzureFiles --account-name name --share-name sharename --access-key key --mount-path /path/to/mount'.format(resource_group, linux_webapp))
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck("[?name=='Id']|[0].value.type", 'AzureFiles'), JMESPathCheck("[?name=='Id']|[0].value.accountName", 'name'), JMESPathCheck("[?name=='Id']|[0].value.shareName", 'sharename'), JMESPathCheck("[?name=='Id']|[0].value.accessKey", 'key'), JMESPathCheck("[?name=='Id']|[0].value.mountPath", '/path/to/mount')])
    self.cmd('webapp config storage-account update -g {} -n {} --custom-id Id --mount-path /different/path'.format(resource_group, linux_webapp))
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck("[?name=='Id']|[0].value.type", 'AzureFiles'), JMESPathCheck("[?name=='Id']|[0].value.accountName", 'name'), JMESPathCheck("[?name=='Id']|[0].value.shareName", 'sharename'), JMESPathCheck("[?name=='Id']|[0].value.accessKey", 'key'), JMESPathCheck("[?name=='Id']|[0].value.mountPath", '/different/path')])
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck('[0].name', 'Id')])
    self.cmd('webapp config storage-account delete -g {} -n {} --custom-id Id'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 0)])
    self.cmd('webapp config connection-string set -t mysql -g {} -n {} --settings c1="conn1" c2=conn2 --slot-settings c3=conn3'.format(resource_group, linux_webapp))
    self.cmd('webapp config connection-string list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length([])', 3), JMESPathCheck("[?name=='c1']|[0].slotSetting", False), JMESPathCheck("[?name=='c1']|[0].type", 'MySql'), JMESPathCheck("[?name=='c1']|[0].value", 'conn1'), JMESPathCheck("[?name=='c2']|[0].slotSetting", False), JMESPathCheck("[?name=='c3']|[0].slotSetting", True)])
    self.cmd('webapp config connection-string delete -g {} -n {} --setting-names c1 c3'.format(resource_group, linux_webapp))
    self.cmd('webapp config connection-string list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length([])', 1), JMESPathCheck('[0].slotSetting', False), JMESPathCheck('[0].name', 'c2')])
    self.assertTrue(self.cmd('webapp deployment user show').get_output_in_json()['type'])
@ResourceGroupPreparer(name_prefix='cli_test_webapp_config', location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_config(self, resource_group):
    webapp_name = self.create_random_name('webapp-config-test', 40)
    plan_name = self.create_random_name('webapp-config-plan', 40)
    self.cmd('appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan_name))
    self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan_name))
    self.cmd('webapp config show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck('alwaysOn', True), JMESPathCheck('autoHealEnabled', False), JMESPathCheck('phpVersion', '5.6'), JMESPathCheck('netFrameworkVersion', 'v4.0'), JMESPathCheck('pythonVersion', ), JMESPathCheck('use32BitWorkerProcess', True), JMESPathCheck('webSocketsEnabled', False), JMESPathCheck('minTlsVersion', '1.2'), JMESPathCheck('ftpsState', 'AllAllowed')])
    checks = [JMESPathCheck('alwaysOn', True), JMESPathCheck('autoHealEnabled', True), JMESPathCheck('phpVersion', '7.2'), JMESPathCheck('netFrameworkVersion', 'v3.0'), JMESPathCheck('pythonVersion', '3.4'), JMESPathCheck('use32BitWorkerProcess', False), JMESPathCheck('webSocketsEnabled', True), JMESPathCheck('minTlsVersion', '1.0'), JMESPathCheck('http20Enabled', True), JMESPathCheck('ftpsState', 'Disabled')]
    self.cmd('webapp config set -g {} -n {} --always-on true --auto-heal-enabled true --php-version 7.2 --net-framework-version v3.5 --python-version 3.4 --use-32bit-worker-process=false --web-sockets-enabled=true --http20-enabled true --min-tls-version 1.0 --ftps-state Disabled'.format(resource_group, webapp_name)).assert_with_checks(checks)
    self.cmd('webapp config show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks(checks)
    self.cmd('webapp config appsettings set -g {} -n {} --settings s1=foo s2=bar s3=bar2'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck("length([?name=='s1'])", 1), JMESPathCheck("length([?name=='s2'])", 1), JMESPathCheck("length([?name=='s3'])", 1), JMESPathCheck("length([?value=='foo'])", 1), JMESPathCheck("length([?value=='bar'])", 1), JMESPathCheck("length([?value=='bar2'])", 1)])
    result = self.cmd('webapp config appsettings list -g {} -n {}'.format(resource_group, webapp_name)).get_output_in_json()
    s2 = next((x for x in result if (x['name'] == 's2')))
    self.assertEqual(s2['name'], 's2')
    self.assertEqual(s2['slotSetting'], False)
    self.assertEqual(s2['value'], 'bar')
    self.assertEqual(set([x['name'] for x in result]), set(['s1', 's2', 's3', 'WEBSITE_NODE_DEFAULT_VERSION']))
    self.cmd('webapp config appsettings delete -g {} -n {} --setting-names s1 s2'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck("length([?name=='s3'])", 1), JMESPathCheck("length([?name=='s1'])", 0), JMESPathCheck("length([?name=='s2'])", 0)])
    self.cmd('webapp config hostname list -g {} --webapp-name {}'.format(resource_group, webapp_name)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck('[0].name', '{0}.azurewebsites.net'.format(webapp_name))])
    runtime = 'node|10.16'
    linux_plan = self.create_random_name(prefix='webapp-linux-plan', length=24)
    linux_webapp = self.create_random_name(prefix='webapp-linux', length=24)
    self.cmd('appservice plan create -g {} -n {} -l eastus2 --sku S1 --is-linux'.format(resource_group, linux_plan), checks=[JMESPathCheck('reserved', True), JMESPathCheck('sku.name', 'S1')])
    self.cmd('webapp create -g {} -n {} --plan {} --runtime {}'.format(resource_group, linux_webapp, linux_plan, runtime), checks=[JMESPathCheck('name', linux_webapp)])
    self.cmd('webapp config storage-account add -g {} -n {} --custom-id Id --storage-type AzureFiles --account-name name --share-name sharename --access-key key --mount-path /path/to/mount'.format(resource_group, linux_webapp))
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck("[?name=='Id']|[0].value.type", 'AzureFiles'), JMESPathCheck("[?name=='Id']|[0].value.accountName", 'name'), JMESPathCheck("[?name=='Id']|[0].value.shareName", 'sharename'), JMESPathCheck("[?name=='Id']|[0].value.accessKey", 'key'), JMESPathCheck("[?name=='Id']|[0].value.mountPath", '/path/to/mount')])
    self.cmd('webapp config storage-account update -g {} -n {} --custom-id Id --mount-path /different/path'.format(resource_group, linux_webapp))
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck("[?name=='Id']|[0].value.type", 'AzureFiles'), JMESPathCheck("[?name=='Id']|[0].value.accountName", 'name'), JMESPathCheck("[?name=='Id']|[0].value.shareName", 'sharename'), JMESPathCheck("[?name=='Id']|[0].value.accessKey", 'key'), JMESPathCheck("[?name=='Id']|[0].value.mountPath", '/different/path')])
    self.cmd('webapp config storage-account list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 1), JMESPathCheck('[0].name', 'Id')])
    self.cmd('webapp config storage-account delete -g {} -n {} --custom-id Id'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length(@)', 0)])
    self.cmd('webapp config connection-string set -t mysql -g {} -n {} --settings c1="conn1" c2=conn2 --slot-settings c3=conn3'.format(resource_group, linux_webapp))
    self.cmd('webapp config connection-string list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length([])', 3), JMESPathCheck("[?name=='c1']|[0].slotSetting", False), JMESPathCheck("[?name=='c1']|[0].type", 'MySql'), JMESPathCheck("[?name=='c1']|[0].value", 'conn1'), JMESPathCheck("[?name=='c2']|[0].slotSetting", False), JMESPathCheck("[?name=='c3']|[0].slotSetting", True)])
    self.cmd('webapp config connection-string delete -g {} -n {} --setting-names c1 c3'.format(resource_group, linux_webapp))
    self.cmd('webapp config connection-string list -g {} -n {}'.format(resource_group, linux_webapp)).assert_with_checks([JMESPathCheck('length([])', 1), JMESPathCheck('[0].slotSetting', False), JMESPathCheck('[0].name', 'c2')])
    self.assertTrue(self.cmd('webapp deployment user show').get_output_in_json()['type'])