mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-13 19:56:25 +00:00
Update testing
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ falko_gravatar.jpg
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
dump_all*.sql
|
dump_all*.sql
|
||||||
dist/
|
dist/
|
||||||
|
.env.local
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ repos:
|
|||||||
- id: prettier
|
- id: prettier
|
||||||
files: \.(css|js|md|markdown|json)
|
files: \.(css|js|md|markdown|json)
|
||||||
- repo: https://github.com/python/black
|
- repo: https://github.com/python/black
|
||||||
rev: 22.10.0
|
rev: 22.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
|||||||
2
attic/debug_toolbar_resources.txt
Normal file
2
attic/debug_toolbar_resources.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
https://django-debug-toolbar.readthedocs.io/en/latest/installation.html
|
||||||
|
https://stackoverflow.com/questions/6548947/how-can-django-debug-toolbar-be-set-to-work-for-just-some-users/6549317#6549317
|
||||||
49
attic/encryption_test.py
Executable file
49
attic/encryption_test.py
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
import timeit
|
||||||
|
|
||||||
|
os.environ.setdefault(
|
||||||
|
"DJANGO_SETTINGS_MODULE", "ivatar.settings"
|
||||||
|
) # pylint: disable=wrong-import-position
|
||||||
|
django.setup() # pylint: disable=wrong-import-position
|
||||||
|
|
||||||
|
from ivatar.ivataraccount.models import ConfirmedEmail, APIKey
|
||||||
|
from simplecrypt import decrypt
|
||||||
|
from binascii import unhexlify
|
||||||
|
|
||||||
|
digest = None
|
||||||
|
digest_sha256 = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_digest_sha256():
|
||||||
|
digest_sha256 = ConfirmedEmail.objects.first().encrypted_digest_sha256(
|
||||||
|
secret_key=APIKey.objects.first()
|
||||||
|
)
|
||||||
|
return digest_sha256
|
||||||
|
|
||||||
|
|
||||||
|
def get_digest():
|
||||||
|
digest = ConfirmedEmail.objects.first().encrypted_digest(
|
||||||
|
secret_key=APIKey.objects.first()
|
||||||
|
)
|
||||||
|
return digest
|
||||||
|
|
||||||
|
|
||||||
|
def decrypt_digest():
|
||||||
|
return decrypt(APIKey.objects.first().secret_key, unhexlify(digest))
|
||||||
|
|
||||||
|
|
||||||
|
def decrypt_digest_256():
|
||||||
|
return decrypt(APIKey.objects.first().secret_key, unhexlify(digest_sha256))
|
||||||
|
|
||||||
|
|
||||||
|
digest = get_digest()
|
||||||
|
digest_sha256 = get_digest_sha256()
|
||||||
|
|
||||||
|
print("Encrypt digest: %s" % timeit.timeit(get_digest, number=1))
|
||||||
|
print("Encrypt digest_sha256: %s" % timeit.timeit(get_digest_sha256, number=1))
|
||||||
|
print("Decrypt digest: %s" % timeit.timeit(decrypt_digest, number=1))
|
||||||
|
print("Decrypt digest_sha256: %s" % timeit.timeit(decrypt_digest_256, number=1))
|
||||||
7
attic/example_mysql_config
Normal file
7
attic/example_mysql_config
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
DATABASES['default'] = {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': 'libravatar',
|
||||||
|
'USER': 'libravatar',
|
||||||
|
'PASSWORD': 'libravatar',
|
||||||
|
'HOST': 'localhost',
|
||||||
|
}
|
||||||
@@ -1998,4 +1998,20 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
Test if preferences page works
|
Test if preferences page works
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.login()
|
||||||
self.client.get(reverse("user_preference"))
|
self.client.get(reverse("user_preference"))
|
||||||
|
|
||||||
|
def test_delete_user(self):
|
||||||
|
"""
|
||||||
|
Test if deleting user profile works
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.login()
|
||||||
|
self.client.get(reverse("delete"))
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("delete"),
|
||||||
|
data={"password": self.password},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 200, "Deletion worked")
|
||||||
|
self.assertEqual(User.objects.count(), 0, "No user there any more")
|
||||||
|
|||||||
0
ivatar/tools/__init__.py
Normal file
0
ivatar/tools/__init__.py
Normal file
@@ -48,16 +48,109 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
password=self.password,
|
password=self.password,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_check(self):
|
def test_check_mail(self):
|
||||||
"""
|
"""
|
||||||
Test check page
|
Test check page
|
||||||
"""
|
"""
|
||||||
|
self.login()
|
||||||
response = self.client.get(reverse("tools_check"))
|
response = self.client.get(reverse("tools_check"))
|
||||||
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("tools_check"),
|
||||||
|
data={"mail": "test@test.com", "size": "85"},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
'value="test@test.com"',
|
||||||
|
1,
|
||||||
|
200,
|
||||||
|
"Value not set again!?",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"b642b4217b34b1e8d3bd915fc65c4452",
|
||||||
|
3,
|
||||||
|
200,
|
||||||
|
"Wrong md5 hash!?",
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a",
|
||||||
|
3,
|
||||||
|
200,
|
||||||
|
"Wrong sha256 hash!?",
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
'value="85"',
|
||||||
|
1,
|
||||||
|
200,
|
||||||
|
"Size should be set based on post params!?",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_check_openid(self):
|
||||||
|
"""
|
||||||
|
Test check page
|
||||||
|
"""
|
||||||
|
self.login()
|
||||||
|
response = self.client.get(reverse("tools_check"))
|
||||||
|
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("tools_check"),
|
||||||
|
data={"openid": "https://test.com", "size": "85"},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
'value="https://test.com"',
|
||||||
|
1,
|
||||||
|
200,
|
||||||
|
"Value not set again!?",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"396936bd0bf0603d6784b65d03e96dae90566c36b62661f28d4116c516524bcc",
|
||||||
|
3,
|
||||||
|
200,
|
||||||
|
"Wrong sha256 hash!?",
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
'value="85"',
|
||||||
|
1,
|
||||||
|
200,
|
||||||
|
"Size should be set based on post params!?",
|
||||||
|
)
|
||||||
|
|
||||||
def test_check_domain(self):
|
def test_check_domain(self):
|
||||||
"""
|
"""
|
||||||
Test check domain page
|
Test check domain page
|
||||||
"""
|
"""
|
||||||
|
self.login()
|
||||||
response = self.client.get(reverse("tools_check_domain"))
|
response = self.client.get(reverse("tools_check_domain"))
|
||||||
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("tools_check_domain"),
|
||||||
|
data={"domain": "linux-kernel.at"},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 200, "no 200 ok?")
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"http://avatars.linux-kernel.at",
|
||||||
|
2,
|
||||||
|
200,
|
||||||
|
"Not responing with right URL!?",
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"https://avatars.linux-kernel.at",
|
||||||
|
2,
|
||||||
|
200,
|
||||||
|
"Not responing with right URL!?",
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user