Ejemplo n.º 1
0
    def test_dns_management(self):
        filename = _test_filename('dns_bindings.csv')
        manager = Command()
        manager.run_from_argv(['manage.py', 'ipdnsauth', 'dns',
                                '--load', filename])
        self.assertTrue(User.objects
                            .filter(username='******')
                            .filter(dnstouser__dns_name='localhost')
                            .exists())

        loaded = manager.export_data('dns', DnsToUser.objects)
        expected = (('test_user', 'localhost'),
                    ('test_user2', 'some.dotted.domain'),
                    )
        self.assertItemsEqual(expected, loaded)

        manager.run_from_argv(['manage.py', 'ipdnsauth', 'dns',
                                '--unload', filename])
        loaded = manager.export_data('dns', DnsToUser.objects)
        self.assertEquals(len(loaded), 0)
Ejemplo n.º 2
0
    def test_ip_management(self):
        filename = _test_filename('ip_bindings.csv')
        manager = Command()
        manager.run_from_argv(['manage.py', 'ipdnsauth', 'ip',
                                '--load', filename])
        self.assertTrue(User.objects
                            .filter(username='******')
                            .filter(iptouser__ip_addr='127.0.0.1')
                            .exists())

        loaded = manager.export_data('ip', IpToUser.objects)
        expected = (('test_user', '127.0.0.1'),
                    ('test_user', '127.0.0.3'),
                    ('test_user2', 'fe80::762f:68ff:fedd:9bd8'),
                    )
        self.assertItemsEqual(expected, loaded)

        manager.clear('ip', IpToUser.objects)
        loaded = manager.export_data('ip', IpToUser.objects)
        self.assertEquals(len(loaded), 0)
Ejemplo n.º 3
0
    def test_dns_management(self):
        filename = _test_filename('dns_bindings.csv')
        manager = Command()
        manager.run_from_argv(['manage.py', 'ipdnsauth', 'dns',
                                '--load', filename])
        self.assertTrue(User.objects.filter(username='******',
                                        dnstouser__dns_name='localhost'
                                        ).exists())

        loaded = manager.export_data('dns', DnsToUser.objects)
        expected = (('test_user', 'localhost'),
                    ('test_user2', 'some.dotted.domain'),
                    )
        self.assertItemsEqual(expected, loaded)

        manager.run_from_argv(['manage.py', 'ipdnsauth', 'dns',
                                '--unload', filename])
        loaded = manager.export_data('dns', DnsToUser.objects)
        self.assertEquals(len(loaded), 0)
Ejemplo n.º 4
0
    def test_ip_management(self):
        filename = _test_filename('ip_bindings.csv')
        manager = Command()
        manager.run_from_argv(['manage.py', 'ipdnsauth', 'ip',
                                '--load', filename])
        self.assertTrue(User.objects.filter(username='******',
                                        iptouser__ip_addr='127.0.0.1'
                                        ).exists())

        loaded = manager.export_data('ip', IpToUser.objects)
        expected = (('test_user', '127.0.0.1'),
                    ('test_user', '127.0.0.3'),
                    ('test_user2', 'fe80::762f:68ff:fedd:9bd8'),
                    )
        self.assertItemsEqual(expected, loaded)

        manager.clear('ip', IpToUser.objects)
        loaded = manager.export_data('ip', IpToUser.objects)
        self.assertEquals(len(loaded), 0)