Exemplo n.º 1
0
    def test_01_create_and_delete_resolver(self):
        r = Resolver("try_delete", "passwdresolver")
        rid = r.save()
        self.assertTrue(r.name is not None, r.name)
        self.assertTrue(r.rtype is not None, r.rtype)
        # Add configuration to the resolver
        conf = ResolverConfig(r.id, "fileName",
                              "this_very_specific_file_try_delete")
        conf.save()

        # Read Resolver
        r1 = Resolver.query.filter_by(name="try_delete").first()
        self.assertTrue(r1.rtype == "passwdresolver", r1.rtype)
        self.assertEqual(rid, r1.id)

        # Get the option
        rc = ResolverConfig.query.filter_by(
            Value="this_very_specific_file_try_delete").first()
        self.assertTrue(rc)
        self.assertEqual(rc.resolver_id, rid)

        # Now delete the Resolver and check, if there is no config left
        reso = Resolver.query.filter_by(name="try_delete").first()
        reso.delete()
        rc = ResolverConfig.query.filter_by(
            Value="this_very_specific_file_try_delete").first()
        self.assertIsNone(rc)
Exemplo n.º 2
0
    def create_resolver_realm(self):
        r = Resolver("resolver1", "passwdresolver")
        r.save()
        self.assertTrue(r.name is not None, r.name)
        self.assertTrue(r.rtype is not None, r.rtype)
        # Add configuration to the resolver
        conf = ResolverConfig(r.id, "fileName", "tests/testdata/passwd")
        conf.save()

        # Read Resolver
        r1 = Resolver.query.filter_by(name="resolver1").first()
        self.assertTrue(r1.rtype == "passwdresolver", r1.rtype)

        realm = Realm("realm1")
        realm.save()
        # Put the resolver into the realm
        rrealm = ResolverRealm(resolver_name="resolver1", realm_name="realm1")
        rrealm.save()
Exemplo n.º 3
0
 def create_resolver_realm(self):
     r = Resolver("resolver1", "passwdresolver")
     r.save()
     self.assertTrue(r.name is not None, r.name)
     self.assertTrue(r.rtype is not None, r.rtype)
     # Add configuration to the resolver
     conf = ResolverConfig(r.id, "fileName", "tests/testdata/passwd")
     conf.save()
     
     # Read Resolver
     r1 = Resolver.query.filter_by(name="resolver1").first()
     self.assertTrue(r1.rtype == "passwdresolver", r1.rtype)
     
     realm = Realm("realm1")
     realm.save()
     # Put the resolver into the realm
     rrealm = ResolverRealm(resolver_name="resolver1",
                            realm_name="realm1")
     rrealm.save()
Exemplo n.º 4
0
    def test_create_resolver(self):
        r = Resolver("r1", "passwdresolver")
        db.session.add(r)
        db.session.commit()
        self.assertTrue(r.name is not None, r.name)
        self.assertTrue(r.rtype is not None, r.rtype)
        # Add configuration to the resolver
        conf = ResolverConfig(r.id, "fileName", "somevalue")
        db.session.add(conf)
        db.session.commit()

        # Read Resolver
        r1 = Resolver.query.filter_by(name="r1").first()
        self.assertTrue(r1.rtype == "passwdresolver", r1.rtype)
Exemplo n.º 5
0
 def test_04_update_resolver_config(self):
     resolvername = "resolver2"
     r = Resolver(resolvername, "passwdresolver")
     rid = r.save()
     self.assertTrue(r.name is not None, r.name)
     self.assertTrue(r.rtype == "passwdresolver", r.rtype)
     # save first resolver config
     rc = ResolverConfig(resolver=resolvername,
                         Key="fileName",
                         Value="/etc/passwd")
     res_conf_id = rc.save()
     self.assertTrue(res_conf_id > 0, res_conf_id)
     # update resolver config
     rc = ResolverConfig(resolver=resolvername,
                         Key="fileName",
                         Value="/etc/secureusers")
     res_conf_id2 = rc.save()
     self.assertTrue(res_conf_id2 == res_conf_id,
                     res_conf_id2)
     # delete resolver and its config
     r.delete()
     # check that config is empty
     q = ResolverConfig.query.filter_by(resolver_id=rid).all()
     self.assertTrue(len(q) == 0, q)
Exemplo n.º 6
0
 def test_04_update_resolver_config(self):
     resolvername = "resolver2"
     r = Resolver(resolvername, "passwdresolver")
     rid = r.save()
     self.assertTrue(r.name is not None, r.name)
     self.assertTrue(r.rtype == "passwdresolver", r.rtype)
     # save first resolver config
     rc = ResolverConfig(resolver=resolvername,
                         Key="fileName",
                         Value="/etc/passwd")
     res_conf_id = rc.save()
     self.assertTrue(res_conf_id > 0, res_conf_id)
     # update resolver config
     rc = ResolverConfig(resolver=resolvername,
                         Key="fileName",
                         Value="/etc/secureusers")
     res_conf_id2 = rc.save()
     self.assertTrue(res_conf_id2 == res_conf_id, res_conf_id2)
     # delete resolver and its config
     r.delete()
     # check that config is empty
     q = ResolverConfig.query.filter_by(resolver_id=rid).all()
     self.assertTrue(len(q) == 0, q)