예제 #1
0
    def setUp(self):
        self.account_key = jose.JWK.load(
            test_util.load_vector('rsa1024_key.pem'))
        self.resources: Set = set()

        from acme.standalone import HTTP01DualNetworkedServers
        self.servers = HTTP01DualNetworkedServers(('', 0), resources=self.resources)

        self.port = self.servers.getsocknames()[0][1]
        self.servers.serve_forever()
예제 #2
0
    def setUp(self):
        self.account_key = jose.JWK.load(
            test_util.load_vector('rsa1024_key.pem'))
        self.resources: Set = set()

        from acme.standalone import HTTP01Server
        self.server = HTTP01Server(('', 0), resources=self.resources)

        self.port = self.server.socket.getsockname()[1]
        self.thread = threading.Thread(target=self.server.serve_forever)
        self.thread.start()
예제 #3
0
"""Tests for acme.jws."""
import unittest

import josepy as jose

import test_util

KEY = jose.JWKRSA.load(test_util.load_vector('rsa512_key.pem'))


class HeaderTest(unittest.TestCase):
    """Tests for acme.jws.Header."""

    good_nonce = jose.encode_b64jose(b'foo')
    wrong_nonce = u'F'
    # Following just makes sure wrong_nonce is wrong
    try:
        jose.b64decode(wrong_nonce)
    except (ValueError, TypeError):
        assert True
    else:
        assert False  # pragma: no cover

    def test_nonce_decoder(self):
        from acme.jws import Header
        nonce_field = Header._fields['nonce']

        self.assertRaises(jose.DeserializationError, nonce_field.decode,
                          self.wrong_nonce)
        self.assertEqual(b'foo', nonce_field.decode(self.good_nonce))
예제 #4
0
 def test_gen_check_validation_wrong_key(self):
     key2 = jose.JWKRSA.load(test_util.load_vector('rsa1024_key.pem'))
     self.assertFalse(self.msg.check_validation(
         self.msg.gen_validation(KEY), key2.public_key()))
예제 #5
0
 def test_simple_verify_bad_key_authorization(self):
     key2 = jose.JWKRSA.load(test_util.load_vector('rsa256_key.pem'))
     self.response.simple_verify(self.chall, "local", key2.public_key())
예제 #6
0
 def test_simple_verify_failure(self):
     key2 = jose.JWKRSA.load(test_util.load_vector('rsa256_key.pem'))
     public_key = key2.public_key()
     verified = self.response.simple_verify(self.chall, "local", public_key)
     self.assertFalse(verified)
예제 #7
0
파일: jwk_test.py 프로젝트: certbot/josepy
 def test_load(self):
     from josepy.jwk import JWKEC
     self.assertEqual(self.private,
                      JWKEC.load(test_util.load_vector('ec_p256_key.pem')))
예제 #8
0
파일: jwk_test.py 프로젝트: certbot/josepy
 def test_load(self):
     from josepy.jwk import JWKRSA
     self.assertEqual(self.private,
                      JWKRSA.load(test_util.load_vector('rsa256_key.pem')))
예제 #9
0
파일: jwk_test.py 프로젝트: certbot/josepy
"""Tests for josepy.jwk."""
import binascii
import unittest

import test_util

from josepy import errors, json_util, util

DSA_PEM = test_util.load_vector('dsa512_key.pem')
RSA256_KEY = test_util.load_rsa_private_key('rsa256_key.pem')
RSA512_KEY = test_util.load_rsa_private_key('rsa512_key.pem')
EC_P256_KEY = test_util.load_ec_private_key('ec_p256_key.pem')
EC_P384_KEY = test_util.load_ec_private_key('ec_p384_key.pem')
EC_P521_KEY = test_util.load_ec_private_key('ec_p521_key.pem')


class JWKTest(unittest.TestCase):
    """Tests for josepy.jwk.JWK."""
    def test_load(self):
        from josepy.jwk import JWK
        self.assertRaises(errors.Error, JWK.load, DSA_PEM)

    def test_load_subclass_wrong_type(self):
        from josepy.jwk import JWKRSA
        self.assertRaises(errors.Error, JWKRSA.load, DSA_PEM)


class JWKTestBaseMixin:
    """Mixin test for JWK subclass tests."""

    thumbprint: bytes = NotImplemented