Exemplo n.º 1
0
    def test_userauth_rules(self):
        core = s_cortex.openurl('ram:///')
        auth = s_userauth.UserAuth(core)

        auth.addUser('visi')
        auth.addUserRule('visi', 'foo.*')

        rules = s_userauth.Rules(auth, 'visi')

        self.true(rules.allow('foo.bar'))
        self.false(rules.allow('baz.faz'))

        auth.addUserRule('visi', 'baz.*')

        self.true(rules.allow('foo.bar'))
        self.true(rules.allow('baz.faz'))

        auth.delUserRule('visi', 'foo.*')

        self.false(rules.allow('foo.bar'))
        self.true(rules.allow('baz.faz'))

        auth.fini()
        core.fini()
Exemplo n.º 2
0
 def _getUserRules(self, user):
     rules = self.rules.get(user)
     if rules == None:
         rules = s_userauth.Rules(self.auth, user)
         self.rules[user] = rules
     return rules