def test_manage_domain_url(self):
     domain = Domain()
     domain.id = '1012705422'
     domain.name = 'domain.cf'
     self.assertEqual(
         'https://my.freenom.com/clientarea.php?managedns=domain.cf&domainid=1012705422',
         self.freenom.manage_domain_url(domain))
    def test_update_record_fail(self):
        domain = Domain()
        domain.id = TEST_DOMAIN_ID
        domain.name = TEST_DOMAIN_NAME

        record = Record()
        record.domain = domain
        record.name = "TESTUPDATEBUG"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        cleanup = self.add_record_if_missing(record)
        original_record = copy(record)
        records_before = self.freenom.list_records(domain)
        record.target = "185.45.193.%d" % random.randint(
            1000, 3500)  # this is an invalid ip address
        try:
            self.freenom.update_record(record)
        except UpdateError as e:
            self.assertEqual(1, len(e.msgs))
            self.assertIn('Error occured: Invalid value in dnsrecord', e.msgs)
            self.assertEqual(record, e.record)
            self.assertListEqual(records_before, e.old_record_list)
        else:
            self.fail("exception %s expected " % UpdateError.__name__)
        finally:
            if cleanup:
                self.freenom.remove_record(original_record)
Example #3
0
    def test_update_record_fail(self):
        domain = Domain()
        domain.id = '1012700019'
        domain.name = 'freenom-dns-updater.cf'

        record = Record()
        record.domain = domain
        record.name = "TESTUPDATEBUG"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        self.add_record_if_missing(record)
        records_before = self.freenom.list_records(domain)
        record.target = "185.45.193.%d" % random.randint(1000, 3500)
        try:
            self.freenom.update_record(record)
        except UpdateError as e:
            self.assertEqual(1, len(e.msgs))
            self.assertIn('Error occured: Invalid value in dnsrecord', e.msgs)
            self.assertEqual(record, e.record)
            self.assertListEqual(records_before, e.old_record_list)
        else:
            self.fail("exception %s expected " % UpdateError.__name__)
        finally:
            self.freenom.remove_record(record)
    def test_update_record_fail(self):
        domain = Domain()
        domain.id = "1012700019"
        domain.name = "freenom-dns-updater.cf"

        record = Record()
        record.domain = domain
        record.name = "TESTUPDATEBUG"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        self.add_record_if_missing(record)
        records_before = self.freenom.list_records(domain)
        record.target = "185.45.193.%d" % random.randint(1000, 3500)
        try:
            self.freenom.update_record(record)
        except UpdateError as e:
            self.assertEqual(1, len(e.msgs))
            self.assertIn("Error occured: Invalid value in dnsrecord", e.msgs)
            self.assertEqual(record, e.record)
            self.assertListEqual(records_before, e.old_record_list)
        else:
            self.fail("exception %s expected " % UpdateError.__name__)
        finally:
            self.freenom.remove_record(record)
 def test_manage_domain_url(self):
     domain = Domain()
     domain.id = "1012705422"
     domain.name = "domain.cf"
     self.assertEqual(
         "https://my.freenom.com/clientarea.php?managedns=domain.cf&domainid=1012705422",
         self.freenom.manage_domain_url(domain),
     )
Example #6
0
 def test_parse_domains(self):
     path = pathlib.Path(__file__).parent / "resources" / "domain_page.html"
     with path.open() as f:
         html = f.read()
     domains = DomainParser.parse(html)
     self.assertEqual(2, len(domains))
     expected = Domain()
     expected.id = "1065251102"
     expected.name = "domain.tk"
     expected.register_date = datetime.date(year=2016, month=2, day=9)
     expected.expire_date = datetime.date(year=2017, month=2, day=9)
     expected.state = "Active"
     expected.type = "Free"
     self.assertIn(expected, domains)
    def test_remove_record(self):
        domain = Domain()
        domain.id = TEST_DOMAIN_ID
        domain.name = TEST_DOMAIN_NAME

        record = Record()
        record.domain = domain
        record.name = "TESTREMOVE"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        self.add_record_if_missing(record)

        res = self.freenom.remove_record(record)
        self.assertTrue(res)
        self.assertNotIn(record, self.freenom.list_records(domain))
Example #8
0
    def test_remove_record(self):
        domain = Domain()
        domain.id = '1012700019'
        domain.name = 'freenom-dns-updater.cf'

        record = Record()
        record.domain = domain
        record.name = "TESTREMOVE"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        self.add_record_if_missing(record)

        res = self.freenom.remove_record(record)
        self.assertTrue(res)
        self.assertNotIn(record, self.freenom.list_records(domain))
    def test_remove_record(self):
        domain = Domain()
        domain.id = "1012700019"
        domain.name = "freenom-dns-updater.cf"

        record = Record()
        record.domain = domain
        record.name = "TESTREMOVE"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = 14440

        self.test_login()
        self.add_record_if_missing(record)

        res = self.freenom.remove_record(record)
        self.assertTrue(res)
        self.assertNotIn(record, self.freenom.list_records(domain))
Example #10
0
    def test_add_record(self):
        domain = Domain()
        domain.id = TEST_DOMAIN_ID
        domain.name = TEST_DOMAIN_NAME

        record = Record()
        record.domain = domain
        record.name = "TESTADD"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = random.choice((14440, 14440 / 2, 14440 * 2))

        self.test_login()
        self.remove_record_if_exists(record)
        try:
            res = self.freenom.add_record(record)
            self.assertTrue(bool(res))
            records = self.freenom.list_records(domain)
            self.assertIn(record, records)
        finally:
            self.freenom.remove_record(record)
    def test_add_record(self):
        domain = Domain()
        domain.id = "1012700019"
        domain.name = "freenom-dns-updater.cf"

        record = Record()
        record.domain = domain
        record.name = "TESTADD"
        record.type = RecordType.A
        record.target = "185.45.193.%d" % random.randint(5, 200)
        record.ttl = random.choice((14440, 14440 / 2, 14440 * 2))

        self.test_login()
        self.remove_record_if_exists(record)
        try:
            res = self.freenom.add_record(record)
            self.assertTrue(bool(res))
            records = self.freenom.list_records(domain)
            self.assertIn(record, records)
        finally:
            self.freenom.remove_record(record)