예제 #1
0
    def test_csrf_token(self):

        response = self.client.get("/")
        snippet = (
            '<div style="display:none;">'
            '<input id="csrf_token" name="csrf_token" type="hidden" value')
        assert snippet in to_unicode(response.data)
예제 #2
0
    def test_csrf_token(self):

        response = self.client.get("/")
        snippet = (
            '<div style="display:none;">'
            '<input id="csrf_token" name="csrf_token" type="hidden" value'
        )
        assert snippet in to_unicode(response.data)
예제 #3
0
    def test_i18n_enabled(self):
        from flask import request
        from flask.ext.babel import Babel
        babel = Babel(self.app)

        @babel.localeselector
        def get_locale():
            return request.accept_languages.best_match(['en', 'zh'], 'en')

        self.app.config['CSRF_ENABLED'] = False

        response = self.client.post(
            "/", headers={'Accept-Language': 'zh-CN,zh;q=0.8'}, data={})
        assert '\u8be5\u5b57\u6bb5\u662f' in to_unicode(response.data)

        response = self.client.post("/", data={})
        assert b'This field is required.' in response.data
예제 #4
0
    def test_i18n_enabled(self):
        from flask import request
        from flask.ext.babel import Babel
        babel = Babel(self.app)

        @babel.localeselector
        def get_locale():
            return request.accept_languages.best_match(['en', 'zh'], 'en')

        self.app.config['CSRF_ENABLED'] = False

        response = self.client.post(
            "/",
            headers={'Accept-Language': 'zh-CN,zh;q=0.8'},
            data={}
        )
        assert '\u8be5\u5b57\u6bb5\u662f' in to_unicode(response.data)

        response = self.client.post("/", data={})
        assert b'This field is required.' in response.data
예제 #5
0
def get_csrf_token(data):
    match = csrf_token_input.search(to_unicode(data))
    assert match
    return match.groups()[0]
예제 #6
0
def get_csrf_token(data):
    match = csrf_token_input.search(to_unicode(data))
    assert match
    return match.groups()[0]