From 01043374061d9ef0b68417dd97987d9c6775ab08 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 10 May 2017 11:12:10 +0200 Subject: [PATCH] Add travis.yml --- .travis.yml | 25 +++++++++++++++++++++++++ README.md | 2 +- pytest.ini | 2 +- requirements-dev.txt | 6 +++--- umap/settings/base.py | 6 ++++++ umap/tests/settings.py | 3 +++ umap/views.py | 11 +++++++++-- 7 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 .travis.yml create mode 100644 umap/tests/settings.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..cca3b66d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +sudo: false +language: python +python: +- "2.7" +- "3.4" +- "3.5" +- "3.6" +services: +- postgresql +env: +- UMAP_SETTINGS=umap/tests/settings.py +install: +- pip install . +- pip install -r requirements-dev.txt +script: make test +notifications: + irc: + channels: + - "irc.freenode.net#umap" + on_success: change + on_failure: always + email: false +branches: + only: + - master diff --git a/README.md b/README.md index 45422738..c65ae66d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # uMap project [![Requirements Status](https://requires.io/github/umap-project/umap/requirements.svg?branch=master)](https://requires.io/github/umap-project/umap/requirements/?branch=master) -[![Join the chat at https://gitter.im/umap-project/umap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/umap-project/umap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Documentation Status](https://readthedocs.org/projects/umap-project/badge/?version=latest)](http://umap-project.readthedocs.io/en/latest/?badge=latest) +[![Join the chat at https://gitter.im/umap-project/umap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/umap-project/umap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Documentation Status](https://readthedocs.org/projects/umap-project/badge/?version=latest)](http://umap-project.readthedocs.io/en/latest/?badge=latest)[![Build Status](https://travis-ci.org/umap-project/umap.svg?branch=master)](https://travis-ci.org/umap-project/umap) ## About diff --git a/pytest.ini b/pytest.ini index 10d3ed6f..b9589e63 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -DJANGO_SETTINGS_MODULE=umap.settings.local +DJANGO_SETTINGS_MODULE=umap.settings diff --git a/requirements-dev.txt b/requirements-dev.txt index 86559899..59dc14cc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,3 @@ -pytest -pytest-django -mkdocs +pytest==3.0.7 +pytest-django==3.1.2 +mkdocs==0.16.3 diff --git a/umap/settings/base.py b/umap/settings/base.py index 19319b0b..9c9c1166 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -168,6 +168,12 @@ MAP_SHORT_URL_NAME = "umap_short_url" UMAP_USE_UNACCENT = False UMAP_FEEDBACK_LINK = "https://wiki.openstreetmap.org/wiki/UMap#Feedback_and_help" # noqa USER_MAPS_URL = 'user_maps' +DATABASES = { + 'default': { + 'ENGINE': 'django.contrib.gis.db.backends.postgis', + 'NAME': 'umap', + } +} # ============================================================================= # Third party app settings diff --git a/umap/tests/settings.py b/umap/tests/settings.py new file mode 100644 index 00000000..a018ce88 --- /dev/null +++ b/umap/tests/settings.py @@ -0,0 +1,3 @@ +from umap.settings.base import * # pylint: disable=W0614,W0401 + +SECRET_KEY = 'justfortests' diff --git a/umap/views.py b/umap/views.py index 55a481e8..bfc98ab0 100644 --- a/umap/views.py +++ b/umap/views.py @@ -1,5 +1,6 @@ import json import mimetypes +import re import socket try: @@ -30,6 +31,13 @@ from leaflet_storage.forms import DEFAULT_CENTER User = get_user_model() +PRIVATE_IP = re.compile(r'((^127\.)|(^10\.)' + r'|(^172\.1[6-9]\.)' + r'|(^172\.2[0-9]\.)' + r'|(^172\.3[0-1]\.)' + r'|(^192\.168\.))') + + class PaginatorMixin(object): per_page = 5 @@ -229,8 +237,7 @@ def validate_url(request): ipaddress = socket.gethostbyname(toproxy.hostname) except: raise AssertionError() - assert not ipaddress.startswith('127.') - assert not ipaddress.startswith('192.168.') + assert not PRIVATE_IP.match(ipaddress) return url