def test_get_external_ip_from_ase(self, client_factory_mock): client = mock.Mock() client_factory_mock.return_value = client cmd_mock = mock.MagicMock() # set up the web inside a ASE, with an ip based ssl binding host_env = HostingEnvironmentProfile(id='id11') host_env.name = 'ase1' host_env.resource_group = 'myRg' host_ssl_state = HostNameSslState(ssl_state=SslState.ip_based_enabled, virtual_ip='1.2.3.4') client.web_apps.get.return_value = Site( name='antarctica', hosting_environment_profile=host_env, host_name_ssl_states=[host_ssl_state], location='westus') client.app_service_environments.list_vips.return_value = AddressResponse( ) # action result = get_external_ip(cmd_mock, 'myRg', 'myWeb') # assert, we return the virtual ip from the ip based ssl binding self.assertEqual('1.2.3.4', result['ip']) # tweak to have no ip based ssl binding, but it is in an internal load balancer host_ssl_state2 = HostNameSslState(ssl_state=SslState.sni_enabled) client.web_apps.get.return_value = Site( name='antarctica', hosting_environment_profile=host_env, host_name_ssl_states=[host_ssl_state2], location='westus') client.app_service_environments.list_vips.return_value = AddressResponse( internal_ip_address='4.3.2.1') # action result = get_external_ip(cmd_mock, 'myRg', 'myWeb') # assert, we take the ILB address self.assertEqual('4.3.2.1', result['ip']) # tweak to have no ip based ssl binding, and not in internal load balancer host_ssl_state2 = HostNameSslState(ssl_state=SslState.sni_enabled) client.web_apps.get.return_value = Site( name='antarctica', hosting_environment_profile=host_env, host_name_ssl_states=[host_ssl_state2], location='westus') client.app_service_environments.list_vips.return_value = AddressResponse( service_ip_address='1.1.1.1') # action result = get_external_ip(cmd_mock, 'myRg', 'myWeb') # assert, we take service ip self.assertEqual('1.1.1.1', result['ip'])
def _update_host_name_ssl_state(resource_group_name, webapp_name, location, host_name, ssl_state, thumbprint, slot=None): updated_webapp = Site(host_name_ssl_states=[HostNameSslState(name=host_name, ssl_state=ssl_state, thumbprint=thumbprint, to_update=True)], location=location) name = '{}({})'.format(webapp_name, slot) if slot else webapp_name return _generic_site_operation(resource_group_name, name, 'create_or_update', slot, updated_webapp)
def test_browse_with_trace(self, webbrowser_mock, log_mock, site_op_mock): site = Site('antarctica') site.default_host_name = 'haha.com' site.host_name_ssl_states = [HostNameSslState('does not matter', ssl_state=SslState.ip_based_enabled)] site_op_mock.return_value = site # action view_in_browser('myRG', 'myweb', logs=True) # assert webbrowser_mock.assert_called_with('https://haha.com') log_mock.assert_called_with('myRG', 'myweb', None, None)