def test_permissions_ruleset():
    add_perm('can_edit_book', always_true)
    assert 'can_edit_book' in permissions
    assert perm_exists('can_edit_book')
    assert has_perm('can_edit_book')
    remove_perm('can_edit_book')
    assert not perm_exists('can_edit_book')
Exemplo n.º 2
0
def test_permissions_ruleset():
    add_perm('can_edit_book', always_true)
    assert 'can_edit_book' in permissions
    assert perm_exists('can_edit_book')
    assert has_perm('can_edit_book')
    remove_perm('can_edit_book')
    assert not perm_exists('can_edit_book')
def test_backend():
    backend = ObjectPermissionBackend()
    assert backend.authenticate('someuser', 'password') is None

    add_perm('can_edit_book', always_true)
    assert 'can_edit_book' in permissions
    assert backend.has_perm(None, 'can_edit_book')
    assert backend.has_module_perms(None, 'can_edit_book')
    remove_perm('can_edit_book')
    assert not perm_exists('can_edit_book')
Exemplo n.º 4
0
def test_backend():
    backend = ObjectPermissionBackend()
    assert backend.authenticate('someuser', 'password') is None

    add_perm('can_edit_book', always_true)
    assert 'can_edit_book' in permissions
    assert backend.has_perm(None, 'can_edit_book')
    assert backend.has_module_perms(None, 'can_edit_book')
    remove_perm('can_edit_book')
    assert not perm_exists('can_edit_book')
Exemplo n.º 5
0
 def test_permissions_ruleset(self):
     add_perm("can_edit_book", always_true)
     assert "can_edit_book" in permissions
     assert perm_exists("can_edit_book")
     assert has_perm("can_edit_book")
     with self.assertRaises(KeyError):
         add_perm("can_edit_book", always_false)
     set_perm("can_edit_book", always_false)
     assert not has_perm("can_edit_book")
     remove_perm("can_edit_book")
     assert not perm_exists("can_edit_book")
Exemplo n.º 6
0
 def test_permissions_ruleset(self):
     add_perm('can_edit_book', always_true)
     assert 'can_edit_book' in permissions
     assert perm_exists('can_edit_book')
     assert has_perm('can_edit_book')
     with self.assertRaises(KeyError):
         add_perm('can_edit_book', always_false)
     set_perm('can_edit_book', always_false)
     assert not has_perm('can_edit_book')
     remove_perm('can_edit_book')
     assert not perm_exists('can_edit_book')
Exemplo n.º 7
0
    def test_backend(self):
        backend = ObjectPermissionBackend()
        assert backend.authenticate("someuser", "password") is None

        add_perm("can_edit_book", always_true)
        assert "can_edit_book" in permissions
        assert backend.has_perm(None, "can_edit_book")
        assert backend.has_module_perms(None, "can_edit_book")
        with self.assertRaises(KeyError):
            add_perm("can_edit_book", always_true)
        set_perm("can_edit_book", always_false)
        assert not backend.has_perm(None, "can_edit_book")
        remove_perm("can_edit_book")
        assert not perm_exists("can_edit_book")
Exemplo n.º 8
0
    def test_backend(self):
        backend = ObjectPermissionBackend()
        assert backend.authenticate('someuser', 'password') is None

        add_perm('can_edit_book', always_true)
        assert 'can_edit_book' in permissions
        assert backend.has_perm(None, 'can_edit_book')
        assert backend.has_module_perms(None, 'can_edit_book')
        with self.assertRaises(KeyError):
            add_perm('can_edit_book', always_true)
        set_perm('can_edit_book', always_false)
        assert not backend.has_perm(None, 'can_edit_book')
        remove_perm('can_edit_book')
        assert not perm_exists('can_edit_book')