Ejemplo n.º 1
0
    def test_DumpingAPrivateKeyAndLoadingTheRespectiveReturnsTheSameKey(
            self, tmpfile):
        key, pubkey = ec_secp256k1.generate_keys()

        ec_secp256k1.dump_key(key, tmpfile)
        loaded_key, loaded_pubkey = ec_secp256k1.load_keys(tmpfile)

        assert key == loaded_key
        assert pubkey == loaded_pubkey
Ejemplo n.º 2
0
from uuid import UUID, uuid4

from django.test import TestCase
from django.urls import reverse

import json

from rest_app import example_keys
import groupbank_crypto.ec_secp256k1 as crypto
from rest_app.models import Group

_, server_key = crypto.load_keys('server_keys.pem')

# Good rules-of-thumb include having:
#
# - a separate TestClass for each model or view
# - a separate test method for each set of conditions you want to test
# - test method names that describe their function
# TODO: check this out, looks cool: https://docs.djangoproject.com/en/1.10/ref/validators/


class RegisterGroupTests(TestCase):
    # TODO: add proxy/name server address?
    # TODO: Avoid testing the signature verification middleware. https://stackoverflow.com/questions/18025367/disable-a-specific-django-middleware-during-tests
    def test_correct_inputs(self):
        group_name = 'test_name'
        priv_key, pub_key = example_keys.G1_priv, example_keys.G1_pub
        id = pub_key

        payload = json.dumps({'group_name': group_name, 'group_key': pub_key})
        signature = crypto.sign(priv_key, payload)
Ejemplo n.º 3
0
 def __init__(self, get_response):
     self.get_response = get_response
     self.private_key, self.public_key = crypto.load_keys('server_keys.pem')