Exemplo n.º 1
0
    def test_login_logout_inside(self):
        with app.test_client() as client:
            username, password = create_one_user(client)
            login_one_user(client, username, password)
            logout(client)

            # The decorator login_required catch the function and return 'no_login.html', 411
            self.assertEqual(411, client.get('/inside').status_code)
Exemplo n.º 2
0
    def test_login_one_user(self):
        with app.test_client() as client:
            username, password = create_one_user(client)
            login_one_user(client, username, password)

            # We check if user was logged in, we verify it, requesting the session
            with client.session_transaction() as sess:
                self.assertEqual(username, sess.get('username'))
Exemplo n.º 3
0
    def test_login_then_logout_two_times(self):
        with app.test_client() as client:
            username, password = create_one_user(client)
            login_one_user(client, username, password)

            # First logout should work as normal
            self.assertEqual(200, client.get('/logout').status_code)

            # Decorator login_required catch the function and return 'no_login.html', 411
            self.assertEqual(411, client.get('/logout').status_code)
Exemplo n.º 4
0
    def test_validate_one_user_then_login(self):
        with app.test_client() as client:
            # We create one user with no email validation
            username, password = create_one_user_no_mail_validation(client)

            # We validate his email
            self.assertEqual(
                200,
                client.get(f'/mail/validation/{username}').status_code)

            # We log in the user
            login_one_user(client, username, password)

            # We check if our user logged in correctly
            with client.session_transaction() as sess:
                self.assertEqual(username, sess.get('username'))
Exemplo n.º 5
0
    def test_login_3_users_logout_2(self):
        with app.test_client() as client:
            username1, password1 = create_one_user(client,
                                                   username="******",
                                                   email="*****@*****.**")
            username2, password2 = create_one_user(client,
                                                   username="******",
                                                   email="*****@*****.**")
            username3, password3 = create_one_user(client,
                                                   username="******",
                                                   email="*****@*****.**")
            login_one_user(client, username1, password1)
            login_one_user(client, username2, password2)
            login_one_user(client, username3, password3)

            # First logout should work as normal
            self.assertEqual(200, client.get('/logout').status_code)

            # Decorator login_required catch the function and return 'no_login.html', 411
            self.assertEqual(411, client.get('/logout').status_code)
Exemplo n.º 6
0
    def test_login_then_logout(self):
        with app.test_client() as client:
            username, password = create_one_user(client)
            login_one_user(client, username, password)

            self.assertEqual(200, client.get('/logout').status_code)