<commit_before># -*- coding: utf-8 -*-
"""
Integration tests for the :mod:`repoze.who`-powered authentication sub-system.

As SkyLines grows and the authentication method changes, only these tests
should be updated.

"""

from . import TestController


class TestAuthentication(TestController):
    """Tests for the default authentication setup.

    By default in TurboGears 2, :mod:`repoze.who` is configured with the same
    plugins specified by repoze.what-quickstart (which are listed in
    http://code.gustavonarea.net/repoze.what-quickstart/#repoze.what.plugins.quickstart.setup_sql_auth).

    As the settings for those plugins change, or the plugins are replaced,
    these tests should be updated.

    """

    def login(self, email, password):
        form = self.browser.getForm(index=2)
        form.getControl(name='email_address').value = email
        form.getControl(name='password').value = password
        form.submit()

    def test_forced_login(self):
        """Anonymous users are forced to login

        Test that anonymous users are automatically redirected to the login
        form when authorization is denied. Next, upon successful login they
        should be redirected to the initially requested page.

        """
        # Requesting a protected area
        self.browser.open('/flights/upload/')
        assert self.browser.url.startswith('http://localhost/login')
        assert '</i> Logout' not in self.browser.contents

        self.login(u'<EMAIL>', 'test')

        # Being redirected to the initially requested page:<commit_msg>tests: Removed outdated comments in test_authentication<commit_after># -*- coding: utf-8 -*-

from . import TestController


class TestAuthentication(TestController):
    """ Tests for the default authentication setup. """

    def login(self, email, password):
        form = self.browser.getForm(index=2)
        form.getControl(name='email_address').value = email
        form.getControl(name='password').value = password
        form.submit()

    def test_forced_login(self):
        """Anonymous users are forced to login

        Test that anonymous users are automatically redirected to the login
        form when authorization is denied. Next, upon successful login they
        should be redirected to the initially requested page.

        """
        # Requesting a protected area
        self.browser.open('/flights/upload/')
        assert self.browser.url.startswith('http://localhost/login')
        assert '</i> Logout' not in self.browser.contents

        self.login(u'<EMAIL>', '<PASSWORD>')

        # Being redirected to the initially requested page:
{'fraction_non_alphanumeric': 0.09705438066465256, 'fraction_numerical': 0.0018882175226586104, 'mean_word_length': 3.1006191950464395, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '971872', 'n_tokens_mistral': 689, 'n_tokens_neox': 667, 'n_words': 228}