Ejemplo n.º 1
0
 def test_only_viewers_added(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     context.add_groups('hanna', [security.ROLE_VIEWER])
     context.add_groups('anders', [security.ROLE_VIEWER])
     obj = self._cut(context)
     self.assertEqual(obj.get_unread_userids(), frozenset(('admin', 'hanna', 'anders')))
Ejemplo n.º 2
0
 def test_inline_add_form_no_permission(self):
     register_security_policies(self.config)
     self.config.scan('voteit.core.models.proposal')
     self.config.scan('voteit.core.schemas.proposal')
     context = self._fixture()
     request = testing.DummyRequest(params={'content_type': 'Proposal'})
     obj = self._cut(context, request)
     self.assertRaises(HTTPForbidden, obj.process_inline_add_form)
Ejemplo n.º 3
0
 def test_with_nonexistent_user(self):
     register_security_policies(self.config)
     register_workflows(self.config)
     root = _fixture(self.config)
     context = root['meeting']
     obj = self._cut(context)
     node = None
     self.assertRaises(colander.Invalid, obj, node, "@admin says that naming @nonexistent should raise Invalid")
Ejemplo n.º 4
0
 def test_inline_add_form_no_permission(self):
     register_security_policies(self.config)
     self.config.scan('voteit.core.models.proposal')
     self.config.scan('voteit.core.schemas.proposal')
     context = self._fixture()
     request = testing.DummyRequest(params={'content_type': 'Proposal'})
     obj = self._cut(context, request)
     self.assertRaises(HTTPForbidden, obj.process_inline_add_form)
Ejemplo n.º 5
0
 def test_with_at_links(self):
     register_security_policies(self.config)
     register_workflows(self.config)
     root = _fixture(self.config)
     context = root['meeting']
     obj = self._cut(context)
     node = None
     self.assertEqual(obj(node, "@admin says to @tester that this shouldn't be valid."), None)
Ejemplo n.º 6
0
 def test_only_viewers_added(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     context.add_groups('hanna', [security.ROLE_VIEWER])
     context.add_groups('anders', [security.ROLE_VIEWER])
     obj = self._cut(context)
     self.assertEqual(obj.get_unread_userids(),
                      frozenset(('admin', 'hanna', 'anders')))
Ejemplo n.º 7
0
 def test_mark_as_read(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     userid = 'somebody'
     obj.unread_storage.add(userid)
     self.assertTrue(userid in obj.get_unread_userids())
     obj.mark_as_read(userid)
     self.assertFalse(userid in obj.get_unread_userids())
Ejemplo n.º 8
0
 def test_mark_as_read(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     userid = 'somebody'
     obj.unread_storage.add(userid)
     self.assertTrue(userid in obj.get_unread_userids())
     obj.mark_as_read(userid)
     self.assertFalse(userid in obj.get_unread_userids())
Ejemplo n.º 9
0
 def test_with_nonexistent_user(self):
     register_security_policies(self.config)
     register_workflows(self.config)
     root = _fixture(self.config)
     context = root['meeting']
     obj = self._cut(context)
     node = None
     self.assertRaises(
         colander.Invalid, obj, node,
         "@admin says that naming @nonexistent should raise Invalid")
Ejemplo n.º 10
0
 def test_with_at_links(self):
     register_security_policies(self.config)
     register_workflows(self.config)
     root = _fixture(self.config)
     context = root['meeting']
     obj = self._cut(context)
     node = None
     self.assertEqual(
         obj(node, "@admin says to @tester that this shouldn't be valid."),
         None)
Ejemplo n.º 11
0
    def test_with_user_outside_of_meeting_context(self):
        from voteit.core.models.user import User

        register_security_policies(self.config)
        register_workflows(self.config)
        root = _fixture(self.config)
        context = root['meeting']
        #New user
        root.users['new'] = User()
        obj = self._cut(context)
        node = None
        self.assertRaises(colander.Invalid, obj, node, "@new doesn't exist in this meeting so this shouldn't work")
Ejemplo n.º 12
0
    def test_with_user_outside_of_meeting_context(self):
        from voteit.core.models.user import User

        register_security_policies(self.config)
        register_workflows(self.config)
        root = _fixture(self.config)
        context = root['meeting']
        #New user
        root.users['new'] = User()
        obj = self._cut(context)
        node = None
        self.assertRaises(
            colander.Invalid, obj, node,
            "@new doesn't exist in this meeting so this shouldn't work")
Ejemplo n.º 13
0
 def test_verify_obj(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     self.assertTrue(verifyObject(IUnread, obj))
Ejemplo n.º 14
0
 def test_existing_userid(self):
     register_security_policies(self.config)
     root = _fixture(self.config)
     obj = self._cut(root)
     node = None
     self.assertRaises(colander.Invalid, obj, node, "admin")
Ejemplo n.º 15
0
 def test_existing_userid(self):
     register_security_policies(self.config)
     root = _fixture(self.config)
     obj = self._cut(root)
     node = None
     self.assertRaises(colander.Invalid, obj, node, "admin")
Ejemplo n.º 16
0
 def test_unread_on_check(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     self.assertEqual(obj.get_unread_userids(), frozenset(('admin',)))
Ejemplo n.º 17
0
 def test_verify_obj(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     self.assertTrue(verifyObject(IUnread, obj))
Ejemplo n.º 18
0
 def setUp(self):
     self.config = testing.setUp()
     self.config.include('arche.testing')
     register_security_policies(self.config)
Ejemplo n.º 19
0
 def test_unread_on_check(self):
     register_security_policies(self.config)
     context = self._fixture_and_setup()
     obj = self._cut(context)
     self.assertEqual(obj.get_unread_userids(), frozenset(('admin', )))
Ejemplo n.º 20
0
 def setUp(self):
     self.config = testing.setUp()
     self.config.include('arche.testing')
     register_security_policies(self.config)
Ejemplo n.º 21
0
 def setUp(self):
     self.config = testing.setUp()
     register_security_policies(self.config)
Ejemplo n.º 22
0
 def test_working_userid(self):
     register_security_policies(self.config)
     root = _fixture(self.config)
     obj = self._cut(root)
     node = None
     self.assertEqual(obj(node, "john_doe"), None)
Ejemplo n.º 23
0
 def setUp(self):
     self.config = testing.setUp()
     register_security_policies(self.config)
Ejemplo n.º 24
0
 def test_working_userid(self):
     register_security_policies(self.config)
     root = _fixture(self.config)
     obj = self._cut(root)
     node = None
     self.assertEqual(obj(node, "john_doe"), None)