Example #1
0
def test_record_list_function():
    """Record list function sends properly formated request."""
    response = record.list('example.com', host='ns1')
    assert response.success

    payload = response.payload
    assert payload['url'] == 'https://api.cloudns.net/dns/records.json'
    assert payload['params']['domain-name'] == 'example.com'
    assert payload['params']['host'] == 'ns1'
Example #2
0
    def delete_dns_record(self, domain_name, domain_dns_value):
        self.logger.info("delete_dns_record")
        domain_name, host = _split_domain_name(domain_name)
        response = record.list(domain_name=domain_name, host=host, record_type="TXT")

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

        for record_id, item in response.payload.items():
            if item["record"] == domain_dns_value:
                response = record.delete(domain_name=domain_name, record_id=record_id)
                if not response.success:
                    self.logger.info("ClouDNS could not delete DNS record.")
                    raise Exception("ClouDNS responded with an error.")
                self.logger.info("delete_dns_record_success")
                return

        self.logger.info("ClouDNS could not find DNS record to delete.")
        raise Exception("ClouDNS responded with an error.")