From b4b146921535d8aed8ec1794f91287f7eb87be6b Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Wed, 31 Aug 2016 16:38:13 +0200 Subject: [PATCH 1/4] try to test login i use requests to test login. the session should be saved and this should work. but i get a error that th session expired. to run this start wallabag and run it with pytest: `py.test -s tests/`. it will output the html of the response. --- tests/test_login.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_login.py b/tests/test_login.py index 6ebeb07..1ed70e1 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -12,3 +12,15 @@ def test_login_page(): assert 'Password' in r.text assert 'Register' in r.text assert 'Username' in r.text + + +def test_login(): + with requests.Session() as s: + + data = { + '_username': 'wallabag', + '_password': 'wallabag' + } + + r = s.post(URL + '/login_check', data=data) + print(r.text) From efbcf75701213784c73f95bbc5a2f208e9aafee2 Mon Sep 17 00:00:00 2001 From: Sven Fischer Date: Wed, 31 Aug 2016 23:13:32 +0200 Subject: [PATCH 2/4] test_login: add login with csrf token and check if it was successful --- tests/test_login.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/test_login.py b/tests/test_login.py index 1ed70e1..4a1efb1 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -1,3 +1,4 @@ +import re import requests @@ -15,12 +16,26 @@ def test_login_page(): def test_login(): - with requests.Session() as s: + csrf = '' + client = requests.session() + r = client.get(URL, allow_redirects=True) + jar = r.cookies + csrf_match = re.search('', r.text) + if csrf_match: + csrf = csrf_match.group(1) + else: + print("csrf not matched") - data = { - '_username': 'wallabag', - '_password': 'wallabag' - } + data = { + '_username': 'wallabag', + '_password': 'wallabag', + '_csrf_token' : csrf + } - r = s.post(URL + '/login_check', data=data) - print(r.text) + r = client.post(URL + '/login_check', cookies=jar, data=data) + print(r.text) + 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 From c65be008ec1fea18d487aec09ac299d0b7103a76 Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Thu, 1 Sep 2016 09:33:17 +0200 Subject: [PATCH 3/4] tests: some pep8 and real failing if csrf dont match --- tests/test_login.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/test_login.py b/tests/test_login.py index 4a1efb1..dd0f362 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -1,3 +1,4 @@ +import pytest import re import requests @@ -5,7 +6,7 @@ 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 @@ -15,25 +16,30 @@ def test_login_page(): assert 'Username' in r.text -def test_login(): - csrf = '' +def test_logging_in(): client = requests.session() r = client.get(URL, allow_redirects=True) jar = r.cookies - csrf_match = re.search('', r.text) + + # get csrf token + csrf_match = re.search( + '', + r.text + ) + if csrf_match: csrf = csrf_match.group(1) else: - print("csrf not matched") + # if there is no csrf token the test will fail + pytest.fail('csrf not matched') data = { '_username': 'wallabag', '_password': 'wallabag', - '_csrf_token' : csrf + '_csrf_token': csrf } r = client.post(URL + '/login_check', cookies=jar, data=data) - print(r.text) assert r.status_code == 200 assert '/unread/list' in r.text assert '/starred/list' in r.text From 28b4b03b21a63cf6f68a576a4cfa5b0b5eb06aff Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Thu, 1 Sep 2016 12:04:11 +0200 Subject: [PATCH 4/4] readme: added badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e264aa6..ffb3519 100644 --- a/README.md +++ b/README.md @@ -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.