Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KoMinkyu committed Oct 12, 2016
1 parent 6c62549 commit d9ff0f4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ Flask==0.11.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
py==1.4.31
pytest==3.0.3
Werkzeug==0.11.11
32 changes: 32 additions & 0 deletions test_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-

import pytest
import server

@pytest.fixture
def client(request):
server.app.config['TESTING'] = True
client = server.app.test_client()

def teardown():
pass

request.addfinalizer(teardown)

return client


def post_webhook_from_trusted_remote_addr(client):
return client.post('/webhook', environ_base={'REMOTE_ADDR': '111.11.1.1'})


def post_test_route(client):
return client.post('/teset')


def test_limit_remote_addr(client):
rv = post_webhook_from_trusted_remote_addr(client)
assert rv.status_code == 403

rv = post_test_route(client)
assert rv.status_code != 403

0 comments on commit d9ff0f4

Please sign in to comment.