Beispiel #1
0
    def test_method_set_record_updated(self, Resolver, Update, tcp):
        resolver = Resolver.return_value
        resolver.query.side_effect = [['1.2.3.4'], ['1.2.3.5']]
        update = Update.return_value

        dns = DnsUpdate('127.0.0.1', names, ipaddresses)
        dns.record_name = 'www'
        result = dns._set_record('1.2.3.5', 4)

        update.delete.assert_has_calls([
            mock.call('www.example.com.', 'a'),
            mock.call('www.example.com.', 'aaaa'),
        ])
        update.add.assert_called_with('www.example.com.', 300, 'a', '1.2.3.5')
        self.assertEqual(tcp.call_args[1]['where'], '127.0.0.1')
        Update.assert_called()

        self.assertEqual(
            result,
            {
                'ip_version': 4,
                'new_ip': '1.2.3.5',
                'old_ip': '1.2.3.4',
                'status': 'UPDATED'
            },
        )
Beispiel #2
0
    def test_method_set_record_error(self, Resolver, Update, tcp):
        resolver = Resolver.return_value
        resolver.query.return_value = ['1.2.3.4']

        dns = DnsUpdate('127.0.0.1', names, ipaddresses)
        dns.record_name = 'www'
        result = dns._set_record('1.2.3.5', 4)

        self.assertEqual(
            result,
            {'ip_version': 4, 'new_ip': '1.2.3.5', 'old_ip': '1.2.3.4',
             'status': 'DNS_SERVER_ERROR'},
        )
Beispiel #3
0
    def test_method_set_record_unchanged(self, Resolver, Update, tcp):
        resolver = Resolver.return_value
        resolver.query.return_value = ['1.2.3.4']
        update = Update.return_value

        dns = DnsUpdate('127.0.0.1', names, ipaddresses)
        dns.record_name = 'www'
        result = dns._set_record('1.2.3.4', 4)

        update.delete.assert_not_called()
        update.add.assert_not_called()

        self.assertEqual(
            result,
            {'ip_version': 4, 'new_ip': '1.2.3.4', 'old_ip': '1.2.3.4',
             'status': 'UNCHANGED'},
        )