from test_cases import factories class TestLogin(): def test_case_bug_with_username(self, test_client, session): """ When the user case does not match the one in database, the form is valid but no record was found in the database. """ susan = factories.UserFactory.create( active=True, username='Susan', password='pepito', role='pentester') session.add(susan) session.commit() # we use lower case username, but in db is Capitalized login_payload = { 'email': 'susan', 'password': 'pepito', } res = test_client.post('/login', data=login_payload) assert res.status_code == 200 assert 'authentication_token' in res.json['response']['user']