<commit_before># -*- coding: utf-8 -*-
from paste.fixture import TestApp
from paste.registry import RegistryManager

from pylons import Response
from pylons.decorators.secure import authenticate_form, csrf_detected_message

from pylons.controllers import WSGIController

from __init__ import ControllerWrap, SetupCacheGlobal, TestWSGIController

class ProtectedController(WSGIController):
    def protected(self):
        return Response("Authenticated form")
    protected = authenticate_form(protected)

class TestAuthenticateFormDecorator(TestWSGIController):
    def setUp(self):
        TestWSGIController.setUp(self)
        app = SetupCacheGlobal(ControllerWrap(ProtectedController),
                               self.environ, setup_cache=False)
        app = RegistryManager(app)
        self.app = TestApp(app)

    def test_unauthenticated(self):
        self.environ['pylons.routes_dict'].update(action='protected')
        response = self.app.post('/', extra_environ=self.environ,
                                 expect_errors=True)
        assert csrf_detected_message in response<commit_msg>[svn] fix python 2.3 compat<commit_after># -*- coding: utf-8 -*-
from paste.fixture import TestApp
from paste.registry import RegistryManager

from pylons import Response
from pylons.decorators.secure import authenticate_form, csrf_detected_message

from pylons.controllers import WSGIController

from __init__ import ControllerWrap, SetupCacheGlobal, TestWSGIController

class ProtectedController(WSGIController):
    def protected(self):
        return Response("Authenticated form")
    protected = authenticate_form(protected)

class TestAuthenticateFormDecorator(TestWSGIController):
    def setUp(self):
        TestWSGIController.setUp(self)
        app = SetupCacheGlobal(ControllerWrap(ProtectedController),
                               self.environ, setup_cache=False)
        app = RegistryManager(app)
        self.app = TestApp(app)

    def test_unauthenticated(self):
        self.environ['pylons.routes_dict'].update(dict(action='protected'))
        response = self.app.post('/', extra_environ=self.environ,
                                 expect_errors=True)
        assert csrf_detected_message in response
{'fraction_non_alphanumeric': 0.07915921288014312, 'fraction_numerical': 0.0017889087656529517, 'mean_word_length': 3.621900826446281, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2763223', 'n_tokens_mistral': 607, 'n_tokens_neox': 618, 'n_words': 129}