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_contact_invalid_handle_escaped(self): WHOIS.get_contact_by_handle.side_effect = INVALID_HANDLE response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "test<handle"})) self.assertContains(response, "Invalid handle") self.assertContains(response, "<strong>test<handle</strong> is not a valid handle.") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'test<handle'), ('handleType', 'contact'))), call.create_request().close(properties=[('reason', 'INVALID_HANDLE')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'NotFound') self.assertEqual(WHOIS.mock_calls, [call.get_contact_by_handle('test<handle')])
def test_domain_without_nsset_and_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_domain_status_descriptions.return_value = self._get_domain_status() WHOIS.get_domain_by_handle.return_value = self._get_domain(nsset_handle=None, keyset_handle=None) WHOIS.get_registrar_by_handle.return_value = self._get_registrar() response = self.client.get(reverse("webwhois:detail_domain", kwargs={"handle": "fred.cz"})) self.assertContains(response, "Domain name details") self.assertContains(response, "Search results for handle <strong>fred.cz</strong>:") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'fred.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('fred.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') ])
def test_contact_not_found(self): WHOIS.get_contact_by_handle.side_effect = OBJECT_NOT_FOUND response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "testhandle"})) self.assertContains(response, 'Contact not found') self.assertContains(response, 'No contact matches <strong>testhandle</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', 'testhandle'), ('handleType', 'contact'))), call.create_request().close(properties=[]) ]) self.assertEqual(self.LOGGER.create_request().result, 'NotFound') self.assertEqual(WHOIS.mock_calls, [call.get_contact_by_handle('testhandle')])
def test_contact_without_registrars_handle(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact(creating_registrar_handle="", sponsoring_registrar_handle="") response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "mycontact"})) self.assertContains(response, "Contact details") self.assertContains(response, "Search results for handle <strong>mycontact</strong>:") self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mycontact'), ('handleType', 'contact'))), call.create_request().close(properties=[('foundType', 'contact')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('mycontact'), call.get_contact_status_descriptions('en') ])
def test_contact_linked(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact() WHOIS.get_registrar_by_handle.return_value = self._get_registrar() response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "mycontact"})) self.assertContains(response, "Contact details") self.assertContains(response, "Search results for handle <strong>mycontact</strong>:") self.assertTrue(response.context['registry_objects']['contact']['is_linked']) self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mycontact'), ('handleType', 'contact'))), call.create_request().close(properties=[('foundType', 'contact')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('mycontact'), call.get_contact_status_descriptions('en'), call.get_registrar_by_handle('REG-FRED_A'), call.get_registrar_by_handle('REG-FRED_A') ])
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') ])
def test_contact_verification_ok(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact(statuses=[STATUS_LINKED, STATUS_VALIDATED]) WHOIS.get_registrar_by_handle.return_value = self._get_registrar() response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "mycontact"})) self.assertContains(response, "Contact details") verification_status = response.context["registry_objects"]['contact']['verification_status'] self.assertEqual(verification_status[0]['code'], STATUS_VALIDATED) self.assertEqual(verification_status[0]['icon'], 'webwhois/img/icon-yes.gif') self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mycontact'), ('handleType', 'contact'))), call.create_request().close(properties=[('foundType', 'contact')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('mycontact'), call.get_contact_status_descriptions('en'), call.get_registrar_by_handle('REG-FRED_A'), call.get_registrar_by_handle('REG-FRED_A') ])
def test_contact_with_invalid_birthday_value(self): WHOIS.get_contact_status_descriptions.return_value = self._get_contact_status() WHOIS.get_contact_by_handle.return_value = self._get_contact( identification=DisclosableContactIdentification( value=ContactIdentification(identification_type='BIRTHDAY', identification_data='FOO'), disclose=True)) WHOIS.get_registrar_by_handle.return_value = self._get_registrar() response = self.client.get(reverse("webwhois:detail_contact", kwargs={"handle": "mycontact"})) self.assertContains(response, "Contact details") self.assertEqual(response.context['registry_objects']['contact']['birthday'], 'FOO') self.assertEqual(self.LOGGER.mock_calls, [ CALL_BOOL, call.create_request('127.0.0.1', 'Web whois', 'Info', properties=( ('handle', 'mycontact'), ('handleType', 'contact'))), call.create_request().close(properties=[('foundType', 'contact')]) ]) self.assertEqual(self.LOGGER.create_request().result, 'Ok') self.assertEqual(WHOIS.mock_calls, [ call.get_contact_by_handle('mycontact'), call.get_contact_status_descriptions('en'), call.get_registrar_by_handle('REG-FRED_A'), call.get_registrar_by_handle('REG-FRED_A') ])