def test_domains_dns_bulkAddHosts(): api = Api(username, api_key, username, ip_address, sandbox=True) api.payload_limit = 3 domain_name = test_register_domain() api.domains_dns_setHosts(domain_name, [{ 'HostName': '@', 'RecordType': 'URL', 'Address': 'http://news.ycombinator.com' }]) for i in range(1, 10): api.domains_dns_addHost( domain_name, { 'Name': "test" + str(i), 'Type': 'A', 'Address': '1.2.3.4', 'TTL': '60' }) hosts = api.domains_dns_getHosts(domain_name) if len(hosts) == 10: return True return False
def test_domains_dns_addHost(): api = Api(username, api_key, username, ip_address, sandbox=True) domain_name = test_register_domain() api.domains_dns_setHosts( domain_name, [{ 'HostName': '@', 'RecordType': 'URL', 'Address': 'http://news.ycombinator.com' }] ) api.domains_dns_addHost( domain_name, { 'Name': 'test', 'Type': 'A', 'Address': '1.2.3.4', 'TTL': '100' } ) hosts = api.domains_dns_getHosts(domain_name) # these might change del hosts[0]['HostId'] del hosts[1]['HostId'] expected_result = [ { 'Name': 'test', 'Address': '1.2.3.4', 'TTL': '100', 'Type': 'A', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': 'true', 'IsDDNSEnabled': 'false' }, { 'Name': '@', 'Address': 'http://news.ycombinator.com', 'TTL': '1800', 'Type': 'URL', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': 'true', 'IsDDNSEnabled': 'false' } ] assert_equal(hosts, expected_result)
def test_domains_dns_addHost(): api = Api(username, api_key, username, ip_address, sandbox=True) domain_name = test_register_domain() api.domains_dns_setHosts(domain_name, [{ 'HostName': '@', 'RecordType': 'URL', 'Address': 'http://news.ycombinator.com' }]) api.domains_dns_addHost(domain_name, { 'Name': 'test', 'Type': 'A', 'Address': '1.2.3.4', 'TTL': '100' }) hosts = api.domains_dns_getHosts(domain_name) # these might change del hosts[0]['HostId'] del hosts[1]['HostId'] expected_result = [{ 'Name': 'test', 'Address': '1.2.3.4', 'TTL': '100', 'Type': 'A', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': 'true', 'IsDDNSEnabled': 'false' }, { 'Name': '@', 'Address': 'http://news.ycombinator.com', 'TTL': '1800', 'Type': 'URL', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': 'true', 'IsDDNSEnabled': 'false' }] assert_equal(hosts, expected_result)
def create_a_records(user, key) -> None: ip = requests.get('http://ifconfig.me') for i in tqdm(range(len(services))): record = { "Type": "A", "Name": services[i], "Address": ip, "TTL": "1799", } api = Api(user, key, user, ip.text, sandbox=False, attempts_count=3, attempts_delay=0.1) import sys sys.stdout = None api.domains_dns_addHost(os.environ['DOMAIN'], record) sys.stdout = sys.__stdout__ print(f'✅ SUCCESS: {len(services)} A Record(s) successfully created!')
def test_domains_dns_bulkAddHosts(): api = Api(username, api_key, username, ip_address, sandbox=True) api.payload_limit = 3 domain_name = test_register_domain() api.domains_dns_setHosts( domain_name, [{ 'HostName': '@', 'RecordType': 'URL', 'Address': 'http://news.ycombinator.com' }] ) for i in range(1, 10): api.domains_dns_addHost( domain_name, {'Name': "test" + str(i), 'Type': 'A', 'Address': '1.2.3.4', 'TTL': '60'} ) hosts = api.domains_dns_getHosts(domain_name) if len(hosts) == 10: return True return False