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