Example #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')))
Example #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)
Example #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")
Example #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)
Example #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)
Example #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')))
Example #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())
Example #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())
 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")
 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)
Example #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")
    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")
Example #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))
Example #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")
 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")
Example #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',)))
Example #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))
Example #18
0
 def setUp(self):
     self.config = testing.setUp()
     self.config.include('arche.testing')
     register_security_policies(self.config)
Example #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', )))
Example #20
0
 def setUp(self):
     self.config = testing.setUp()
     self.config.include('arche.testing')
     register_security_policies(self.config)
Example #21
0
 def setUp(self):
     self.config = testing.setUp()
     register_security_policies(self.config)
Example #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)
Example #23
0
 def setUp(self):
     self.config = testing.setUp()
     register_security_policies(self.config)
 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)