def test_idn_domain_punycode(self): self._mocks_for_domain_detail(handle="xn--frd-cma.cz") response = self.client.get(reverse("webwhois:detail_domain", kwargs={"handle": "xn--frd-cma.cz"})) self.assertContains(response, "Search results for handle <strong>xn--frd-cma.cz</strong>:") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'xn--frd-cma.cz'), ('handleType', 'domain'))), call.create_request().close(properties=[('foundType', 'domain')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_domain_by_handle('xn--frd-cma.cz'), call.get_domain_status_descriptions('en'), call.get_contact_by_handle('KONTAKT'), call.get_registrar_by_handle('REG-FRED_A'), call.get_contact_by_handle('KONTAKT'), call.get_nsset_by_handle('NSSET-1'), call.get_nsset_status_descriptions('en'), call.get_contact_by_handle('KONTAKT'), call.get_registrar_by_handle('REG-FRED_A'), call.get_keyset_by_handle('KEYSID-1'), call.get_keyset_status_descriptions('en'), call.get_contact_by_handle('KONTAKT'), call.get_registrar_by_handle('REG-FRED_A') ])
def test_multiple_entries(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact() WHOIS.get_nsset_status_descriptions.return_value = self._get_nsset_status() WHOIS.get_nsset_by_handle.return_value = self._get_nsset() WHOIS.get_keyset_status_descriptions.return_value = self._get_keyset_status() WHOIS.get_keyset_by_handle.return_value = self._get_keyset() WHOIS.get_registrar_by_handle.return_value = self._get_registrar() WHOIS.get_domain_status_descriptions.return_value = self._get_domain_status() WHOIS.get_domain_by_handle.return_value = self._get_domain() response = self.client.get(reverse("webwhois:registry_object_type", kwargs={"handle": "testhandle.cz"})) self.assertContains(response, "Multiple entries found") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'testhandle.cz'), ('handleType', 'multiple'))), call.create_request().close(properties=[ ('foundType', 'contact'), ('foundType', 'domain'), ('foundType', 'keyset'), ('foundType', 'nsset'), ('foundType', 'registrar'), ]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('testhandle.cz'), call.get_nsset_by_handle('testhandle.cz'), call.get_keyset_by_handle('testhandle.cz'), call.get_registrar_by_handle('testhandle.cz'), call.get_domain_by_handle('testhandle.cz') ])
def test_keyset_invalid_handle(self): WHOIS.get_keyset_by_handle.side_effect = INVALID_HANDLE response = self.client.get(reverse("webwhois:detail_keyset", kwargs={"handle": "mykeysid"})) self.assertContains(response, "Invalid handle") self.assertContains(response, "<strong>mykeysid</strong> is not a valid handle.") self.assertNotContains(response, 'Register this domain name?') self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mykeysid'), ('handleType', 'keyset'))), call.create_request().close(properties=[('reason', 'INVALID_HANDLE')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'NotFound') self.assertEqual(WHOIS.mock_calls, [call.get_keyset_by_handle('mykeysid')])
def test_keyset_not_found(self): WHOIS.get_keyset_by_handle.side_effect = OBJECT_NOT_FOUND response = self.client.get(reverse("webwhois:detail_keyset", kwargs={"handle": "mykeysid"})) self.assertContains(response, 'Key server set not found') self.assertContains(response, 'No key set matches <strong>mykeysid</strong> handle.') self.assertNotContains(response, 'Register this domain name?') self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mykeysid'), ('handleType', 'keyset'))), call.create_request().close(properties=[]) ]) self.assertEqual(self.LOGGER.create_request().result, 'NotFound') self.assertEqual(WHOIS.mock_calls, [call.get_keyset_by_handle('mykeysid')])
def test_handle_with_dash_not_found(self): WHOIS.get_contact_by_handle.side_effect = OBJECT_NOT_FOUND WHOIS.get_nsset_by_handle.side_effect = OBJECT_NOT_FOUND WHOIS.get_keyset_by_handle.side_effect = OBJECT_NOT_FOUND WHOIS.get_registrar_by_handle.side_effect = OBJECT_NOT_FOUND WHOIS.get_managed_zone_list.return_value = [] response = self.client.get(reverse("webwhois:registry_object_type", kwargs={"handle": "-abc"})) self.assertContains(response, "Record not found") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', '-abc'), ('handleType', 'multiple'))), call.create_request().close(properties=[]) ]) self.assertEqual(self.LOGGER.create_request().result, 'NotFound') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('-abc'), call.get_nsset_by_handle('-abc'), call.get_keyset_by_handle('-abc'), call.get_registrar_by_handle('-abc'), call.get_managed_zone_list(), ])
def test_keyset(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact() WHOIS.get_keyset_status_descriptions.return_value = self._get_keyset_status() WHOIS.get_keyset_by_handle.return_value = self._get_keyset() WHOIS.get_registrar_by_handle.return_value = self._get_registrar() response = self.client.get(reverse("webwhois:detail_keyset", kwargs={"handle": "mykeysid"})) self.assertContains(response, "Key set details") self.assertContains(response, "Search results for handle <strong>mykeysid</strong>:") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mykeysid'), ('handleType', 'keyset'))), call.create_request().close(properties=[('foundType', 'keyset')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_keyset_by_handle('mykeysid'), call.get_keyset_status_descriptions('en'), call.get_contact_by_handle('KONTAKT'), call.get_registrar_by_handle('REG-FRED_A') ])