Ejemplo n.º 1
0
def test_record_create_function_catches_validation_errors():
    """Record create function catches validation errors."""
    response = record.create('not a valid domain',
                             host='',
                             record_type='A',
                             record='10.10.10.10',
                             ttl=3600)

    assert not response.success
    assert response.json()['error'] == 'Validation error.'
Ejemplo n.º 2
0
    def create_dns_record(self, domain_name, domain_dns_value):
        self.logger.info("create_dns_record")
        domain_name, host = _split_domain_name(domain_name)
        response = record.create(
            domain_name=domain_name, host=host, record_type="TXT", record=domain_dns_value, ttl=60
        )

        if not response.success:
            self.logger.info("ClouDNS could not create DNS record.")
            raise Exception("ClouDNS responded with an error.")

        self.logger.info("create_dns_record_success")
        return
Ejemplo n.º 3
0
def test_record_create_function():
    """Record create function sends properly formated update request."""
    response = record.create('example.com',
                             host='',
                             record_type='A',
                             record='10.10.10.10',
                             ttl=3600)

    assert response.success

    payload = response.payload
    assert payload['url'] == 'https://api.cloudns.net/dns/add-record.json'
    assert payload['params']['record-type'] == 'A'
    assert payload['params']['domain-name'] == 'example.com'
    assert payload['params']['host'] == ''
    assert payload['params']['record'] == '10.10.10.10'
    assert payload['params']['ttl'] == 3600