Skip to content

Commit

Permalink
Merge pull request #16 from xsteadfastx/master
Browse files Browse the repository at this point in the history
Login testing works now
  • Loading branch information
xsteadfastx authored Sep 2, 2016
2 parents 4a81bc4 + 28b4b03 commit d069159
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# What is wallabag?

[![Build Status](https://travis-ci.org/wallabag/docker.svg?branch=master)](https://travis-ci.org/wallabag/docker)
[![Docker Stars](https://img.shields.io/docker/stars/wallabag/wallabag.svg?maxAge=2592000)](https://hub.docker.com/r/wallabag/wallabag/)
[![Docker Pulls](https://img.shields.io/docker/pulls/wallabag/wallabag.svg?maxAge=2592000)](https://hub.docker.com/r/wallabag/wallabag/)

[wallabag](https://www.wallabag.org/) is a self hostable application for saving web pages. Unlike other services, wallabag is free (as in freedom) and open source.

With this application you will not miss content anymore. Click, save, read it when you want. It saves the content you select so that you can read it when you have time.
Expand Down
35 changes: 34 additions & 1 deletion tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
import pytest
import re
import requests


URL = 'http://127.0.0.1:80'


def test_login_page():
def test_accessing_login_page():
r = requests.get(URL, allow_redirects=True)

assert r.status_code == 200
assert 'Login' in r.text
assert 'Password' in r.text
assert 'Register' in r.text
assert 'Username' in r.text


def test_logging_in():
client = requests.session()
r = client.get(URL, allow_redirects=True)
jar = r.cookies

# get csrf token
csrf_match = re.search(
'<input type="hidden" name="_csrf_token" value="(.*)" />',
r.text
)

if csrf_match:
csrf = csrf_match.group(1)
else:
# if there is no csrf token the test will fail
pytest.fail('csrf not matched')

data = {
'_username': 'wallabag',
'_password': 'wallabag',
'_csrf_token': csrf
}

r = client.post(URL + '/login_check', cookies=jar, data=data)
assert r.status_code == 200
assert '/unread/list' in r.text
assert '/starred/list' in r.text
assert '/archive/list' in r.text
assert '/all/list' in r.text

0 comments on commit d069159

Please sign in to comment.