diff --git a/.coveragerc b/.coveragerc index 33e6d5b..58ddbe7 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,6 +3,7 @@ plugins = django_coverage_plugin omit = node_modules/* + .virtualenv/* [html] extra_css = coverage_extra_style.css diff --git a/ivatar/test_static_pages.py b/ivatar/test_static_pages.py new file mode 100644 index 0000000..5191509 --- /dev/null +++ b/ivatar/test_static_pages.py @@ -0,0 +1,80 @@ +''' +Test our views in ivatar.ivataraccount.views and ivatar.views +''' +# pylint: disable=too-many-lines +from urllib.parse import urlsplit +from io import BytesIO +import io +import os +import django +from django.test import TestCase +from django.test import Client +from django.urls import reverse +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +import hashlib + +from libravatar import libravatar_url + +from PIL import Image + +os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings' +django.setup() + +# pylint: disable=wrong-import-position +from ivatar import settings +from ivatar.ivataraccount.forms import MAX_NUM_UNCONFIRMED_EMAILS_DEFAULT +from ivatar.ivataraccount.models import Photo, ConfirmedOpenId +from ivatar.utils import random_string +# pylint: enable=wrong-import-position + + +class Tester(TestCase): # pylint: disable=too-many-public-methods + ''' + Main test class + ''' + client = Client() + user = None + username = random_string() + password = random_string() + email = '%s@%s.%s' % (username, random_string(), random_string(2)) + # Dunno why random tld doesn't work, but I'm too lazy now to investigate + openid = 'http://%s.%s.%s/' % (username, random_string(), 'org') + + def login(self): + ''' + Login as user + ''' + self.client.login(username=self.username, password=self.password) + + def setUp(self): + ''' + Prepare for tests. + - Create user + ''' + self.user = User.objects.create_user( + username=self.username, + password=self.password, + ) + + def test_contact_page(self): + """ + Test contact page + """ + response = self.client.get(reverse('contact')) + self.assertEqual(response.status_code, 200, 'no 200 ok?') + + def test_description_page(self): + """ + Test description page + """ + response = self.client.get(reverse('description')) + self.assertEqual(response.status_code, 200, 'no 200 ok?') + + def test_security_page(self): + """ + Test security page + """ + response = self.client.get(reverse('security')) + self.assertEqual(response.status_code, 200, 'no 200 ok?') + diff --git a/ivatar/test_views.py b/ivatar/test_views.py new file mode 100644 index 0000000..dbed347 --- /dev/null +++ b/ivatar/test_views.py @@ -0,0 +1,65 @@ +''' +Test our views in ivatar.ivataraccount.views and ivatar.views +''' +# pylint: disable=too-many-lines +from urllib.parse import urlsplit +from io import BytesIO +import io +import os +import django +from django.test import TestCase +from django.test import Client +from django.urls import reverse +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +import hashlib + +from libravatar import libravatar_url + +from PIL import Image + +os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings' +django.setup() + +# pylint: disable=wrong-import-position +from ivatar import settings +from ivatar.ivataraccount.forms import MAX_NUM_UNCONFIRMED_EMAILS_DEFAULT +from ivatar.ivataraccount.models import Photo, ConfirmedOpenId +from ivatar.utils import random_string +# pylint: enable=wrong-import-position + + +class Tester(TestCase): # pylint: disable=too-many-public-methods + ''' + Main test class + ''' + client = Client() + user = None + username = random_string() + password = random_string() + email = '%s@%s.%s' % (username, random_string(), random_string(2)) + # Dunno why random tld doesn't work, but I'm too lazy now to investigate + openid = 'http://%s.%s.%s/' % (username, random_string(), 'org') + + def login(self): + ''' + Login as user + ''' + self.client.login(username=self.username, password=self.password) + + def setUp(self): + ''' + Prepare for tests. + - Create user + ''' + self.user = User.objects.create_user( + username=self.username, + password=self.password, + ) + + def test_incorrect_digest(self): + """ + Test incorrect digest + """ + response = self.client.get('/avatar/%s' % 'x'*65) + self.assertEqual(response.status_code, 200, 'no 200 ok?') diff --git a/ivatar/tools/templates/check_domain.html b/ivatar/tools/templates/check_domain.html new file mode 100644 index 0000000..f7e8db4 --- /dev/null +++ b/ivatar/tools/templates/check_domain.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} +{% load i18n %} +{% load static %} + +{% block title %}{% trans 'Check e-mail or openid' %}{% endblock title %} + +{% block content %} + +