Exemplo n.º 1
0
    def test_non_editors_are_redirect_to_home_page_after_login(self):
        user = User.example()
        perm = MediaCorePermissionSystem.permissions_for_user(user, config)
        assert_false(perm.contains_permission(u'edit'))
        assert_false(perm.contains_permission(u'admin'))

        response = self.call_post_login(user)
        assert_equals('http://server.example:80/', response.location)
Exemplo n.º 2
0
 def test_non_editors_are_redirect_to_home_page_after_login(self):
     user = User.example()
     perm = MediaCorePermissionSystem.permissions_for_user(user, config)
     assert_false(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     
     response = self.call_post_login(user)
     assert_equals('http://server.example:80/', response.location)
Exemplo n.º 3
0
 def test_uses_correct_redirect_url_if_mediacore_is_mounted_in_subdirectory(self):
     user = User.example()
     
     request = self.init_fake_request(server_name='server.example', request_uri='/mymedia/login/post_login')
     request.environ['SCRIPT_NAME'] = 'my_media'
     
     response = self.call_post_login(user, request=request)
     assert_equals('http://server.example:80/my_media/', response.location)
Exemplo n.º 4
0
 def test_can_create_example_user(self):
     user = User.example()
     
     assert_not_none(user.user_id)
     assert_equals(u'joe', user.user_name)
     assert_equals(u'Joe Smith', user.display_name)
     assert_equals(u'*****@*****.**', user.email_address)
     assert_almost_equals(datetime.now(), user.created, 
                          max_delta=timedelta(seconds=1))
 def test_non_editors_are_redirect_to_home_page_after_login(self):
     user = User.example()
     perm = MediaCorePermissionSystem.permissions_for_user(user, config)
     assert_false(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     
     response = self.call_post_login(user)
     redirect_path = urlparse.urlsplit(response.location)[2] # .path in 2.5+
     assert_equals('/', redirect_path)
Exemplo n.º 6
0
    def test_uses_correct_redirect_url_if_mediacore_is_mounted_in_subdirectory(
            self):
        user = User.example()

        request = self.init_fake_request(server_name='server.example',
                                         request_uri='/login/post_login')
        request.environ['SCRIPT_NAME'] = 'my_media'

        response = self.call_post_login(user, request=request)
        assert_equals('http://server.example:80/my_media/', response.location)
Exemplo n.º 7
0
 def _create_user_with_admin_permission_only(self):
     admin_perm = DBSession.query(Permission).filter(Permission.permission_name == u'admin').one()
     second_admin_group = Group.example(name=u'Second admin group')
     admin_perm.groups.append(second_admin_group)
     admin = User.example(groups=[second_admin_group])
     DBSession.commit()
     perm = MediaCorePermissionSystem.permissions_for_user(admin, config)
     assert_true(perm.contains_permission(u'admin'))
     assert_false(perm.contains_permission(u'edit'))
     return admin
Exemplo n.º 8
0
 def _create_user_with_admin_permission_only(self):
     admin_perm = DBSession.query(Permission).filter(
         Permission.permission_name == u'admin').one()
     second_admin_group = Group.example(name=u'Second admin group')
     admin_perm.groups.append(second_admin_group)
     admin = User.example(groups=[second_admin_group])
     DBSession.commit()
     perm = MediaCorePermissionSystem.permissions_for_user(admin, config)
     assert_true(perm.contains_permission(u'admin'))
     assert_false(perm.contains_permission(u'edit'))
     return admin
Exemplo n.º 9
0
 def test_can_override_example_data(self):
     user = User.example(display_name=u'Bar Foo')
     
     assert_equals(u'Bar Foo', user.display_name)
Exemplo n.º 10
0
 def _create_user_with_edit_permission_only(self):
     editor = User.example(groups=[self.editor_group()])
     perm = MediaCorePermissionSystem.permissions_for_user(editor, config)
     assert_true(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     return editor
Exemplo n.º 11
0
 def _create_user_with_edit_permission_only(self):
     editor = User.example(groups=[self.editor_group()])
     perm = MediaCorePermissionSystem.permissions_for_user(editor, config)
     assert_true(perm.contains_permission(u'edit'))
     assert_false(perm.contains_permission(u'admin'))
     return editor