Exemplo n.º 1
0
def test_domain_not_exist():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable
    scenario = []
    dtr = domain_transfer_requestor.DomainTransferRequestor(
        log_events=True,
        log_transitions=True,
    )
    dtr.add_state_changed_callback(
        cb=lambda oldstate, newstate, event, *args, **kwargs: scenario.append((
            oldstate,
            newstate,
            event,
        )),
    )
    new_auth_info = zdomains.generate_random_auth_info()
    dtr.event('run',
              target_domain_name='this-domain-not-exist.ai',
              auth_info=new_auth_info)
    outputs = list(dtr.outputs)
    del dtr
    assert scenario == [
        ('AT_STARTUP', 'DOMAIN_INFO', 'run'),
        ('DOMAIN_INFO', 'FAIL', 'response'),
    ]
    assert len(outputs) == 1
    assert outputs[0]
    assert isinstance(outputs[0], zerrors.EPPUnexpectedResponse)
Exemplo n.º 2
0
def test_transfer_request_sent():
    if os.environ.get('E2E', '0') != '1':
        return pytest.skip('skip E2E')  # @UndefinedVariable
    scenario = []
    dtr = domain_transfer_requestor.DomainTransferRequestor(
        skip_info=False,
        auth_info_verify=False,
        log_events=True,
        log_transitions=True,
    )
    dtr.add_state_changed_callback(
        cb=lambda oldstate, newstate, event, *args, **kwargs: scenario.append((
            oldstate,
            newstate,
            event,
        )),
    )
    dtr.event('run',
              target_domain_name='can-not-be-transferred.ai',
              auth_info='abc123')
    outputs = list(dtr.outputs)
    del dtr
    assert scenario == [
        ('AT_STARTUP', 'DOMAIN_INFO', 'run'),
        ('DOMAIN_INFO', 'FAIL', 'response'),
    ]
    assert len(outputs) == 1
    assert outputs[0]
    assert isinstance(outputs[0], zerrors.EPPRegistrarAuthFailed)
Exemplo n.º 3
0
def domain_transfer_request(domain,
                            auth_info,
                            skip_info=False,
                            raise_errors=False,
                            log_events=True,
                            log_transitions=True):
    """
    Sending domain transfer request to the back-end. As soon as back-end process the request and accept transfer
    new event message suppose to be received via polling script and new domain object will be created in Zenaida DB.
    This method only initiate the request. You must provide "authentication code" for that domain
    to be able to transfer it to Zenaida.  
    """
    from automats import domain_transfer_requestor
    dtr = domain_transfer_requestor.DomainTransferRequestor(
        skip_info=skip_info,
        log_events=log_events,
        log_transitions=log_transitions,
        raise_errors=raise_errors,
    )
    dtr.event('run', target_domain_name=domain, auth_info=auth_info)
    outputs = list(dtr.outputs)
    del dtr

    if not outputs or not outputs[-1] or isinstance(outputs[-1], Exception):
        if isinstance(outputs[-1], Exception):
            logger.error('domain_transfer_request(%r) failed with: %r', domain,
                         outputs[-1])
        return False

    logger.info('domain_transfer_request(%r) finished with %d outputs', domain,
                len(outputs))
    return True