@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_ssl(self, resource_group, resource_group_location):
    plan = self.create_random_name(prefix='ssl-test-plan', length=24)
    webapp_name = self.create_random_name(prefix='web-ssl-test', length=20)
    slot_name = self.create_random_name(prefix='slot-ssl-test', length=20)
    pfx_file = os.path.join(TEST_DIR, 'server.pfx')
    cert_password = 'test'
    cert_thumbprint = '9E9735C45C792B03B3FFCCA614852B32EE71AD6B'
    self.cmd('appservice plan create -g {} -n {} --sku S1 --tags plan=plan1'.format(resource_group, plan))
    self.cmd('appservice plan show -g {} -n {}'.format(resource_group, plan), self.check('tags.plan', 'plan1'))
    self.cmd('webapp create -g {} -n {} --plan {} --tags web=web1'.format(resource_group, webapp_name, plan))
    self.cmd('webapp config ssl upload -g {} -n {} --certificate-file "{}" --certificate-password {}'.format(resource_group, webapp_name, pfx_file, cert_password), checks=[JMESPathCheck('thumbprint', cert_thumbprint)])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl bind -g {} -n {} --certificate-thumbprint {} --ssl-type {}'.format(resource_group, webapp_name, cert_thumbprint, 'SNI'), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].sslState".format(webapp_name), 'SniEnabled'), JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].thumbprint".format(webapp_name), cert_thumbprint)])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl unbind -g {} -n {} --certificate-thumbprint {}'.format(resource_group, webapp_name, cert_thumbprint), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].sslState".format(webapp_name), 'Disabled')])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl delete -g {} --certificate-thumbprint {}'.format(resource_group, cert_thumbprint))
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl upload -g {} -n {} --certificate-file "{}" --certificate-password {} -s {}'.format(resource_group, webapp_name, pfx_file, cert_password, slot_name), checks=[JMESPathCheck('thumbprint', cert_thumbprint)])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl bind -g {} -n {} --certificate-thumbprint {} --ssl-type {} -s {}'.format(resource_group, webapp_name, cert_thumbprint, 'SNI', slot_name), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].sslState".format(webapp_name, slot_name), 'SniEnabled'), JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].thumbprint".format(webapp_name, slot_name), cert_thumbprint)])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl unbind -g {} -n {} --certificate-thumbprint {} -s {}'.format(resource_group, webapp_name, cert_thumbprint, slot_name), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].sslState".format(webapp_name, slot_name), 'Disabled')])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl delete -g {} --certificate-thumbprint {}'.format(resource_group, cert_thumbprint))
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp delete -g {} -n {}'.format(resource_group, webapp_name))
@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_ssl(self, resource_group, resource_group_location):
    plan = self.create_random_name(prefix='ssl-test-plan', length=24)
    webapp_name = self.create_random_name(prefix='web-ssl-test', length=20)
    slot_name = self.create_random_name(prefix='slot-ssl-test', length=20)
    pfx_file = os.path.join(TEST_DIR, 'server.pfx')
    cert_password = 'test'
    cert_thumbprint = '9E9735C45C792B03B3FFCCA614852B32EE71AD6B'
    self.cmd('appservice plan create -g {} -n {} --sku S1 --tags plan=plan1'.format(resource_group, plan))
    self.cmd('appservice plan show -g {} -n {}'.format(resource_group, plan), self.check('tags.plan', 'plan1'))
    self.cmd('webapp create -g {} -n {} --plan {} --tags web=web1'.format(resource_group, webapp_name, plan))
    self.cmd('webapp config ssl upload -g {} -n {} --certificate-file "{}" --certificate-password {}'.format(resource_group, webapp_name, pfx_file, cert_password), checks=[JMESPathCheck('thumbprint', cert_thumbprint)])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl bind -g {} -n {} --certificate-thumbprint {} --ssl-type {}'.format(resource_group, webapp_name, cert_thumbprint, 'SNI'), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].sslState".format(webapp_name), 'SniEnabled'), JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].thumbprint".format(webapp_name), cert_thumbprint)])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl unbind -g {} -n {} --certificate-thumbprint {}'.format(resource_group, webapp_name, cert_thumbprint), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}.azurewebsites.net']|[0].sslState".format(webapp_name), 'Disabled')])
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp config ssl delete -g {} --certificate-thumbprint {}'.format(resource_group, cert_thumbprint))
    self.cmd('webapp show -g {} -n {}'.format(resource_group, webapp_name), self.check('tags.web', 'web1'))
    self.cmd('webapp deployment slot create -g {} -n {} --slot {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl upload -g {} -n {} --certificate-file "{}" --certificate-password {} -s {}'.format(resource_group, webapp_name, pfx_file, cert_password, slot_name), checks=[JMESPathCheck('thumbprint', cert_thumbprint)])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl bind -g {} -n {} --certificate-thumbprint {} --ssl-type {} -s {}'.format(resource_group, webapp_name, cert_thumbprint, 'SNI', slot_name), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].sslState".format(webapp_name, slot_name), 'SniEnabled'), JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].thumbprint".format(webapp_name, slot_name), cert_thumbprint)])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl unbind -g {} -n {} --certificate-thumbprint {} -s {}'.format(resource_group, webapp_name, cert_thumbprint, slot_name), checks=[JMESPathCheck("hostNameSslStates|[?name=='{}-{}.azurewebsites.net']|[0].sslState".format(webapp_name, slot_name), 'Disabled')])
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp config ssl delete -g {} --certificate-thumbprint {}'.format(resource_group, cert_thumbprint))
    self.cmd('webapp show -g {} -n {} -s {}'.format(resource_group, webapp_name, slot_name))
    self.cmd('webapp delete -g {} -n {}'.format(resource_group, webapp_name))