Exemple #1
0
def test_domain_refreshed():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable
    testsupport.prepare_tester_registrant(epp_id='tester480126cf6j', create_new=True)
    scenario = []
    dr = domain_refresher.DomainRefresher(
        log_events=True,
        log_transitions=True,
    )
    dr.add_state_changed_callback(
        cb=lambda oldstate, newstate, event, *args, **kwargs: scenario.append(
            (oldstate, newstate, event, )
        ),
    )
    test_domain_name = 'test.%s' % settings.ZENAIDA_SUPPORTED_ZONES[0]
    dr.event(
        'run',
        domain_name=test_domain_name,
        change_owner_allowed=True,
        refresh_contacts=True,
    )
    outputs = list(dr.outputs)
    del dr
    assert scenario == [
        ('AT_STARTUP', 'EXISTS?', 'run'),
        ('EXISTS?', 'INFO?', 'response'),
        ('INFO?', 'CONTACTS?', 'response'),
        ('CONTACTS?', 'DONE', 'all-contacts-received'),
    ]
    assert len(outputs) == 5
    assert outputs[0]['epp']['response']['result']['@code'] == '1000'
    assert outputs[1]['epp']['response']['result']['@code'] == '1000'
    assert outputs[2]['epp']['response']['result']['@code'] == '1000'
    assert outputs[3]['epp']['response']['result']['@code'] == '1000'
    assert outputs[4]['epp']['response']['result']['@code'] == '1000'
Exemple #2
0
 def test_glue_record_not_supported(self, mock_messages_error):
     tester = prepare_tester_account()
     contact_admin = prepare_tester_contact(tester=tester)
     profile = prepare_tester_profile(tester=tester)
     prepare_tester_registrant(tester=tester, profile_object=profile)
     response = self.client.post('/domains/create/test.ai/',
                                 data=dict(nameserver1='ns1.test.ai',
                                           contact_admin=contact_admin.id))
     assert response.status_code == 302
     mock_messages_error.assert_called_once()
Exemple #3
0
def test_get_oldest_registrant():
    tester = testsupport.prepare_tester_account()
    assert zcontacts.get_oldest_registrant(tester) is None
    first_registrant = testsupport.prepare_tester_registrant(tester, epp_id='id1', create_new=True)
    assert zcontacts.registrant_exists(epp_id='id1') is True
    assert zcontacts.registrant_exists(epp_id='id2') is False
    assert zcontacts.registrant_find(epp_id='id1') == first_registrant
    assert zcontacts.get_oldest_registrant(tester) == first_registrant
    second_registrant = testsupport.prepare_tester_registrant(tester, epp_id='id2', create_new=True)
    assert zcontacts.registrant_exists(epp_id='id2') is True
    assert zcontacts.registrant_find(epp_id='id2') != first_registrant
    assert zcontacts.registrant_find(epp_id='id2') == second_registrant
    assert zcontacts.get_oldest_registrant(tester) == first_registrant
    zcontacts.registrant_delete(epp_id='id1')
    assert zcontacts.get_oldest_registrant(tester) == second_registrant
Exemple #4
0
 def test_nameserver_is_not_available(self, mock_ping, mock_gethostbyname):
     mock_ping.return_value = -1
     mock_gethostbyname.side_effect = socket.error('failed')
     tester = prepare_tester_account()
     contact_admin = prepare_tester_contact(tester=tester)
     profile = prepare_tester_profile(tester=tester)
     prepare_tester_registrant(tester=tester, profile_object=profile)
     response = self.client.post('/domains/create/test.ai/',
                                 data=dict(nameserver1='dns1.kuwaitnet.net',
                                           contact_admin=contact_admin.id))
     assert response.status_code == 200
     assert response.context['errors'] == [
         'List of nameservers that are not valid or not reachable at this '
         'moment: <br>dns1.kuwaitnet.net <br>Please try again later or '
         'specify valid and available nameservers.'
     ]
def test_domain_restore():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable
    if os.environ.get('MANUAL', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable

    # first need to read existing domain from back-end and create it in local DB
    testsupport.prepare_tester_registrant(epp_id='tester087401xo2c',
                                          create_new=True)
    zmaster.domain_synchronize_from_backend(
        'test-restore-0.ai',
        refresh_contacts=True,
        change_owner_allowed=False,
        soft_delete=False,
    )
    tester_domain = zdomains.domain_find(domain_name='test-restore-0.ai')
    assert tester_domain.epp_id is not None

    # now try to restore it
    scenario = []
    dr = domain_resurrector.DomainResurrector(
        log_events=True,
        log_transitions=True,
        raise_errors=True,
    )
    dr.add_state_changed_callback(
        cb=lambda oldstate, newstate, event, *args, **kwargs: scenario.append((
            oldstate,
            newstate,
            event,
        )),
    )
    dr.event('run', domain_object=tester_domain)
    outputs = list(dr.outputs)
    del dr

    # this domain must be restored now and renew for 2 years
    assert scenario == [
        ('AT_STARTUP', 'VERIFY?', 'run'),
        ('VERIFY?', 'RESTORE!', 'verify-ok'),
        ('RESTORE!', 'REFRESH', 'response'),
        ('REFRESH', 'RENEW', 'refresh-ok'),
        ('RENEW', 'RENEW', 'refresh-ok'),
    ]
    assert len(outputs) == 7
    assert tester_domain.epp_id is not None
def test_domain_pending_delete_status_not_set():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable

    # first need to read existing domain from back-end and create it in local DB
    testsupport.prepare_tester_registrant(epp_id='tester065480yp60',
                                          create_new=True)
    test_domain_name = 'test-pending-delete-status-not-set.%s' % settings.ZENAIDA_SUPPORTED_ZONES[
        0]
    zmaster.domain_synchronize_from_backend(
        domain_name=test_domain_name,
        refresh_contacts=True,
        change_owner_allowed=False,
        soft_delete=False,
    )
    tester_domain = zdomains.domain_find(domain_name=test_domain_name)
    assert tester_domain.epp_id is not None

    # now try to restore it
    scenario = []
    dr = domain_resurrector.DomainResurrector(
        log_events=True,
        log_transitions=True,
        raise_errors=True,
    )
    dr.add_state_changed_callback(
        cb=lambda oldstate, newstate, event, *args, **kwargs: scenario.append((
            oldstate,
            newstate,
            event,
        )),
    )
    dr.event('run', domain_object=tester_domain)
    outputs = list(dr.outputs)
    del dr

    # this domain is not possible to restore because status is not pending delete
    assert scenario == [
        ('AT_STARTUP', 'VERIFY?', 'run'),
        ('VERIFY?', 'RESTORE!', 'verify-ok'),
        ('RESTORE!', 'FAILED', 'error'),
    ]
    assert tester_domain.epp_id is not None
    assert len(outputs) == 5
    assert isinstance(outputs[-1], Exception)
Exemple #7
0
def test_registrant_find_by_epp_id():
    tester = testsupport.prepare_tester_account(email='*****@*****.**')
    tester_registrant = testsupport.prepare_tester_registrant(tester=tester, epp_id='reg1234', profile_object=tester.profile, create_new=True)
    assert zcontacts.registrant_find(epp_id='reg1234') == tester_registrant