def test_domain_ip_bad_urls(): """Tests get_server_ip() passing bad urls. Assumes ip is correct.""" with pytest.raises(LookupError): get_server_ip(['http://example.com', 'http://techterminal.net']) # Try 2 bad urls with one good url: assert socket.inet_aton(get_server_ip(['http://example.com', 'http://techterminal.net', 'http://techterminal.net/myip']))
def verify(self, repair=False): # pylint: disable=unused-argument """Verifies that the domain is pointed at the server.""" server_ip = get_server_ip() website_ip = self.get_ip() print('Server IP: ' + server_ip) print('Current website IP: ' + website_ip) if website_ip == '127.0.0.1': print('\n -----------------------------------------------------------') print(' [WARN] Website IP is pointed to localhost! This usually') print(' means there is an entry in the hosts file. Remember') print(' to check if this is what you actually want.') print(' -----------------------------------------------------------\n') return True if not server_ip == website_ip: if repair: print(' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') print('\n -----------------------------------------------------------') print(' [WARN] Website IP is not the same as this server\'s ip!') print(' DNS API not yet implemented.') print(' Please remember to change DNS settings manually.') print(' -----------------------------------------------------------\n') return False print('Domain is correctly pointed at this server.') return True
def test_domain_ip(): """Tests get_server_ip(). Assumes ip is correct.""" assert socket.inet_aton(get_server_ip())