Example #1
0
    def test_registered_user_login_bad_password(self):
        '''
        Registered user is redirected to appropriate place if they submit
        invalid login details at /user/login.
        '''
        app = helpers._get_test_app()

        # make a user
        user = factories.User()

        # get the form
        response = app.get('/user/login')
        # ...it's the second one
        login_form = response.forms[1]

        # fill it in
        login_form['login'] = user['name']
        login_form['password'] = '******'

        # submit it
        submit_response = login_form.submit()
        # let's go to the last redirect in the chain
        final_response = self._maybe_follow(submit_response)

        # the response is the login page again
        final_response.mustcontain('<h1 class="page-heading">Login</h1>',
                                   'Login failed. Bad username or password.')
        # and we're definitely not on the dashboard.
        final_response.mustcontain(no='<a href="/dashboard">Dashboard</a>'),
        final_response.mustcontain(no='<span class="username">{0}</span>'
                                   .format(user['fullname']))
Example #2
0
    def test_registered_user_login_bad_password(self):
        '''
        Registered user is redirected to appropriate place if they submit
        invalid login details at /user/login.
        '''
        app = helpers._get_test_app()

        # make a user
        user = factories.User()

        # get the form
        response = app.get('/user/login')
        # ...it's the second one
        login_form = response.forms[1]

        # fill it in
        login_form['login'] = user['name']
        login_form['password'] = '******'

        # submit it
        submit_response = login_form.submit()
        # let's go to the last redirect in the chain
        final_response = self._maybe_follow(submit_response)

        # the response is the login page again
        final_response.mustcontain('<h1 class="page-heading">Login</h1>',
                                   'Login failed. Bad username or password.')
        # and we're definitely not on the dashboard.
        final_response.mustcontain(no='<a href="/dashboard">Dashboard</a>'),
        final_response.mustcontain(
            no='<span class="username">{0}</span>'.format(user['fullname']))
 def setup_class(cls):
     cls.config = Configurer()
     cls.app = helpers._get_test_app()
     ckan.plugins.load('twitter')
    def test_auth_visitor_cannot_create_article(self):
        article = _make_article()
        app = helpers._get_test_app()

        tests.call_action_api(app, 'package_create', status=403, **article)
    def test_auth_sysadmin_can_create_article(self):
        sysadmin = factories.Sysadmin()
        article = _make_article(apikey=sysadmin['apikey'])
        app = helpers._get_test_app()

        tests.call_action_api(TestAuth._test_app, 'package_create', **article)
    def test_auth_visitor_cannot_create_article(self):
        article = _make_article()
        app = helpers._get_test_app()

        tests.call_action_api(app, 'package_create', status=403, **article)
    def test_auth_sysadmin_can_create_article(self):
        sysadmin = factories.Sysadmin()
        article = _make_article(apikey=sysadmin['apikey'])
        app = helpers._get_test_app()

        tests.call_action_api(TestAuth._test_app, 'package_create', **article)
Example #8
0
 def setup_class(cls):
     cls.original_config = config.copy()
     cls.app = helpers._get_test_app()
     plugins.load('example_idatasetform')