Ejemplo n.º 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'
Ejemplo n.º 2
0
def test_domain_not_exist():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable
    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 = 'this-domain-not-exist.%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?', 'DONE', 'response'),
    ]
    assert len(outputs) == 1
    assert outputs[0] is None
Ejemplo n.º 3
0
def domain_synchronize_from_backend(domain_name,
                                    refresh_contacts=False,
                                    change_owner_allowed=False,
                                    raise_errors=False,
                                    log_events=True,
                                    log_transitions=True):
    """
    Requests domain info from backend and take required actions to update local DB
    to be fully in sync with  backend.
    If domain not exists in local DB it will be created.
    Returns False if error happened, or raise Exception if `raise_errors` is True,
    if all is okay returns domain object from local DB.
    """
    dr = domain_refresher.DomainRefresher(
        log_events=log_events,
        log_transitions=log_transitions,
        raise_errors=raise_errors,
    )
    dr.event(
        'run',
        domain_name=domain_name,
        change_owner_allowed=change_owner_allowed,
        refresh_contacts=refresh_contacts,
    )
    outputs = list(dr.outputs)
    del dr
    logger.debug('domain_refresher(%r) finished with %d outputs', domain_name,
                 len(outputs))
    return outputs
Ejemplo n.º 4
0
 def doRunDomainRefresher(self, *args, **kwargs):
     """
     Action method.
     """
     dr = domain_refresher.DomainRefresher(
         log_events=self.log_events,
         log_transitions=self.log_transitions,
         raise_errors=self.raise_errors,
     )
     try:
         dr.event(
             'run',
             domain_name=self.target_domain.name,
             change_owner_allowed=False,
             refresh_contacts=False,
         )
     except Exception as exc:
         self.log(self.debug_level,
                  'Exception in DomainRefresher: %s' % exc)
         del dr
         self.event('refresh-failed', exc)
     else:
         self.outputs.extend(list(dr.outputs))
         del dr
         self.event('refresh-ok')
Ejemplo n.º 5
0
def domain_synchronize_from_backend(domain_name,
                                    refresh_contacts=False,
                                    rewrite_contacts=None,
                                    change_owner_allowed=False,
                                    create_new_owner_allowed=False,
                                    expected_owner=None,
                                    soft_delete=True,
                                    domain_transferred_away=False,
                                    raise_errors=False,
                                    log_events=True,
                                    log_transitions=True):
    """
    Requests domain info from back-end and take required actions to update local DB
    to be in sync with COCCA back-end, but with some limitations.
    If domain not exists in local DB it will be created.
    If domain not exist on COCCA anymore, or owned by another registrar it will be removed from local DB,
    but only if `soft_delete=False`. Otherwise marked as INACTIVE.
    Skip any actions with domain contacts if `refresh_contacts=False`.
    If `rewrite_contacts=True` will actually first write current contact IDs is from DB to COCCA and
    then do the full contacts details synchronization, thus actually rewrite contacts on back-end.
    """
    dr = domain_refresher.DomainRefresher(
        log_events=log_events,
        log_transitions=log_transitions,
        raise_errors=raise_errors,
    )
    outputs = []
    try:
        dr.event(
            'run',
            domain_name=domain_name,
            change_owner_allowed=change_owner_allowed,
            create_new_owner_allowed=create_new_owner_allowed,
            expected_owner=expected_owner,
            refresh_contacts=refresh_contacts,
            rewrite_contacts=rewrite_contacts,
            soft_delete=soft_delete,
            domain_transferred_away=domain_transferred_away,
        )
        outputs = list(dr.outputs)
    except rpc_error.EPPError as exc:
        dr.destroy()
        outputs = [
            exc,
        ]
    del dr
    logger.info('domain_refresher(%r) finished with %d outputs', domain_name,
                len(outputs))
    return outputs
Ejemplo n.º 6
0
def domain_synchronize_from_backend(domain_name,
                                    refresh_contacts=False,
                                    change_owner_allowed=False,
                                    create_new_owner_allowed=False,
                                    soft_delete=True,
                                    domain_transferred_away=False,
                                    raise_errors=False,
                                    log_events=True,
                                    log_transitions=True):
    """
    Requests domain info from back-end and take required actions to update local DB
    to be fully in sync with COCCA back-end.
    If domain not exists in local DB it will be created.
    If domain not exist on COCCA anymore, or owned by another registrar it will be removed from local DB.
    Returns False if error happened, or raise Exception if `raise_errors` is True,
    if all is okay returns domain object from local DB.
    """
    dr = domain_refresher.DomainRefresher(
        log_events=log_events,
        log_transitions=log_transitions,
        raise_errors=raise_errors,
    )
    dr.event(
        'run',
        domain_name=domain_name,
        change_owner_allowed=change_owner_allowed,
        create_new_owner_allowed=create_new_owner_allowed,
        refresh_contacts=refresh_contacts,
        soft_delete=soft_delete,
        domain_transferred_away=domain_transferred_away,
    )
    outputs = list(dr.outputs)
    del dr
    logger.info('domain_refresher(%r) finished with %d outputs', domain_name,
                len(outputs))
    return outputs