diff --git a/MANIFEST.in b/MANIFEST.in index 5d40ffa59..79c87e8f0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,8 +6,8 @@ include letsencrypt/EULA recursive-include letsencrypt/client/tests/testdata * -recursive-include letsencrypt/acme/schemata *.json -recursive-include letsencrypt/acme/jose/testdata * +recursive-include acme/schemata *.json +recursive-include acme/jose/testdata * recursive-include letsencrypt/client/plugins/apache/tests/testdata * include letsencrypt/client/plugins/apache/options-ssl.conf diff --git a/letsencrypt/acme/__init__.py b/acme/__init__.py similarity index 100% rename from letsencrypt/acme/__init__.py rename to acme/__init__.py diff --git a/letsencrypt/acme/challenges.py b/acme/challenges.py similarity index 96% rename from letsencrypt/acme/challenges.py rename to acme/challenges.py index 9c0f263c7..11a1c9a60 100644 --- a/letsencrypt/acme/challenges.py +++ b/acme/challenges.py @@ -5,8 +5,8 @@ import hashlib import Crypto.Random -from letsencrypt.acme import jose -from letsencrypt.acme import other +from acme import jose +from acme import other # pylint: disable=too-few-public-methods @@ -186,8 +186,8 @@ class ProofOfPossession(ContinuityChallenge): class Hints(jose.JSONObjectWithFields): """Hints for "proofOfPossession" challenge. - :ivar jwk: JSON Web Key (:class:`letsencrypt.acme.jose.JWK`) - :ivar list certs: List of :class:`letsencrypt.acme.jose.ComparableX509` + :ivar jwk: JSON Web Key (:class:`acme.jose.JWK`) + :ivar list certs: List of :class:`acme.jose.ComparableX509` certificates. """ @@ -221,7 +221,7 @@ class ProofOfPossessionResponse(ChallengeResponse): """ACME "proofOfPossession" challenge response. :ivar str nonce: Random data, **not** base64-encoded. - :ivar signature: :class:`~letsencrypt.acme.other.Signature` of this message. + :ivar signature: :class:`~acme.other.Signature` of this message. """ typ = "proofOfPossession" diff --git a/letsencrypt/acme/challenges_test.py b/acme/challenges_test.py similarity index 81% rename from letsencrypt/acme/challenges_test.py rename to acme/challenges_test.py index 9ca9f6dd8..c2c8bdfea 100644 --- a/letsencrypt/acme/challenges_test.py +++ b/acme/challenges_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.challenges.""" +"""Tests for acme.challenges.""" import os import pkg_resources import unittest @@ -6,8 +6,8 @@ import unittest import Crypto.PublicKey.RSA import M2Crypto -from letsencrypt.acme import jose -from letsencrypt.acme import other +from acme import jose +from acme import other CERT = jose.ComparableX509(M2Crypto.X509.load_cert( @@ -15,14 +15,13 @@ CERT = jose.ComparableX509(M2Crypto.X509.load_cert( 'letsencrypt.client.tests', os.path.join('testdata', 'cert.pem')))) KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( - 'letsencrypt.acme.jose', - os.path.join('testdata', 'rsa512_key.pem')))) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) class SimpleHTTPSTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import SimpleHTTPS + from acme.challenges import SimpleHTTPS self.msg = SimpleHTTPS( token='evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ+PCt92wr+oA') self.jmsg = { @@ -34,18 +33,18 @@ class SimpleHTTPSTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import SimpleHTTPS + from acme.challenges import SimpleHTTPS self.assertEqual(self.msg, SimpleHTTPS.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import SimpleHTTPS + from acme.challenges import SimpleHTTPS hash(SimpleHTTPS.from_json(self.jmsg)) class SimpleHTTPSResponseTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import SimpleHTTPSResponse + from acme.challenges import SimpleHTTPSResponse self.msg = SimpleHTTPSResponse(path='6tbIMBC5Anhl5bOlWT5ZFA') self.jmsg = { 'type': 'simpleHttps', @@ -60,19 +59,19 @@ class SimpleHTTPSResponseTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import SimpleHTTPSResponse + from acme.challenges import SimpleHTTPSResponse self.assertEqual( self.msg, SimpleHTTPSResponse.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import SimpleHTTPSResponse + from acme.challenges import SimpleHTTPSResponse hash(SimpleHTTPSResponse.from_json(self.jmsg)) class DVSNITest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI self.msg = DVSNI( r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6" "\xbf'\xb3\xed\x9a9nX\x0f'\\m\xe7\x12", @@ -91,21 +90,21 @@ class DVSNITest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI self.assertEqual(self.msg, DVSNI.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI hash(DVSNI.from_json(self.jmsg)) def test_from_json_invalid_r_length(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI self.jmsg['r'] = 'abcd' self.assertRaises( jose.DeserializationError, DVSNI.from_json, self.jmsg) def test_from_json_invalid_nonce_length(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI self.jmsg['nonce'] = 'abcd' self.assertRaises( jose.DeserializationError, DVSNI.from_json, self.jmsg) @@ -114,7 +113,7 @@ class DVSNITest(unittest.TestCase): class DVSNIResponseTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import DVSNIResponse + from acme.challenges import DVSNIResponse self.msg = DVSNIResponse( s='\xf5\xd6\xe3\xb2]\xe0L\x0bN\x9cKJ\x14I\xa1K\xa3#\xf9\xa8' '\xcd\x8c7\x0e\x99\x19)\xdc\xb7\xf3\x9bw') @@ -124,7 +123,7 @@ class DVSNIResponseTest(unittest.TestCase): } def test_z_and_domain(self): - from letsencrypt.acme.challenges import DVSNI + from acme.challenges import DVSNI challenge = DVSNI( r="O*\xb4-\xad\xec\x95>\xed\xa9\r0\x94\xe8\x97\x9c&6" "\xbf'\xb3\xed\x9a9nX\x0f'\\m\xe7\x12", @@ -140,18 +139,18 @@ class DVSNIResponseTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import DVSNIResponse + from acme.challenges import DVSNIResponse self.assertEqual(self.msg, DVSNIResponse.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import DVSNIResponse + from acme.challenges import DVSNIResponse hash(DVSNIResponse.from_json(self.jmsg)) class RecoveryContactTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import RecoveryContact + from acme.challenges import RecoveryContact self.msg = RecoveryContact( activation_url='https://example.ca/sendrecovery/a5bd99383fb0', success_url='https://example.ca/confirmrecovery/bb1b9928932', @@ -167,11 +166,11 @@ class RecoveryContactTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import RecoveryContact + from acme.challenges import RecoveryContact self.assertEqual(self.msg, RecoveryContact.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import RecoveryContact + from acme.challenges import RecoveryContact hash(RecoveryContact.from_json(self.jmsg)) def test_json_without_optionals(self): @@ -179,7 +178,7 @@ class RecoveryContactTest(unittest.TestCase): del self.jmsg['successURL'] del self.jmsg['contact'] - from letsencrypt.acme.challenges import RecoveryContact + from acme.challenges import RecoveryContact msg = RecoveryContact.from_json(self.jmsg) self.assertTrue(msg.activation_url is None) @@ -191,7 +190,7 @@ class RecoveryContactTest(unittest.TestCase): class RecoveryContactResponseTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import RecoveryContactResponse + from acme.challenges import RecoveryContactResponse self.msg = RecoveryContactResponse(token='23029d88d9e123e') self.jmsg = {'type': 'recoveryContact', 'token': '23029d88d9e123e'} @@ -199,18 +198,18 @@ class RecoveryContactResponseTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import RecoveryContactResponse + from acme.challenges import RecoveryContactResponse self.assertEqual( self.msg, RecoveryContactResponse.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import RecoveryContactResponse + from acme.challenges import RecoveryContactResponse hash(RecoveryContactResponse.from_json(self.jmsg)) def test_json_without_optionals(self): del self.jmsg['token'] - from letsencrypt.acme.challenges import RecoveryContactResponse + from acme.challenges import RecoveryContactResponse msg = RecoveryContactResponse.from_json(self.jmsg) self.assertTrue(msg.token is None) @@ -220,7 +219,7 @@ class RecoveryContactResponseTest(unittest.TestCase): class RecoveryTokenTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import RecoveryToken + from acme.challenges import RecoveryToken self.msg = RecoveryToken() self.jmsg = {'type': 'recoveryToken'} @@ -228,18 +227,18 @@ class RecoveryTokenTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import RecoveryToken + from acme.challenges import RecoveryToken self.assertEqual(self.msg, RecoveryToken.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import RecoveryToken + from acme.challenges import RecoveryToken hash(RecoveryToken.from_json(self.jmsg)) class RecoveryTokenResponseTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import RecoveryTokenResponse + from acme.challenges import RecoveryTokenResponse self.msg = RecoveryTokenResponse(token='23029d88d9e123e') self.jmsg = {'type': 'recoveryToken', 'token': '23029d88d9e123e'} @@ -247,18 +246,18 @@ class RecoveryTokenResponseTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import RecoveryTokenResponse + from acme.challenges import RecoveryTokenResponse self.assertEqual( self.msg, RecoveryTokenResponse.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import RecoveryTokenResponse + from acme.challenges import RecoveryTokenResponse hash(RecoveryTokenResponse.from_json(self.jmsg)) def test_json_without_optionals(self): del self.jmsg['token'] - from letsencrypt.acme.challenges import RecoveryTokenResponse + from acme.challenges import RecoveryTokenResponse msg = RecoveryTokenResponse.from_json(self.jmsg) self.assertTrue(msg.token is None) @@ -282,7 +281,7 @@ class ProofOfPossessionHintsTest(unittest.TestCase): authorized_for = ('www.example.com', 'example.net') serial_numbers = (34234239832, 23993939911, 17) - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession self.msg = ProofOfPossession.Hints( jwk=jwk, issuers=issuers, cert_fingerprints=cert_fingerprints, certs=(CERT,), subject_key_identifiers=subject_key_identifiers, @@ -304,12 +303,12 @@ class ProofOfPossessionHintsTest(unittest.TestCase): self.assertEqual(self.jmsg_to, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession self.assertEqual( self.msg, ProofOfPossession.Hints.from_json(self.jmsg_from)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession hash(ProofOfPossession.Hints.from_json(self.jmsg_from)) def test_json_without_optionals(self): @@ -318,7 +317,7 @@ class ProofOfPossessionHintsTest(unittest.TestCase): del self.jmsg_from[optional] del self.jmsg_to[optional] - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession msg = ProofOfPossession.Hints.from_json(self.jmsg_from) self.assertEqual(msg.cert_fingerprints, ()) @@ -334,7 +333,7 @@ class ProofOfPossessionHintsTest(unittest.TestCase): class ProofOfPossessionTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession hints = ProofOfPossession.Hints( jwk=jose.JWKRSA(key=KEY.publickey()), cert_fingerprints=(), certs=(), serial_numbers=(), subject_key_identifiers=(), @@ -360,12 +359,12 @@ class ProofOfPossessionTest(unittest.TestCase): self.assertEqual(self.jmsg_to, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession self.assertEqual( self.msg, ProofOfPossession.from_json(self.jmsg_from)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import ProofOfPossession + from acme.challenges import ProofOfPossession hash(ProofOfPossession.from_json(self.jmsg_from)) @@ -384,7 +383,7 @@ class ProofOfPossessionResponseTest(unittest.TestCase): nonce='\x99\xc7Q\xb3f2\xbc\xdci\xfe\xd6\x98k\xc67\xdf', ) - from letsencrypt.acme.challenges import ProofOfPossessionResponse + from acme.challenges import ProofOfPossessionResponse self.msg = ProofOfPossessionResponse( nonce='xD\xf9\xb9\xdbU\xed\xaa\x17\xf1y|\x81\x88\x99 ', signature=signature) @@ -407,19 +406,19 @@ class ProofOfPossessionResponseTest(unittest.TestCase): self.assertEqual(self.jmsg_to, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import ProofOfPossessionResponse + from acme.challenges import ProofOfPossessionResponse self.assertEqual( self.msg, ProofOfPossessionResponse.from_json(self.jmsg_from)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import ProofOfPossessionResponse + from acme.challenges import ProofOfPossessionResponse hash(ProofOfPossessionResponse.from_json(self.jmsg_from)) class DNSTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import DNS + from acme.challenges import DNS self.msg = DNS(token='17817c66b60ce2e4012dfad92657527a') self.jmsg = {'type': 'dns', 'token': '17817c66b60ce2e4012dfad92657527a'} @@ -427,18 +426,18 @@ class DNSTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import DNS + from acme.challenges import DNS self.assertEqual(self.msg, DNS.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import DNS + from acme.challenges import DNS hash(DNS.from_json(self.jmsg)) class DNSResponseTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.challenges import DNSResponse + from acme.challenges import DNSResponse self.msg = DNSResponse() self.jmsg = {'type': 'dns'} @@ -446,11 +445,11 @@ class DNSResponseTest(unittest.TestCase): self.assertEqual(self.jmsg, self.msg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.challenges import DNSResponse + from acme.challenges import DNSResponse self.assertEqual(self.msg, DNSResponse.from_json(self.jmsg)) def test_from_json_hashable(self): - from letsencrypt.acme.challenges import DNSResponse + from acme.challenges import DNSResponse hash(DNSResponse.from_json(self.jmsg)) diff --git a/letsencrypt/acme/errors.py b/acme/errors.py similarity index 77% rename from letsencrypt/acme/errors.py rename to acme/errors.py index d69efda11..957e781af 100644 --- a/letsencrypt/acme/errors.py +++ b/acme/errors.py @@ -1,5 +1,5 @@ """ACME errors.""" -from letsencrypt.acme.jose import errors as jose_errors +from acme.jose import errors as jose_errors class Error(Exception): """Generic ACME error.""" diff --git a/letsencrypt/acme/fields.py b/acme/fields.py similarity index 94% rename from letsencrypt/acme/fields.py rename to acme/fields.py index f001f1cd5..3af336fe5 100644 --- a/letsencrypt/acme/fields.py +++ b/acme/fields.py @@ -1,7 +1,7 @@ """ACME JSON fields.""" import pyrfc3339 -from letsencrypt.acme import jose +from acme import jose class RFC3339Field(jose.Field): diff --git a/letsencrypt/acme/fields_test.py b/acme/fields_test.py similarity index 69% rename from letsencrypt/acme/fields_test.py rename to acme/fields_test.py index 204849408..340e0131e 100644 --- a/letsencrypt/acme/fields_test.py +++ b/acme/fields_test.py @@ -1,35 +1,35 @@ -"""Tests for letsencrypt.acme.fields.""" +"""Tests for acme.fields.""" import datetime import unittest import pytz -from letsencrypt.acme import jose +from acme import jose class RFC3339FieldTest(unittest.TestCase): - """Tests for letsencrypt.acme.fields.RFC3339Field.""" + """Tests for acme.fields.RFC3339Field.""" def setUp(self): self.decoded = datetime.datetime(2015, 3, 27, tzinfo=pytz.utc) self.encoded = '2015-03-27T00:00:00Z' def test_default_encoder(self): - from letsencrypt.acme.fields import RFC3339Field + from acme.fields import RFC3339Field self.assertEqual( self.encoded, RFC3339Field.default_encoder(self.decoded)) def test_default_encoder_naive_fails(self): - from letsencrypt.acme.fields import RFC3339Field + from acme.fields import RFC3339Field self.assertRaises( ValueError, RFC3339Field.default_encoder, datetime.datetime.now()) def test_default_decoder(self): - from letsencrypt.acme.fields import RFC3339Field + from acme.fields import RFC3339Field self.assertEqual( self.decoded, RFC3339Field.default_decoder(self.encoded)) def test_default_decoder_raises_deserialization_error(self): - from letsencrypt.acme.fields import RFC3339Field + from acme.fields import RFC3339Field self.assertRaises( jose.DeserializationError, RFC3339Field.default_decoder, '') diff --git a/letsencrypt/acme/jose/__init__.py b/acme/jose/__init__.py similarity index 77% rename from letsencrypt/acme/jose/__init__.py rename to acme/jose/__init__.py index 20f9ba7d3..db3258a3d 100644 --- a/letsencrypt/acme/jose/__init__.py +++ b/acme/jose/__init__.py @@ -22,21 +22,21 @@ particular the following RFCs: https://datatracker.ietf.org/doc/draft-ietf-jose-json-web-signature/ """ -from letsencrypt.acme.jose.b64 import ( +from acme.jose.b64 import ( b64decode, b64encode, ) -from letsencrypt.acme.jose.errors import ( +from acme.jose.errors import ( DeserializationError, SerializationError, Error, UnrecognizedTypeError, ) -from letsencrypt.acme.jose.interfaces import JSONDeSerializable +from acme.jose.interfaces import JSONDeSerializable -from letsencrypt.acme.jose.json_util import ( +from acme.jose.json_util import ( Field, JSONObjectWithFields, TypedJSONObjectWithFields, @@ -48,7 +48,7 @@ from letsencrypt.acme.jose.json_util import ( encode_csr, ) -from letsencrypt.acme.jose.jwa import ( +from acme.jose.jwa import ( HS256, HS384, HS512, @@ -61,14 +61,14 @@ from letsencrypt.acme.jose.jwa import ( RS512, ) -from letsencrypt.acme.jose.jwk import ( +from acme.jose.jwk import ( JWK, JWKRSA, ) -from letsencrypt.acme.jose.jws import JWS +from acme.jose.jws import JWS -from letsencrypt.acme.jose.util import ( +from acme.jose.util import ( ComparableX509, HashableRSAKey, ImmutableMap, diff --git a/letsencrypt/acme/jose/b64.py b/acme/jose/b64.py similarity index 100% rename from letsencrypt/acme/jose/b64.py rename to acme/jose/b64.py diff --git a/letsencrypt/acme/jose/b64_test.py b/acme/jose/b64_test.py similarity index 87% rename from letsencrypt/acme/jose/b64_test.py rename to acme/jose/b64_test.py index 89ff27f5d..0e2a726fe 100644 --- a/letsencrypt/acme/jose/b64_test.py +++ b/acme/jose/b64_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.jose.b64.""" +"""Tests for acme.jose.b64.""" import unittest @@ -19,11 +19,11 @@ B64_URL_UNSAFE_EXAMPLES = { class B64EncodeTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.b64.b64encode.""" + """Tests for acme.jose.b64.b64encode.""" @classmethod def _call(cls, data): - from letsencrypt.acme.jose.b64 import b64encode + from acme.jose.b64 import b64encode return b64encode(data) def test_unsafe_url(self): @@ -39,11 +39,11 @@ class B64EncodeTest(unittest.TestCase): class B64DecodeTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.b64.b64decode.""" + """Tests for acme.jose.b64.b64decode.""" @classmethod def _call(cls, data): - from letsencrypt.acme.jose.b64 import b64decode + from acme.jose.b64 import b64decode return b64decode(data) def test_unsafe_url(self): diff --git a/letsencrypt/acme/jose/errors.py b/acme/jose/errors.py similarity index 100% rename from letsencrypt/acme/jose/errors.py rename to acme/jose/errors.py diff --git a/letsencrypt/acme/jose/errors_test.py b/acme/jose/errors_test.py similarity index 75% rename from letsencrypt/acme/jose/errors_test.py rename to acme/jose/errors_test.py index dd6af6c1a..cafe16e8d 100644 --- a/letsencrypt/acme/jose/errors_test.py +++ b/acme/jose/errors_test.py @@ -1,10 +1,10 @@ -"""Tests for letsencrypt.acme.jose.errors.""" +"""Tests for acme.jose.errors.""" import unittest class UnrecognizedTypeErrorTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.jose.errors import UnrecognizedTypeError + from acme.jose.errors import UnrecognizedTypeError self.error = UnrecognizedTypeError('foo', {'type': 'foo'}) def test_str(self): diff --git a/letsencrypt/acme/jose/interfaces.py b/acme/jose/interfaces.py similarity index 96% rename from letsencrypt/acme/jose/interfaces.py rename to acme/jose/interfaces.py index 8e06f99f9..27dcf863f 100644 --- a/letsencrypt/acme/jose/interfaces.py +++ b/acme/jose/interfaces.py @@ -3,7 +3,7 @@ import abc import collections import json -from letsencrypt.acme.jose import util +from acme.jose import util # pylint: disable=no-self-argument,no-method-argument,no-init,inherit-non-class # pylint: disable=too-few-public-methods @@ -110,7 +110,7 @@ class JSONDeSerializable(object): # in particular... assert Bar().to_partial_json() != ['foo', 'foo'] - :raises letsencrypt.acme.jose.errors.SerializationError: + :raises acme.jose.errors.SerializationError: in case of any serialization error. :returns: Partially serializable object. @@ -125,7 +125,7 @@ class JSONDeSerializable(object): assert Bar().to_json() == ['foo', 'foo'] - :raises letsencrypt.acme.jose.errors.SerializationError: + :raises acme.jose.errors.SerializationError: in case of any serialization error. :returns: Fully serialized object. @@ -157,7 +157,7 @@ class JSONDeSerializable(object): types, as decoded from JSON document. Not necessarily :class:`dict` (as decoded from "JSON object" document). - :raises letsencrypt.acme.jose.errors.DeserializationError: + :raises acme.jose.errors.DeserializationError: if decoding was unsuccessful, e.g. in case of unparseable X509 certificate, or wrong padding in JOSE base64 encoded string, etc. diff --git a/letsencrypt/acme/jose/interfaces_test.py b/acme/jose/interfaces_test.py similarity index 90% rename from letsencrypt/acme/jose/interfaces_test.py rename to acme/jose/interfaces_test.py index 4c0fc6eb9..8e4d415ef 100644 --- a/letsencrypt/acme/jose/interfaces_test.py +++ b/acme/jose/interfaces_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.jose.interfaces.""" +"""Tests for acme.jose.interfaces.""" import unittest @@ -6,7 +6,7 @@ class JSONDeSerializableTest(unittest.TestCase): # pylint: disable=too-many-instance-attributes def setUp(self): - from letsencrypt.acme.jose.interfaces import JSONDeSerializable + from acme.jose.interfaces import JSONDeSerializable # pylint: disable=missing-docstring,invalid-name @@ -76,7 +76,7 @@ class JSONDeSerializableTest(unittest.TestCase): self.assertEqual(self.tuple.to_json(), (('foo', ))) def test_from_json_not_implemented(self): - from letsencrypt.acme.jose.interfaces import JSONDeSerializable + from acme.jose.interfaces import JSONDeSerializable self.assertRaises(TypeError, JSONDeSerializable.from_json, 'xxx') def test_json_loads(self): @@ -95,7 +95,7 @@ class JSONDeSerializableTest(unittest.TestCase): self.seq.json_dumps_pretty(), '[\n "foo1",\n "foo2"\n]') def test_json_dump_default(self): - from letsencrypt.acme.jose.interfaces import JSONDeSerializable + from acme.jose.interfaces import JSONDeSerializable self.assertEqual( 'foo1', JSONDeSerializable.json_dump_default(self.basic1)) @@ -106,7 +106,7 @@ class JSONDeSerializableTest(unittest.TestCase): self.assertTrue(jobj[1] is self.basic2) def test_json_dump_default_type_error(self): - from letsencrypt.acme.jose.interfaces import JSONDeSerializable + from acme.jose.interfaces import JSONDeSerializable self.assertRaises( TypeError, JSONDeSerializable.json_dump_default, object()) diff --git a/letsencrypt/acme/jose/json_util.py b/acme/jose/json_util.py similarity index 95% rename from letsencrypt/acme/jose/json_util.py rename to acme/jose/json_util.py index ac8cdf7aa..0c91c3412 100644 --- a/letsencrypt/acme/jose/json_util.py +++ b/acme/jose/json_util.py @@ -12,10 +12,10 @@ import logging import M2Crypto -from letsencrypt.acme.jose import b64 -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import interfaces -from letsencrypt.acme.jose import util +from acme.jose import b64 +from acme.jose import errors +from acme.jose import interfaces +from acme.jose import util class Field(object): @@ -27,8 +27,8 @@ class Field(object): ``encoder`` (``decoder``) is a callable that accepts a single parameter, i.e. a value to be encoded (decoded), and returns the serialized (deserialized) value. In case of errors it should raise - :class:`~letsencrypt.acme.jose.errors.SerializationError` - (:class:`~letsencrypt.acme.jose.errors.DeserializationError`). + :class:`~acme.jose.errors.SerializationError` + (:class:`~acme.jose.errors.DeserializationError`). Note, that ``decoder`` should perform partial serialization only. @@ -96,7 +96,7 @@ class Field(object): """Default decoder. Recursively deserialize into immutable types ( - :class:`letsencrypt.acme.jose.util.frozendict` instead of + :class:`acme.jose.util.frozendict` instead of :func:`dict`, :func:`tuple` instead of :func:`list`). """ @@ -304,7 +304,7 @@ def encode_cert(cert): """Encode certificate as JOSE Base-64 DER. :param cert: Certificate. - :type cert: :class:`letsencrypt.acme.jose.util.ComparableX509` + :type cert: :class:`acme.jose.util.ComparableX509` """ return b64.b64encode(cert.as_der()) @@ -381,7 +381,7 @@ class TypedJSONObjectWithFields(JSONObjectWithFields): :returns: Serializable JSON object representing ACME typed object. :meth:`validate` will almost certainly not work, due to reasons - explained in :class:`letsencrypt.acme.interfaces.IJSONSerializable`. + explained in :class:`acme.interfaces.IJSONSerializable`. :rtype: dict """ @@ -393,7 +393,7 @@ class TypedJSONObjectWithFields(JSONObjectWithFields): def from_json(cls, jobj): """Deserialize ACME object from valid JSON object. - :raises letsencrypt.acme.errors.UnrecognizedTypeError: if type + :raises acme.errors.UnrecognizedTypeError: if type of the ACME object has not been registered. """ diff --git a/letsencrypt/acme/jose/json_util_test.py b/acme/jose/json_util_test.py similarity index 87% rename from letsencrypt/acme/jose/json_util_test.py rename to acme/jose/json_util_test.py index 88818ed07..42113279e 100644 --- a/letsencrypt/acme/jose/json_util_test.py +++ b/acme/jose/json_util_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.jose.json_util.""" +"""Tests for acme.jose.json_util.""" import os import pkg_resources import unittest @@ -6,9 +6,9 @@ import unittest import M2Crypto import mock -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import interfaces -from letsencrypt.acme.jose import util +from acme.jose import errors +from acme.jose import interfaces +from acme.jose import util CERT = M2Crypto.X509.load_cert(pkg_resources.resource_filename( @@ -18,7 +18,7 @@ CSR = M2Crypto.X509.load_request(pkg_resources.resource_filename( class FieldTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.json_util.Field.""" + """Tests for acme.jose.json_util.Field.""" def test_descriptors(self): mock_value = mock.MagicMock() @@ -31,7 +31,7 @@ class FieldTest(unittest.TestCase): def encoder(unused_value): return 'e' - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field field = Field('foo') field = field.encoder(encoder) @@ -51,39 +51,39 @@ class FieldTest(unittest.TestCase): pass mock_field = MockField() - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field self.assertTrue(Field.default_encoder(mock_field) is mock_field) # in particular... self.assertNotEqual('foo', Field.default_encoder(mock_field)) def test_default_encoder_passthrough(self): mock_value = mock.MagicMock() - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field self.assertTrue(Field.default_encoder(mock_value) is mock_value) def test_default_decoder_list_to_tuple(self): - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field self.assertEqual((1, 2, 3), Field.default_decoder([1, 2, 3])) def test_default_decoder_dict_to_frozendict(self): - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field obj = Field.default_decoder({'x': 2}) self.assertTrue(isinstance(obj, util.frozendict)) self.assertEqual(obj, util.frozendict(x=2)) def test_default_decoder_passthrough(self): mock_value = mock.MagicMock() - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import Field self.assertTrue(Field.default_decoder(mock_value) is mock_value) class JSONObjectWithFieldsTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.json_util.JSONObjectWithFields.""" + """Tests for acme.jose.json_util.JSONObjectWithFields.""" # pylint: disable=protected-access def setUp(self): - from letsencrypt.acme.jose.json_util import JSONObjectWithFields - from letsencrypt.acme.jose.json_util import Field + from acme.jose.json_util import JSONObjectWithFields + from acme.jose.json_util import Field class MockJSONObjectWithFields(JSONObjectWithFields): # pylint: disable=invalid-name,missing-docstring,no-self-argument @@ -185,11 +185,11 @@ class DeEncodersTest(unittest.TestCase): ) def test_decode_b64_jose_padding_error(self): - from letsencrypt.acme.jose.json_util import decode_b64jose + from acme.jose.json_util import decode_b64jose self.assertRaises(errors.DeserializationError, decode_b64jose, 'x') def test_decode_b64_jose_size(self): - from letsencrypt.acme.jose.json_util import decode_b64jose + from acme.jose.json_util import decode_b64jose self.assertEqual('foo', decode_b64jose('Zm9v', size=3)) self.assertRaises( errors.DeserializationError, decode_b64jose, 'Zm9v', size=2) @@ -197,44 +197,44 @@ class DeEncodersTest(unittest.TestCase): errors.DeserializationError, decode_b64jose, 'Zm9v', size=4) def test_decode_b64_jose_minimum_size(self): - from letsencrypt.acme.jose.json_util import decode_b64jose + from acme.jose.json_util import decode_b64jose self.assertEqual('foo', decode_b64jose('Zm9v', size=3, minimum=True)) self.assertEqual('foo', decode_b64jose('Zm9v', size=2, minimum=True)) self.assertRaises(errors.DeserializationError, decode_b64jose, 'Zm9v', size=4, minimum=True) def test_decode_hex16(self): - from letsencrypt.acme.jose.json_util import decode_hex16 + from acme.jose.json_util import decode_hex16 self.assertEqual('foo', decode_hex16('666f6f')) def test_decode_hex16_minimum_size(self): - from letsencrypt.acme.jose.json_util import decode_hex16 + from acme.jose.json_util import decode_hex16 self.assertEqual('foo', decode_hex16('666f6f', size=3, minimum=True)) self.assertEqual('foo', decode_hex16('666f6f', size=2, minimum=True)) self.assertRaises(errors.DeserializationError, decode_hex16, '666f6f', size=4, minimum=True) def test_decode_hex16_odd_length(self): - from letsencrypt.acme.jose.json_util import decode_hex16 + from acme.jose.json_util import decode_hex16 self.assertRaises(errors.DeserializationError, decode_hex16, 'x') def test_encode_cert(self): - from letsencrypt.acme.jose.json_util import encode_cert + from acme.jose.json_util import encode_cert self.assertEqual(self.b64_cert, encode_cert(CERT)) def test_decode_cert(self): - from letsencrypt.acme.jose.json_util import decode_cert + from acme.jose.json_util import decode_cert cert = decode_cert(self.b64_cert) self.assertTrue(isinstance(cert, util.ComparableX509)) self.assertEqual(cert, CERT) self.assertRaises(errors.DeserializationError, decode_cert, '') def test_encode_csr(self): - from letsencrypt.acme.jose.json_util import encode_csr + from acme.jose.json_util import encode_csr self.assertEqual(self.b64_cert, encode_csr(CERT)) def test_decode_csr(self): - from letsencrypt.acme.jose.json_util import decode_csr + from acme.jose.json_util import decode_csr csr = decode_csr(self.b64_csr) self.assertTrue(isinstance(csr, util.ComparableX509)) self.assertEqual(csr, CSR) @@ -244,7 +244,7 @@ class DeEncodersTest(unittest.TestCase): class TypedJSONObjectWithFieldsTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.jose.json_util import TypedJSONObjectWithFields + from acme.jose.json_util import TypedJSONObjectWithFields # pylint: disable=missing-docstring,abstract-method # pylint: disable=too-few-public-methods diff --git a/letsencrypt/acme/jose/jwa.py b/acme/jose/jwa.py similarity index 96% rename from letsencrypt/acme/jose/jwa.py rename to acme/jose/jwa.py index b1f058d77..97c770b78 100644 --- a/letsencrypt/acme/jose/jwa.py +++ b/acme/jose/jwa.py @@ -13,9 +13,9 @@ from Crypto.Hash import SHA512 from Crypto.Signature import PKCS1_PSS from Crypto.Signature import PKCS1_v1_5 -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import interfaces -from letsencrypt.acme.jose import jwk +from acme.jose import errors +from acme.jose import interfaces +from acme.jose import jwk class JWA(interfaces.JSONDeSerializable): # pylint: disable=abstract-method diff --git a/letsencrypt/acme/jose/jwa_test.py b/acme/jose/jwa_test.py similarity index 83% rename from letsencrypt/acme/jose/jwa_test.py rename to acme/jose/jwa_test.py index 48fdfce0d..083cd0b73 100644 --- a/letsencrypt/acme/jose/jwa_test.py +++ b/acme/jose/jwa_test.py @@ -1,11 +1,11 @@ -"""Tests for letsencrypt.acme.jose.jwa.""" +"""Tests for acme.jose.jwa.""" import os import pkg_resources import unittest from Crypto.PublicKey import RSA -from letsencrypt.acme.jose import errors +from acme.jose import errors RSA256_KEY = RSA.importKey(pkg_resources.resource_string( @@ -17,10 +17,10 @@ RSA1024_KEY = RSA.importKey(pkg_resources.resource_string( class JWASignatureTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jwa.JWASignature.""" + """Tests for acme.jose.jwa.JWASignature.""" def setUp(self): - from letsencrypt.acme.jose.jwa import JWASignature + from acme.jose.jwa import JWASignature class MockSig(JWASignature): # pylint: disable=missing-docstring,too-few-public-methods @@ -48,15 +48,15 @@ class JWASignatureTest(unittest.TestCase): self.assertEqual(self.Sig2.to_partial_json(), 'Sig2') def test_from_json(self): - from letsencrypt.acme.jose.jwa import JWASignature - from letsencrypt.acme.jose.jwa import RS256 + from acme.jose.jwa import JWASignature + from acme.jose.jwa import RS256 self.assertTrue(JWASignature.from_json('RS256') is RS256) class JWAHSTest(unittest.TestCase): # pylint: disable=too-few-public-methods def test_it(self): - from letsencrypt.acme.jose.jwa import HS256 + from acme.jose.jwa import HS256 sig = ( "\xceR\xea\xcd\x94\xab\xcf\xfb\xe0\xacA.:\x1a'\x08i\xe2\xc4" "\r\x85+\x0e\x85\xaeUZ\xd4\xb3\x97zO" @@ -69,19 +69,19 @@ class JWAHSTest(unittest.TestCase): # pylint: disable=too-few-public-methods class JWARSTest(unittest.TestCase): def test_sign_no_private_part(self): - from letsencrypt.acme.jose.jwa import RS256 + from acme.jose.jwa import RS256 self.assertRaises( errors.Error, RS256.sign, RSA512_KEY.publickey(), 'foo') def test_sign_key_too_small(self): - from letsencrypt.acme.jose.jwa import RS256 - from letsencrypt.acme.jose.jwa import PS256 + from acme.jose.jwa import RS256 + from acme.jose.jwa import PS256 self.assertRaises(errors.Error, RS256.sign, RSA256_KEY, 'foo') self.assertRaises(errors.Error, PS256.sign, RSA256_KEY, 'foo') self.assertRaises(errors.Error, PS256.sign, RSA512_KEY, 'foo') def test_rs(self): - from letsencrypt.acme.jose.jwa import RS256 + from acme.jose.jwa import RS256 sig = ( '|\xc6\xb2\xa4\xab(\x87\x99\xfa*:\xea\xf8\xa0N&}\x9f\x0f\xc0O' '\xc6t\xa3\xe6\xfa\xbb"\x15Y\x80Y\xe0\x81\xb8\x88)\xba\x0c\x9c' @@ -95,7 +95,7 @@ class JWARSTest(unittest.TestCase): self.assertFalse(RS256.verify(RSA512_KEY, 'foo', sig + '!') is False) def test_ps(self): - from letsencrypt.acme.jose.jwa import PS256 + from acme.jose.jwa import PS256 sig = PS256.sign(RSA1024_KEY, 'foo') self.assertTrue(PS256.verify(RSA1024_KEY, 'foo', sig) is True) self.assertTrue(PS256.verify(RSA1024_KEY, 'foo', sig + '!') is False) diff --git a/letsencrypt/acme/jose/jwk.py b/acme/jose/jwk.py similarity index 95% rename from letsencrypt/acme/jose/jwk.py rename to acme/jose/jwk.py index ec35baa18..7c55e99a8 100644 --- a/letsencrypt/acme/jose/jwk.py +++ b/acme/jose/jwk.py @@ -4,10 +4,10 @@ import binascii import Crypto.PublicKey.RSA -from letsencrypt.acme.jose import b64 -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import json_util -from letsencrypt.acme.jose import util +from acme.jose import b64 +from acme.jose import errors +from acme.jose import json_util +from acme.jose import util class JWK(json_util.TypedJSONObjectWithFields): diff --git a/letsencrypt/acme/jose/jwk_test.py b/acme/jose/jwk_test.py similarity index 81% rename from letsencrypt/acme/jose/jwk_test.py rename to acme/jose/jwk_test.py index 1328528e8..7b942eca1 100644 --- a/letsencrypt/acme/jose/jwk_test.py +++ b/acme/jose/jwk_test.py @@ -1,12 +1,12 @@ -"""Tests for letsencrypt.acme.jose.jwk.""" +"""Tests for acme.jose.jwk.""" import os import pkg_resources import unittest from Crypto.PublicKey import RSA -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import util +from acme.jose import errors +from acme.jose import util RSA256_KEY = util.HashableRSAKey(RSA.importKey(pkg_resources.resource_string( @@ -16,10 +16,10 @@ RSA512_KEY = util.HashableRSAKey(RSA.importKey(pkg_resources.resource_string( class JWKOctTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jwk.JWKOct.""" + """Tests for acme.jose.jwk.JWKOct.""" def setUp(self): - from letsencrypt.acme.jose.jwk import JWKOct + from acme.jose.jwk import JWKOct self.jwk = JWKOct(key='foo') self.jobj = {'kty': 'oct', 'k': 'foo'} @@ -27,15 +27,15 @@ class JWKOctTest(unittest.TestCase): self.assertEqual(self.jwk.to_partial_json(), self.jobj) def test_from_json(self): - from letsencrypt.acme.jose.jwk import JWKOct + from acme.jose.jwk import JWKOct self.assertEqual(self.jwk, JWKOct.from_json(self.jobj)) def test_from_json_hashable(self): - from letsencrypt.acme.jose.jwk import JWKOct + from acme.jose.jwk import JWKOct hash(JWKOct.from_json(self.jobj)) def test_load(self): - from letsencrypt.acme.jose.jwk import JWKOct + from acme.jose.jwk import JWKOct self.assertEqual(self.jwk, JWKOct.load('foo')) def test_public(self): @@ -43,10 +43,10 @@ class JWKOctTest(unittest.TestCase): class JWKRSATest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jwk.JWKRSA.""" + """Tests for acme.jose.jwk.JWKRSA.""" def setUp(self): - from letsencrypt.acme.jose.jwk import JWKRSA + from acme.jose.jwk import JWKRSA self.jwk256 = JWKRSA(key=RSA256_KEY.publickey()) self.jwk256_private = JWKRSA(key=RSA256_KEY) self.jwk256json = { @@ -71,7 +71,7 @@ class JWKRSATest(unittest.TestCase): self.assertNotEqual(self.jwk512, self.jwk256) def test_load(self): - from letsencrypt.acme.jose.jwk import JWKRSA + from acme.jose.jwk import JWKRSA self.assertEqual( JWKRSA(key=util.HashableRSAKey(RSA256_KEY)), JWKRSA.load( pkg_resources.resource_string( @@ -85,18 +85,18 @@ class JWKRSATest(unittest.TestCase): self.assertEqual(self.jwk512.to_partial_json(), self.jwk512json) def test_from_json(self): - from letsencrypt.acme.jose.jwk import JWK + from acme.jose.jwk import JWK self.assertEqual(self.jwk256, JWK.from_json(self.jwk256json)) # TODO: fix schemata to allow RSA512 #self.assertEqual(self.jwk512, JWK.from_json(self.jwk512json)) def test_from_json_hashable(self): - from letsencrypt.acme.jose.jwk import JWK + from acme.jose.jwk import JWK hash(JWK.from_json(self.jwk256json)) def test_from_json_non_schema_errors(self): # valid against schema, but still failing - from letsencrypt.acme.jose.jwk import JWK + from acme.jose.jwk import JWK self.assertRaises(errors.DeserializationError, JWK.from_json, {'kty': 'RSA', 'e': 'AQAB', 'n': ''}) self.assertRaises(errors.DeserializationError, JWK.from_json, diff --git a/letsencrypt/acme/jose/jws.py b/acme/jose/jws.py similarity index 96% rename from letsencrypt/acme/jose/jws.py rename to acme/jose/jws.py index fc37227fd..06923e145 100644 --- a/letsencrypt/acme/jose/jws.py +++ b/acme/jose/jws.py @@ -5,12 +5,12 @@ import sys import M2Crypto -from letsencrypt.acme.jose import b64 -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import json_util -from letsencrypt.acme.jose import jwa -from letsencrypt.acme.jose import jwk -from letsencrypt.acme.jose import util +from acme.jose import b64 +from acme.jose import errors +from acme.jose import json_util +from acme.jose import jwa +from acme.jose import jwk +from acme.jose import util class MediaType(object): @@ -103,9 +103,9 @@ class Header(json_util.JSONObjectWithFields): .. todo:: Supports only "jwk" header parameter lookup. :returns: (Public) key found in the header. - :rtype: :class:`letsencrypt.acme.jose.jwk.JWK` + :rtype: :class:`acme.jose.jwk.JWK` - :raises letsencrypt.acme.jose.errors.Error: if key could not be found + :raises acme.jose.errors.Error: if key could not be found """ if self.jwk is None: @@ -180,7 +180,7 @@ class Signature(json_util.JSONObjectWithFields): """Verify. :param key: Key used for verification. - :type key: :class:`letsencrypt.acme.jose.jwk.JWK` + :type key: :class:`acme.jose.jwk.JWK` """ key = self.combined.find_key() if key is None else key @@ -195,7 +195,7 @@ class Signature(json_util.JSONObjectWithFields): """Sign. :param key: Key for signature. - :type key: :class:`letsencrypt.acme.jose.jwk.JWK` + :type key: :class:`acme.jose.jwk.JWK` """ assert isinstance(key, alg.kty) @@ -241,8 +241,6 @@ class Signature(json_util.JSONObjectWithFields): class JWS(json_util.JSONObjectWithFields): """JSON Web Signature. - from letsencrypt.acme.jose import interfaces - :ivar str payload: JWS Payload. :ivar str signaturea: JWS Signatures. diff --git a/letsencrypt/acme/jose/jws_test.py b/acme/jose/jws_test.py similarity index 83% rename from letsencrypt/acme/jose/jws_test.py rename to acme/jose/jws_test.py index dca61c3d9..736391e4c 100644 --- a/letsencrypt/acme/jose/jws_test.py +++ b/acme/jose/jws_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.jose.jws.""" +"""Tests for acme.jose.jws.""" import base64 import os import pkg_resources @@ -8,11 +8,11 @@ import Crypto.PublicKey.RSA import M2Crypto import mock -from letsencrypt.acme.jose import b64 -from letsencrypt.acme.jose import errors -from letsencrypt.acme.jose import jwa -from letsencrypt.acme.jose import jwk -from letsencrypt.acme.jose import util +from acme.jose import b64 +from acme.jose import errors +from acme.jose import jwa +from acme.jose import jwk +from acme.jose import util CERT = util.ComparableX509(M2Crypto.X509.load_cert( @@ -23,34 +23,34 @@ RSA512_KEY = Crypto.PublicKey.RSA.importKey(pkg_resources.resource_string( class MediaTypeTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jws.MediaType.""" + """Tests for acme.jose.jws.MediaType.""" def test_decode(self): - from letsencrypt.acme.jose.jws import MediaType + from acme.jose.jws import MediaType self.assertEqual('application/app', MediaType.decode('application/app')) self.assertEqual('application/app', MediaType.decode('app')) self.assertRaises( errors.DeserializationError, MediaType.decode, 'app;foo') def test_encode(self): - from letsencrypt.acme.jose.jws import MediaType + from acme.jose.jws import MediaType self.assertEqual('app', MediaType.encode('application/app')) self.assertEqual('application/app;foo', MediaType.encode('application/app;foo')) class HeaderTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jws.Header.""" + """Tests for acme.jose.jws.Header.""" def setUp(self): - from letsencrypt.acme.jose.jws import Header + from acme.jose.jws import Header self.header1 = Header(jwk='foo') self.header2 = Header(jwk='bar') self.crit = Header(crit=('a', 'b')) self.empty = Header() def test_add_non_empty(self): - from letsencrypt.acme.jose.jws import Header + from acme.jose.jws import Header self.assertEqual(Header(jwk='foo', crit=('a', 'b')), self.header1 + self.crit) @@ -65,12 +65,12 @@ class HeaderTest(unittest.TestCase): self.assertRaises(TypeError, self.header1.__add__, 'xxx') def test_crit_decode_always_errors(self): - from letsencrypt.acme.jose.jws import Header + from acme.jose.jws import Header self.assertRaises(errors.DeserializationError, Header.from_json, {'crit': ['a', 'b']}) def test_x5c_decoding(self): - from letsencrypt.acme.jose.jws import Header + from acme.jose.jws import Header header = Header(x5c=(CERT, CERT)) jobj = header.to_partial_json() cert_b64 = base64.b64encode(CERT.as_der()) @@ -86,30 +86,30 @@ class HeaderTest(unittest.TestCase): class SignatureTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jws.Signature.""" + """Tests for acme.jose.jws.Signature.""" def test_from_json(self): - from letsencrypt.acme.jose.jws import Header - from letsencrypt.acme.jose.jws import Signature + from acme.jose.jws import Header + from acme.jose.jws import Signature self.assertEqual( Signature(signature='foo', header=Header(alg=jwa.RS256)), Signature.from_json( {'signature': 'Zm9v', 'header': {'alg': 'RS256'}})) def test_from_json_no_alg_error(self): - from letsencrypt.acme.jose.jws import Signature + from acme.jose.jws import Signature self.assertRaises(errors.DeserializationError, Signature.from_json, {'signature': 'foo'}) class JWSTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.jws.JWS.""" + """Tests for acme.jose.jws.JWS.""" def setUp(self): self.privkey = jwk.JWKRSA(key=RSA512_KEY) self.pubkey = self.privkey.public() - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.unprotected = JWS.sign( payload='foo', key=self.privkey, alg=jwa.RS256) self.protected = JWS.sign( @@ -140,7 +140,7 @@ class JWSTest(unittest.TestCase): '_893n1zQjpim_eLS5J1F61lkvrCrCDErTEJnBGOGesJ72M7b6Ve1cAJA', compact) - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS mixed = JWS.from_compact(compact) self.assertNotEqual(self.mixed, mixed) @@ -148,7 +148,7 @@ class JWSTest(unittest.TestCase): set(['alg']), set(mixed.signature.combined.not_omitted())) def test_from_compact_missing_components(self): - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.assertRaises(errors.DeserializationError, JWS.from_compact, '.') def test_json_omitempty(self): @@ -160,7 +160,7 @@ class JWSTest(unittest.TestCase): unprotected_jobj['header'] = unprotected_jobj['header'].to_json() - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.assertEqual(JWS.from_json(protected_jobj), self.protected) self.assertEqual(JWS.from_json(unprotected_jobj), self.unprotected) @@ -175,7 +175,7 @@ class JWSTest(unittest.TestCase): jobj_from['header'] = jobj_from['header'].to_json() self.assertEqual(self.mixed.to_partial_json(flat=True), jobj_to) - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.assertEqual(self.mixed, JWS.from_json(jobj_from)) def test_json_not_flat(self): @@ -187,16 +187,16 @@ class JWSTest(unittest.TestCase): jobj_from['signatures'] = [jobj_to['signatures'][0].to_json()] self.assertEqual(self.mixed.to_partial_json(flat=False), jobj_to) - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.assertEqual(self.mixed, JWS.from_json(jobj_from)) def test_from_json_mixed_flat(self): - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS self.assertRaises(errors.DeserializationError, JWS.from_json, {'signatures': (), 'signature': 'foo'}) def test_from_json_hashable(self): - from letsencrypt.acme.jose.jws import JWS + from acme.jose.jws import JWS hash(JWS.from_json(self.mixed.to_json())) @@ -207,14 +207,14 @@ class CLITest(unittest.TestCase): __name__, os.path.join('testdata', 'rsa512_key.pem')) def test_unverified(self): - from letsencrypt.acme.jose.jws import CLI + from acme.jose.jws import CLI with mock.patch('sys.stdin') as sin: sin.read.return_value = '{"payload": "foo", "signature": "xxx"}' with mock.patch('sys.stdout'): self.assertEqual(-1, CLI.run(['verify'])) def test_json(self): - from letsencrypt.acme.jose.jws import CLI + from acme.jose.jws import CLI with mock.patch('sys.stdin') as sin: sin.read.return_value = 'foo' @@ -225,7 +225,7 @@ class CLITest(unittest.TestCase): self.assertEqual(0, CLI.run(['verify'])) def test_compact(self): - from letsencrypt.acme.jose.jws import CLI + from acme.jose.jws import CLI with mock.patch('sys.stdin') as sin: sin.read.return_value = 'foo' diff --git a/letsencrypt/acme/jose/testdata/README b/acme/jose/testdata/README similarity index 100% rename from letsencrypt/acme/jose/testdata/README rename to acme/jose/testdata/README diff --git a/letsencrypt/acme/jose/testdata/csr2.pem b/acme/jose/testdata/csr2.pem similarity index 100% rename from letsencrypt/acme/jose/testdata/csr2.pem rename to acme/jose/testdata/csr2.pem diff --git a/letsencrypt/acme/jose/testdata/rsa1024_key.pem b/acme/jose/testdata/rsa1024_key.pem similarity index 100% rename from letsencrypt/acme/jose/testdata/rsa1024_key.pem rename to acme/jose/testdata/rsa1024_key.pem diff --git a/letsencrypt/acme/jose/testdata/rsa256_key.pem b/acme/jose/testdata/rsa256_key.pem similarity index 100% rename from letsencrypt/acme/jose/testdata/rsa256_key.pem rename to acme/jose/testdata/rsa256_key.pem diff --git a/letsencrypt/acme/jose/testdata/rsa512_key.pem b/acme/jose/testdata/rsa512_key.pem similarity index 100% rename from letsencrypt/acme/jose/testdata/rsa512_key.pem rename to acme/jose/testdata/rsa512_key.pem diff --git a/letsencrypt/acme/jose/util.py b/acme/jose/util.py similarity index 100% rename from letsencrypt/acme/jose/util.py rename to acme/jose/util.py diff --git a/letsencrypt/acme/jose/util_test.py b/acme/jose/util_test.py similarity index 87% rename from letsencrypt/acme/jose/util_test.py rename to acme/jose/util_test.py index fc75497e0..1c179ee6b 100644 --- a/letsencrypt/acme/jose/util_test.py +++ b/acme/jose/util_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.jose.util.""" +"""Tests for acme.jose.util.""" import functools import os import pkg_resources @@ -8,10 +8,10 @@ import Crypto.PublicKey.RSA class HashableRSAKeyTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.util.HashableRSAKey.""" + """Tests for acme.jose.util.HashableRSAKey.""" def setUp(self): - from letsencrypt.acme.jose.util import HashableRSAKey + from acme.jose.util import HashableRSAKey self.key = HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( __name__, os.path.join('testdata', 'rsa256_key.pem')))) @@ -28,17 +28,17 @@ class HashableRSAKeyTest(unittest.TestCase): self.assertTrue(isinstance(hash(self.key), int)) def test_publickey(self): - from letsencrypt.acme.jose.util import HashableRSAKey + from acme.jose.util import HashableRSAKey self.assertTrue(isinstance(self.key.publickey(), HashableRSAKey)) class ImmutableMapTest(unittest.TestCase): - """Tests for letsencrypt.acme.jose.util.ImmutableMap.""" + """Tests for acme.jose.util.ImmutableMap.""" def setUp(self): # pylint: disable=invalid-name,too-few-public-methods # pylint: disable=missing-docstring - from letsencrypt.acme.jose.util import ImmutableMap + from acme.jose.util import ImmutableMap class A(ImmutableMap): __slots__ = ('x', 'y') @@ -101,18 +101,18 @@ class ImmutableMapTest(unittest.TestCase): class frozendictTest(unittest.TestCase): # pylint: disable=invalid-name - """Tests for letsencrypt.acme.jose.util.frozendict.""" + """Tests for acme.jose.util.frozendict.""" def setUp(self): - from letsencrypt.acme.jose.util import frozendict + from acme.jose.util import frozendict self.fdict = frozendict(x=1, y='2') def test_init_dict(self): - from letsencrypt.acme.jose.util import frozendict + from acme.jose.util import frozendict self.assertEqual(self.fdict, frozendict({'x': 1, 'y': '2'})) def test_init_other_raises_type_error(self): - from letsencrypt.acme.jose.util import frozendict + from acme.jose.util import frozendict # specifically fail for generators... self.assertRaises(TypeError, frozendict, {'a': 'b'}.iteritems()) diff --git a/letsencrypt/acme/messages.py b/acme/messages.py similarity index 89% rename from letsencrypt/acme/messages.py rename to acme/messages.py index 41b7389a7..6d46f894c 100644 --- a/letsencrypt/acme/messages.py +++ b/acme/messages.py @@ -22,11 +22,11 @@ """ import jsonschema -from letsencrypt.acme import challenges -from letsencrypt.acme import errors -from letsencrypt.acme import jose -from letsencrypt.acme import other -from letsencrypt.acme import util +from acme import challenges +from acme import errors +from acme import jose +from acme import other +from acme import util class Message(jose.TypedJSONObjectWithFields): @@ -41,7 +41,7 @@ class Message(jose.TypedJSONObjectWithFields): Subclasses must overrride it with a value that is acceptable by :func:`jsonschema.validate`, most probably using - :func:`letsencrypt.acme.util.load_schema`. + :func:`acme.util.load_schema`. """ @@ -53,10 +53,10 @@ class Message(jose.TypedJSONObjectWithFields): :param jobj: JSON object. - :raises letsencrypt.acme.errors.SchemaValidationError: if the input + :raises acme.errors.SchemaValidationError: if the input JSON object could not be validated against JSON schema specified in :attr:`schema`. - :raises letsencrypt.acme.jose.errors.DeserializationError: for any + :raises acme.jose.errors.DeserializationError: for any other generic error in decoding. :returns: instance of the class @@ -79,7 +79,7 @@ class Challenge(Message): :ivar str nonce: Random data, **not** base64-encoded. :ivar list challenges: List of - :class:`~letsencrypt.acme.challenges.Challenge` objects. + :class:`~acme.challenges.Challenge` objects. .. todo:: 1. can challenges contain two challenges of the same type? @@ -121,7 +121,7 @@ class ChallengeRequest(Message): class Authorization(Message): """ACME "authorization" message. - :ivar jwk: :class:`letsencrypt.acme.jose.JWK` + :ivar jwk: :class:`acme.jose.JWK` """ typ = "authorization" @@ -139,8 +139,8 @@ class AuthorizationRequest(Message): :ivar str nonce: Random data from the corresponding :attr:`Challenge.nonce`, **not** base64-encoded. :ivar list responses: List of completed challenges ( - :class:`letsencrypt.acme.challenges.ChallengeResponse`). - :ivar signature: Signature (:class:`letsencrypt.acme.other.Signature`). + :class:`acme.challenges.ChallengeResponse`). + :ivar signature: Signature (:class:`acme.other.Signature`). """ typ = "authorizationRequest" @@ -184,7 +184,7 @@ class AuthorizationRequest(Message): """Verify signature. .. warning:: Caller must check that the public key encoded in the - :attr:`signature`'s :class:`letsencrypt.acme.jose.JWK` object + :attr:`signature`'s :class:`acme.jose.JWK` object is the correct key for a given context. :param str name: Hostname @@ -202,10 +202,10 @@ class Certificate(Message): """ACME "certificate" message. :ivar certificate: The certificate (:class:`M2Crypto.X509.X509` - wrapped in :class:`letsencrypt.acme.util.ComparableX509`). + wrapped in :class:`acme.util.ComparableX509`). :ivar list chain: Chain of certificates (:class:`M2Crypto.X509.X509` - wrapped in :class:`letsencrypt.acme.util.ComparableX509` ). + wrapped in :class:`acme.util.ComparableX509` ). """ typ = "certificate" @@ -230,8 +230,8 @@ class CertificateRequest(Message): """ACME "certificateRequest" message. :ivar csr: Certificate Signing Request (:class:`M2Crypto.X509.Request` - wrapped in :class:`letsencrypt.acme.util.ComparableX509`. - :ivar signature: Signature (:class:`letsencrypt.acme.other.Signature`). + wrapped in :class:`acme.util.ComparableX509`. + :ivar signature: Signature (:class:`acme.other.Signature`). """ typ = "certificateRequest" @@ -262,7 +262,7 @@ class CertificateRequest(Message): """Verify signature. .. warning:: Caller must check that the public key encoded in the - :attr:`signature`'s :class:`letsencrypt.acme.jose.JWK` object + :attr:`signature`'s :class:`acme.jose.JWK` object is the correct key for a given context. :returns: True iff ``signature`` can be verified, False otherwise. @@ -316,8 +316,8 @@ class RevocationRequest(Message): """ACME "revocationRequest" message. :ivar certificate: Certificate (:class:`M2Crypto.X509.X509` - wrapped in :class:`letsencrypt.acme.util.ComparableX509`). - :ivar signature: Signature (:class:`letsencrypt.acme.other.Signature`). + wrapped in :class:`acme.util.ComparableX509`). + :ivar signature: Signature (:class:`acme.other.Signature`). """ typ = "revocationRequest" @@ -348,7 +348,7 @@ class RevocationRequest(Message): """Verify signature. .. warning:: Caller must check that the public key encoded in the - :attr:`signature`'s :class:`letsencrypt.acme.jose.JWK` object + :attr:`signature`'s :class:`acme.jose.JWK` object is the correct key for a given context. :returns: True iff ``signature`` can be verified, False otherwise. diff --git a/letsencrypt/acme/messages2.py b/acme/messages2.py similarity index 91% rename from letsencrypt/acme/messages2.py rename to acme/messages2.py index a2829ff57..419bb0b4e 100644 --- a/letsencrypt/acme/messages2.py +++ b/acme/messages2.py @@ -1,7 +1,7 @@ """ACME protocol messages.""" -from letsencrypt.acme import challenges -from letsencrypt.acme import fields -from letsencrypt.acme import jose +from acme import challenges +from acme import fields +from acme import jose class Error(jose.JSONObjectWithFields, Exception): @@ -101,7 +101,7 @@ IDENTIFIER_FQDN = IdentifierType('dns') # IdentifierDNS in Boulder class Identifier(jose.JSONObjectWithFields): """ACME identifier. - :ivar letsencrypt.acme.messages2.IdentifierType typ: + :ivar acme.messages2.IdentifierType typ: """ typ = jose.Field('type', decoder=IdentifierType.from_json) @@ -111,7 +111,7 @@ class Identifier(jose.JSONObjectWithFields): class Resource(jose.ImmutableMap): """ACME Resource. - :ivar letsencrypt.acme.messages2.ResourceBody body: Resource body. + :ivar acme.messages2.ResourceBody body: Resource body. :ivar str uri: Location of the resource. """ @@ -125,7 +125,7 @@ class ResourceBody(jose.JSONObjectWithFields): class RegistrationResource(Resource): """Registration Resource. - :ivar letsencrypt.acme.messages2.Registration body: + :ivar acme.messages2.Registration body: :ivar str new_authzr_uri: URI found in the 'next' ``Link`` header :ivar str terms_of_service: URL for the CA TOS. @@ -136,7 +136,7 @@ class RegistrationResource(Resource): class Registration(ResourceBody): """Registration Resource Body. - :ivar letsencrypt.acme.jose.jwk.JWK key: Public key. + :ivar acme.jose.jwk.JWK key: Public key. :ivar tuple contact: Contact information following ACME spec """ @@ -151,7 +151,7 @@ class Registration(ResourceBody): class ChallengeResource(Resource, jose.JSONObjectWithFields): """Challenge Resource. - :ivar letsencrypt.acme.messages2.ChallengeBody body: + :ivar acme.messages2.ChallengeBody body: :ivar str authzr_uri: URI found in the 'up' ``Link`` header. """ @@ -173,10 +173,10 @@ class ChallengeBody(ResourceBody): such as ``challb`` to distinguish instances of this class from ``achall``. - :ivar letsencrypt.acme.challenges.Challenge: Wrapped challenge. + :ivar acme.challenges.Challenge: Wrapped challenge. Conveniently, all challenge fields are proxied, i.e. you can call ``challb.x`` to get ``challb.chall.x`` contents. - :ivar letsencrypt.acme.messages2.Status status: + :ivar acme.messages2.Status status: :ivar datetime.datetime validated: """ @@ -203,7 +203,7 @@ class ChallengeBody(ResourceBody): class AuthorizationResource(Resource): """Authorization Resource. - :ivar letsencrypt.acme.messages2.Authorization body: + :ivar acme.messages2.Authorization body: :ivar str new_cert_uri: URI found in the 'next' ``Link`` header """ @@ -213,13 +213,13 @@ class AuthorizationResource(Resource): class Authorization(ResourceBody): """Authorization Resource Body. - :ivar letsencrypt.acme.messages2.Identifier identifier: + :ivar acme.messages2.Identifier identifier: :ivar list challenges: `list` of `.ChallengeBody` :ivar tuple combinations: Challenge combinations (`tuple` of `tuple` of `int`, as opposed to `list` of `list` from the spec). - :ivar letsencrypt.acme.jose.jwk.JWK key: Public key. + :ivar acme.jose.jwk.JWK key: Public key. :ivar tuple contact: - :ivar letsencrypt.acme.messages2.Status status: + :ivar acme.messages2.Status status: :ivar datetime.datetime expires: """ @@ -252,7 +252,7 @@ class Authorization(ResourceBody): class CertificateRequest(jose.JSONObjectWithFields): """ACME new-cert request. - :ivar letsencrypt.acme.jose.util.ComparableX509 csr: + :ivar acme.jose.util.ComparableX509 csr: `M2Crypto.X509.Request` wrapped in `.ComparableX509` :ivar tuple authorizations: `tuple` of URIs (`str`) @@ -264,7 +264,7 @@ class CertificateRequest(jose.JSONObjectWithFields): class CertificateResource(Resource): """Certificate Resource. - :ivar letsencrypt.acme.jose.util.ComparableX509 body: + :ivar acme.jose.util.ComparableX509 body: `M2Crypto.X509.X509` wrapped in `.ComparableX509` :ivar str cert_chain_uri: URI found in the 'up' ``Link`` header :ivar tuple authzrs: `tuple` of `AuthorizationResource`. diff --git a/letsencrypt/acme/messages2_test.py b/acme/messages2_test.py similarity index 78% rename from letsencrypt/acme/messages2_test.py rename to acme/messages2_test.py index 9e8ef33c8..d0c7fdea1 100644 --- a/letsencrypt/acme/messages2_test.py +++ b/acme/messages2_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.messages2.""" +"""Tests for acme.messages2.""" import datetime import os import pkg_resources @@ -8,19 +8,19 @@ import mock import pytz from Crypto.PublicKey import RSA -from letsencrypt.acme import challenges -from letsencrypt.acme import jose +from acme import challenges +from acme import jose KEY = jose.util.HashableRSAKey(RSA.importKey(pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) class ErrorTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.Error.""" + """Tests for acme.messages2.Error.""" def setUp(self): - from letsencrypt.acme.messages2 import Error + from acme.messages2 import Error self.error = Error(detail='foo', typ='malformed') def test_typ_prefix(self): @@ -31,14 +31,14 @@ class ErrorTest(unittest.TestCase): 'malformed', self.error.from_json(self.error.to_partial_json()).typ) def test_typ_decoder_missing_prefix(self): - from letsencrypt.acme.messages2 import Error + from acme.messages2 import Error self.assertRaises(jose.DeserializationError, Error.from_json, {'detail': 'foo', 'type': 'malformed'}) self.assertRaises(jose.DeserializationError, Error.from_json, {'detail': 'foo', 'type': 'not valid bare type'}) def test_typ_decoder_not_recognized(self): - from letsencrypt.acme.messages2 import Error + from acme.messages2 import Error self.assertRaises(jose.DeserializationError, Error.from_json, {'detail': 'foo', 'type': 'urn:acme:error:baz'}) @@ -47,7 +47,7 @@ class ErrorTest(unittest.TestCase): 'The request message was malformed', self.error.description) def test_from_json_hashable(self): - from letsencrypt.acme.messages2 import Error + from acme.messages2 import Error hash(Error.from_json(self.error.to_json())) def test_str(self): @@ -58,10 +58,10 @@ class ErrorTest(unittest.TestCase): class ConstantTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2._Constant.""" + """Tests for acme.messages2._Constant.""" def setUp(self): - from letsencrypt.acme.messages2 import _Constant + from acme.messages2 import _Constant class MockConstant(_Constant): # pylint: disable=missing-docstring POSSIBLE_NAMES = {} @@ -94,7 +94,7 @@ class ConstantTest(unittest.TestCase): self.assertFalse(self.const_a != const_a_prime) class RegistrationTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.Registration.""" + """Tests for acme.messages2.Registration.""" def setUp(self): key = jose.jwk.JWKRSA(key=KEY.publickey()) @@ -102,7 +102,7 @@ class RegistrationTest(unittest.TestCase): recovery_token = 'XYZ' agreement = 'https://letsencrypt.org/terms' - from letsencrypt.acme.messages2 import Registration + from acme.messages2 import Registration self.reg = Registration( key=key, contact=contact, recovery_token=recovery_token, agreement=agreement) @@ -120,31 +120,31 @@ class RegistrationTest(unittest.TestCase): self.assertEqual(self.jobj_to, self.reg.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.messages2 import Registration + from acme.messages2 import Registration self.assertEqual(self.reg, Registration.from_json(self.jobj_from)) def test_from_json_hashable(self): - from letsencrypt.acme.messages2 import Registration + from acme.messages2 import Registration hash(Registration.from_json(self.jobj_from)) class ChallengeResourceTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.ChallengeResource.""" + """Tests for acme.messages2.ChallengeResource.""" def test_uri(self): - from letsencrypt.acme.messages2 import ChallengeResource + from acme.messages2 import ChallengeResource self.assertEqual('http://challb', ChallengeResource(body=mock.MagicMock( uri='http://challb'), authzr_uri='http://authz').uri) class ChallengeBodyTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.ChallengeBody.""" + """Tests for acme.messages2.ChallengeBody.""" def setUp(self): self.chall = challenges.DNS(token='foo') - from letsencrypt.acme.messages2 import ChallengeBody - from letsencrypt.acme.messages2 import STATUS_VALID + from acme.messages2 import ChallengeBody + from acme.messages2 import STATUS_VALID self.status = STATUS_VALID self.challb = ChallengeBody( uri='http://challb', chall=self.chall, status=self.status) @@ -162,11 +162,11 @@ class ChallengeBodyTest(unittest.TestCase): self.assertEqual(self.jobj_to, self.challb.to_partial_json()) def test_from_json(self): - from letsencrypt.acme.messages2 import ChallengeBody + from acme.messages2 import ChallengeBody self.assertEqual(self.challb, ChallengeBody.from_json(self.jobj_from)) def test_from_json_hashable(self): - from letsencrypt.acme.messages2 import ChallengeBody + from acme.messages2 import ChallengeBody hash(ChallengeBody.from_json(self.jobj_from)) def test_proxy(self): @@ -174,11 +174,11 @@ class ChallengeBodyTest(unittest.TestCase): class AuthorizationTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.Authorization.""" + """Tests for acme.messages2.Authorization.""" def setUp(self): - from letsencrypt.acme.messages2 import ChallengeBody - from letsencrypt.acme.messages2 import STATUS_VALID + from acme.messages2 import ChallengeBody + from acme.messages2 import STATUS_VALID self.challbs = ( ChallengeBody( uri='http://challb1', status=STATUS_VALID, @@ -190,9 +190,9 @@ class AuthorizationTest(unittest.TestCase): ) combinations = ((0, 2), (1, 2)) - from letsencrypt.acme.messages2 import Authorization - from letsencrypt.acme.messages2 import Identifier - from letsencrypt.acme.messages2 import IDENTIFIER_FQDN + from acme.messages2 import Authorization + from acme.messages2 import Identifier + from acme.messages2 import IDENTIFIER_FQDN identifier = Identifier(typ=IDENTIFIER_FQDN, value='example.com') self.authz = Authorization( identifier=identifier, combinations=combinations, @@ -205,11 +205,11 @@ class AuthorizationTest(unittest.TestCase): } def test_from_json(self): - from letsencrypt.acme.messages2 import Authorization + from acme.messages2 import Authorization Authorization.from_json(self.jobj_from) def test_from_json_hashable(self): - from letsencrypt.acme.messages2 import Authorization + from acme.messages2 import Authorization hash(Authorization.from_json(self.jobj_from)) def test_resolved_combinations(self): @@ -220,10 +220,10 @@ class AuthorizationTest(unittest.TestCase): class RevocationTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages2.RevocationTest.""" + """Tests for acme.messages2.RevocationTest.""" def setUp(self): - from letsencrypt.acme.messages2 import Revocation + from acme.messages2 import Revocation self.rev_now = Revocation(authorizations=(), revoke=Revocation.NOW) self.rev_date = Revocation(authorizations=(), revoke=datetime.datetime( 2015, 3, 27, tzinfo=pytz.utc)) @@ -232,7 +232,7 @@ class RevocationTest(unittest.TestCase): 'revoke': '2015-03-27T00:00:00Z'} def test_revoke_decoder(self): - from letsencrypt.acme.messages2 import Revocation + from acme.messages2 import Revocation self.assertEqual(self.rev_now, Revocation.from_json(self.jobj_now)) self.assertEqual(self.rev_date, Revocation.from_json(self.jobj_date)) @@ -241,7 +241,7 @@ class RevocationTest(unittest.TestCase): self.assertEqual(self.jobj_date, self.rev_date.to_partial_json()) def test_from_json_hashable(self): - from letsencrypt.acme.messages2 import Revocation + from acme.messages2 import Revocation hash(Revocation.from_json(self.rev_now.to_json())) diff --git a/letsencrypt/acme/messages_test.py b/acme/messages_test.py similarity index 86% rename from letsencrypt/acme/messages_test.py rename to acme/messages_test.py index 56781db18..1acb0e838 100644 --- a/letsencrypt/acme/messages_test.py +++ b/acme/messages_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.acme.messages.""" +"""Tests for acme.messages.""" import os import pkg_resources import unittest @@ -6,15 +6,15 @@ import unittest import Crypto.PublicKey.RSA import M2Crypto -from letsencrypt.acme import challenges -from letsencrypt.acme import errors -from letsencrypt.acme import jose -from letsencrypt.acme import other +from acme import challenges +from acme import errors +from acme import jose +from acme import other KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) CERT = jose.ComparableX509(M2Crypto.X509.load_cert( pkg_resources.resource_filename( 'letsencrypt.client.tests', os.path.join('testdata', 'cert.pem')))) @@ -23,15 +23,15 @@ CSR = jose.ComparableX509(M2Crypto.X509.load_request( 'letsencrypt.client.tests', os.path.join('testdata', 'csr.pem')))) CSR2 = jose.ComparableX509(M2Crypto.X509.load_request( pkg_resources.resource_filename( - 'letsencrypt.acme.jose', os.path.join('testdata', 'csr2.pem')))) + 'acme.jose', os.path.join('testdata', 'csr2.pem')))) class MessageTest(unittest.TestCase): - """Tests for letsencrypt.acme.messages.Message.""" + """Tests for acme.messages.Message.""" def setUp(self): # pylint: disable=missing-docstring,too-few-public-methods - from letsencrypt.acme.messages import Message + from acme.messages import Message class MockParentMessage(Message): # pylint: disable=abstract-method @@ -69,7 +69,7 @@ class ChallengeTest(unittest.TestCase): ) combinations = ((0, 2), (1, 2)) - from letsencrypt.acme.messages import Challenge + from acme.messages import Challenge self.msg = Challenge( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', @@ -107,14 +107,14 @@ class ChallengeTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): - from letsencrypt.acme.messages import Challenge + from acme.messages import Challenge self.assertEqual(Challenge.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): del self.jmsg_from['combinations'] del self.jmsg_to['combinations'] - from letsencrypt.acme.messages import Challenge + from acme.messages import Challenge msg = Challenge.from_json(self.jmsg_from) self.assertEqual(msg.combinations, ()) @@ -124,7 +124,7 @@ class ChallengeTest(unittest.TestCase): class ChallengeRequestTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.messages import ChallengeRequest + from acme.messages import ChallengeRequest self.msg = ChallengeRequest(identifier='example.com') self.jmsg = { @@ -136,7 +136,7 @@ class ChallengeRequestTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): - from letsencrypt.acme.messages import ChallengeRequest + from acme.messages import ChallengeRequest self.assertEqual(ChallengeRequest.from_json(self.jmsg), self.msg) @@ -145,7 +145,7 @@ class AuthorizationTest(unittest.TestCase): def setUp(self): jwk = jose.JWKRSA(key=KEY.publickey()) - from letsencrypt.acme.messages import Authorization + from acme.messages import Authorization self.msg = Authorization(recovery_token='tok', jwk=jwk, identifier='example.com') @@ -162,7 +162,7 @@ class AuthorizationTest(unittest.TestCase): def test_from_json(self): self.jmsg['jwk'] = self.jmsg['jwk'].to_partial_json() - from letsencrypt.acme.messages import Authorization + from acme.messages import Authorization self.assertEqual(Authorization.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): @@ -170,7 +170,7 @@ class AuthorizationTest(unittest.TestCase): del self.jmsg['identifier'] del self.jmsg['jwk'] - from letsencrypt.acme.messages import Authorization + from acme.messages import Authorization msg = Authorization.from_json(self.jmsg) self.assertTrue(msg.recovery_token is None) @@ -196,7 +196,7 @@ class AuthorizationRequestTest(unittest.TestCase): '\x92\xe9\x96\x11\xc2\xefx\x0bR', nonce='\xab?\x08o\xe6\x81$\x9f\xa1\xc9\x025\x1c\x1b\xa5+') - from letsencrypt.acme.messages import AuthorizationRequest + from acme.messages import AuthorizationRequest self.msg = AuthorizationRequest( session_id='aefoGaavieG9Wihuk2aufai3aeZ5EeW4', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', @@ -226,7 +226,7 @@ class AuthorizationRequestTest(unittest.TestCase): } def test_create(self): - from letsencrypt.acme.messages import AuthorizationRequest + from acme.messages import AuthorizationRequest self.assertEqual(self.msg, AuthorizationRequest.create( name='example.com', key=KEY, responses=self.responses, nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9', @@ -241,7 +241,7 @@ class AuthorizationRequestTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): - from letsencrypt.acme.messages import AuthorizationRequest + from acme.messages import AuthorizationRequest self.assertEqual( self.msg, AuthorizationRequest.from_json(self.jmsg_from)) @@ -249,7 +249,7 @@ class AuthorizationRequestTest(unittest.TestCase): del self.jmsg_from['contact'] del self.jmsg_to['contact'] - from letsencrypt.acme.messages import AuthorizationRequest + from acme.messages import AuthorizationRequest msg = AuthorizationRequest.from_json(self.jmsg_from) self.assertEqual(msg.contact, ()) @@ -261,7 +261,7 @@ class CertificateTest(unittest.TestCase): def setUp(self): refresh = 'https://example.com/refresh/Dr8eAwTVQfSS/' - from letsencrypt.acme.messages import Certificate + from acme.messages import Certificate self.msg = Certificate( certificate=CERT, chain=(CERT,), refresh=refresh) @@ -279,7 +279,7 @@ class CertificateTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): - from letsencrypt.acme.messages import Certificate + from acme.messages import Certificate self.assertEqual(Certificate.from_json(self.jmsg_from), self.msg) def test_json_without_optionals(self): @@ -288,7 +288,7 @@ class CertificateTest(unittest.TestCase): del self.jmsg_to['chain'] del self.jmsg_to['refresh'] - from letsencrypt.acme.messages import Certificate + from acme.messages import Certificate msg = Certificate.from_json(self.jmsg_from) self.assertEqual(msg.chain, ()) @@ -307,7 +307,7 @@ class CertificateRequestTest(unittest.TestCase): 'k\xfe\xee\xb4\xe4\xc8\x05\x9a\x08\xa7', nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9') - from letsencrypt.acme.messages import CertificateRequest + from acme.messages import CertificateRequest self.msg = CertificateRequest(csr=CSR, signature=signature) self.jmsg_to = { @@ -319,7 +319,7 @@ class CertificateRequestTest(unittest.TestCase): self.jmsg_from['signature'] = self.jmsg_from['signature'].to_json() def test_create(self): - from letsencrypt.acme.messages import CertificateRequest + from acme.messages import CertificateRequest self.assertEqual(self.msg, CertificateRequest.create( csr=CSR, key=KEY, sig_nonce='\xec\xd6\xf2oYH\xeb\x13\xd5#q\xe0\xdd\xa2\x92\xa9')) @@ -331,14 +331,14 @@ class CertificateRequestTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): - from letsencrypt.acme.messages import CertificateRequest + from acme.messages import CertificateRequest self.assertEqual(self.msg, CertificateRequest.from_json(self.jmsg_from)) class DeferTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.messages import Defer + from acme.messages import Defer self.msg = Defer( token='O7-s9MNq1siZHlgrMzi9_A', interval=60, message='Warming up the HSM') @@ -354,14 +354,14 @@ class DeferTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): - from letsencrypt.acme.messages import Defer + from acme.messages import Defer self.assertEqual(Defer.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['interval'] del self.jmsg['message'] - from letsencrypt.acme.messages import Defer + from acme.messages import Defer msg = Defer.from_json(self.jmsg) self.assertTrue(msg.interval is None) @@ -372,7 +372,7 @@ class DeferTest(unittest.TestCase): class ErrorTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.messages import Error + from acme.messages import Error self.msg = Error( error='badCSR', message='RSA keys must be at least 2048 bits long', more_info='https://ca.example.com/documentation/csr-requirements') @@ -388,14 +388,14 @@ class ErrorTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): - from letsencrypt.acme.messages import Error + from acme.messages import Error self.assertEqual(Error.from_json(self.jmsg), self.msg) def test_json_without_optionals(self): del self.jmsg['message'] del self.jmsg['moreInfo'] - from letsencrypt.acme.messages import Error + from acme.messages import Error msg = Error.from_json(self.jmsg) self.assertTrue(msg.message is None) @@ -406,7 +406,7 @@ class ErrorTest(unittest.TestCase): class RevocationTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.messages import Revocation + from acme.messages import Revocation self.msg = Revocation() self.jmsg = {'type': 'revocation'} @@ -414,7 +414,7 @@ class RevocationTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): - from letsencrypt.acme.messages import Revocation + from acme.messages import Revocation self.assertEqual(Revocation.from_json(self.jmsg), self.msg) @@ -431,7 +431,7 @@ class RevocationRequestTest(unittest.TestCase): 's\xd9\xd0\xe7', nonce=self.sig_nonce) - from letsencrypt.acme.messages import RevocationRequest + from acme.messages import RevocationRequest self.msg = RevocationRequest(certificate=CERT, signature=signature) self.jmsg_to = { @@ -443,7 +443,7 @@ class RevocationRequestTest(unittest.TestCase): self.jmsg_from['signature'] = self.jmsg_from['signature'].to_json() def test_create(self): - from letsencrypt.acme.messages import RevocationRequest + from acme.messages import RevocationRequest self.assertEqual(self.msg, RevocationRequest.create( certificate=CERT, key=KEY, sig_nonce=self.sig_nonce)) @@ -454,14 +454,14 @@ class RevocationRequestTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg_to) def test_from_json(self): - from letsencrypt.acme.messages import RevocationRequest + from acme.messages import RevocationRequest self.assertEqual(self.msg, RevocationRequest.from_json(self.jmsg_from)) class StatusRequestTest(unittest.TestCase): def setUp(self): - from letsencrypt.acme.messages import StatusRequest + from acme.messages import StatusRequest self.msg = StatusRequest(token=u'O7-s9MNq1siZHlgrMzi9_A') self.jmsg = { 'type': 'statusRequest', @@ -472,7 +472,7 @@ class StatusRequestTest(unittest.TestCase): self.assertEqual(self.msg.to_partial_json(), self.jmsg) def test_from_json(self): - from letsencrypt.acme.messages import StatusRequest + from acme.messages import StatusRequest self.assertEqual(StatusRequest.from_json(self.jmsg), self.msg) diff --git a/letsencrypt/acme/other.py b/acme/other.py similarity index 98% rename from letsencrypt/acme/other.py rename to acme/other.py index 99a4ec551..d7eb49156 100644 --- a/letsencrypt/acme/other.py +++ b/acme/other.py @@ -5,7 +5,7 @@ import logging import Crypto.Random import Crypto.PublicKey.RSA -from letsencrypt.acme import jose +from acme import jose class Signature(jose.JSONObjectWithFields): diff --git a/letsencrypt/acme/other_test.py b/acme/other_test.py similarity index 87% rename from letsencrypt/acme/other_test.py rename to acme/other_test.py index eefcb2fc5..d106c50ab 100644 --- a/letsencrypt/acme/other_test.py +++ b/acme/other_test.py @@ -1,21 +1,21 @@ -"""Tests for letsencrypt.acme.sig.""" +"""Tests for acme.sig.""" import os import pkg_resources import unittest import Crypto.PublicKey.RSA -from letsencrypt.acme import jose +from acme import jose KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) class SignatureTest(unittest.TestCase): # pylint: disable=too-many-instance-attributes - """Tests for letsencrypt.acme.sig.Signature.""" + """Tests for acme.sig.Signature.""" def setUp(self): self.msg = 'message' @@ -45,7 +45,7 @@ class SignatureTest(unittest.TestCase): 'sig': b64sig, } - from letsencrypt.acme.other import Signature + from acme.other import Signature self.signature = Signature( alg=self.alg, sig=self.sig, nonce=self.nonce, jwk=self.jwk) @@ -63,7 +63,7 @@ class SignatureTest(unittest.TestCase): @classmethod def _from_msg(cls, *args, **kwargs): - from letsencrypt.acme.other import Signature + from acme.other import Signature return Signature.from_msg(*args, **kwargs) def test_create_from_msg(self): @@ -80,12 +80,12 @@ class SignatureTest(unittest.TestCase): self.assertEqual(self.signature.to_partial_json(), self.jsig_to) def test_from_json(self): - from letsencrypt.acme.other import Signature + from acme.other import Signature self.assertEqual( self.signature, Signature.from_json(self.jsig_from)) def test_from_json_non_schema_errors(self): - from letsencrypt.acme.other import Signature + from acme.other import Signature jwk = self.jwk.to_partial_json() self.assertRaises( jose.DeserializationError, Signature.from_json, { diff --git a/letsencrypt/acme/schemata/authorization.json b/acme/schemata/authorization.json similarity index 88% rename from letsencrypt/acme/schemata/authorization.json rename to acme/schemata/authorization.json index 742a9c0d5..122f263e1 100644 --- a/letsencrypt/acme/schemata/authorization.json +++ b/acme/schemata/authorization.json @@ -15,7 +15,7 @@ "type": "string" }, "jwk": { - "$ref": "file:letsencrypt/acme/schemata/jwk.json" + "$ref": "file:acme/schemata/jwk.json" } } } diff --git a/letsencrypt/acme/schemata/authorizationRequest.json b/acme/schemata/authorizationRequest.json similarity index 85% rename from letsencrypt/acme/schemata/authorizationRequest.json rename to acme/schemata/authorizationRequest.json index ee22808bc..2d4371cb8 100644 --- a/letsencrypt/acme/schemata/authorizationRequest.json +++ b/acme/schemata/authorizationRequest.json @@ -15,14 +15,14 @@ "type": "string" }, "signature" : { - "$ref": "file:letsencrypt/acme/schemata/signature.json" + "$ref": "file:acme/schemata/signature.json" }, "responses": { "type": "array", "minItems": 1, "items": { "anyOf": [ - { "$ref": "file:letsencrypt/acme/schemata/responseobject.json" }, + { "$ref": "file:acme/schemata/responseobject.json" }, { "type": "null" } ] } diff --git a/letsencrypt/acme/schemata/certificate.json b/acme/schemata/certificate.json similarity index 100% rename from letsencrypt/acme/schemata/certificate.json rename to acme/schemata/certificate.json diff --git a/letsencrypt/acme/schemata/certificateRequest.json b/acme/schemata/certificateRequest.json similarity index 88% rename from letsencrypt/acme/schemata/certificateRequest.json rename to acme/schemata/certificateRequest.json index c75e93bd9..ef3e18f98 100644 --- a/letsencrypt/acme/schemata/certificateRequest.json +++ b/acme/schemata/certificateRequest.json @@ -13,7 +13,7 @@ "pattern": "^[-_=0-9A-Za-z]+$" }, "signature" : { - "$ref": "file:letsencrypt/acme/schemata/signature.json" + "$ref": "file:acme/schemata/signature.json" } } } diff --git a/letsencrypt/acme/schemata/challenge.json b/acme/schemata/challenge.json similarity index 91% rename from letsencrypt/acme/schemata/challenge.json rename to acme/schemata/challenge.json index b4b2a5205..978fcd4c4 100644 --- a/letsencrypt/acme/schemata/challenge.json +++ b/acme/schemata/challenge.json @@ -18,7 +18,7 @@ "type": "array", "minItems": 1, "items": { - "$ref": "file:letsencrypt/acme/schemata/challengeobject.json" + "$ref": "file:acme/schemata/challengeobject.json" } }, "combinations": { diff --git a/letsencrypt/acme/schemata/challengeRequest.json b/acme/schemata/challengeRequest.json similarity index 100% rename from letsencrypt/acme/schemata/challengeRequest.json rename to acme/schemata/challengeRequest.json diff --git a/letsencrypt/acme/schemata/challengeobject.json b/acme/schemata/challengeobject.json similarity index 100% rename from letsencrypt/acme/schemata/challengeobject.json rename to acme/schemata/challengeobject.json diff --git a/letsencrypt/acme/schemata/defer.json b/acme/schemata/defer.json similarity index 100% rename from letsencrypt/acme/schemata/defer.json rename to acme/schemata/defer.json diff --git a/letsencrypt/acme/schemata/error.json b/acme/schemata/error.json similarity index 100% rename from letsencrypt/acme/schemata/error.json rename to acme/schemata/error.json diff --git a/letsencrypt/acme/schemata/jwk.json b/acme/schemata/jwk.json similarity index 100% rename from letsencrypt/acme/schemata/jwk.json rename to acme/schemata/jwk.json diff --git a/letsencrypt/acme/schemata/responseobject.json b/acme/schemata/responseobject.json similarity index 96% rename from letsencrypt/acme/schemata/responseobject.json rename to acme/schemata/responseobject.json index c6d6c9c1b..5ca6babf1 100644 --- a/letsencrypt/acme/schemata/responseobject.json +++ b/acme/schemata/responseobject.json @@ -59,7 +59,7 @@ "pattern": "^[-_=0-9A-Za-z]+$" }, "signature": { - "$ref": "file:letsencrypt/acme/schemata/signature.json" + "$ref": "file:acme/schemata/signature.json" } } }, diff --git a/letsencrypt/acme/schemata/revocation.json b/acme/schemata/revocation.json similarity index 100% rename from letsencrypt/acme/schemata/revocation.json rename to acme/schemata/revocation.json diff --git a/letsencrypt/acme/schemata/revocationRequest.json b/acme/schemata/revocationRequest.json similarity index 87% rename from letsencrypt/acme/schemata/revocationRequest.json rename to acme/schemata/revocationRequest.json index 5eb604fd9..7559d0ee0 100644 --- a/letsencrypt/acme/schemata/revocationRequest.json +++ b/acme/schemata/revocationRequest.json @@ -12,7 +12,7 @@ "type" : "string" }, "signature" : { - "$ref": "file:letsencrypt/acme/schemata/signature.json" + "$ref": "file:acme/schemata/signature.json" } } } diff --git a/letsencrypt/acme/schemata/signature.json b/acme/schemata/signature.json similarity index 100% rename from letsencrypt/acme/schemata/signature.json rename to acme/schemata/signature.json diff --git a/letsencrypt/acme/schemata/statusRequest.json b/acme/schemata/statusRequest.json similarity index 100% rename from letsencrypt/acme/schemata/statusRequest.json rename to acme/schemata/statusRequest.json diff --git a/letsencrypt/acme/util.py b/acme/util.py similarity index 100% rename from letsencrypt/acme/util.py rename to acme/util.py diff --git a/docs/acme/index.rst b/docs/acme/index.rst new file mode 100644 index 000000000..9cca3b795 --- /dev/null +++ b/docs/acme/index.rst @@ -0,0 +1,61 @@ +:mod:`acme` +=========== + +.. contents:: + +.. automodule:: acme + :members: + + +Messages +-------- + +v00 +~~~ + +.. automodule:: acme.messages + :members: + +v02 +~~~ + +.. automodule:: acme.messages2 + :members: + + +Challenges +---------- + +.. automodule:: acme.challenges + :members: + + +Other ACME objects +------------------ + +.. automodule:: acme.other + :members: + + +Fields +------ + +.. automodule:: acme.fields + :members: + + +Errors +------ + +.. automodule:: acme.errors + :members: + + + :members: + + +Utilities +--------- + +.. automodule:: acme.util + :members: diff --git a/docs/acme/jose.rst b/docs/acme/jose.rst new file mode 100644 index 000000000..fa3a0e9bb --- /dev/null +++ b/docs/acme/jose.rst @@ -0,0 +1,67 @@ +:mod:`acme.jose` +================ + +.. contents:: + +.. automodule:: acme.jose + :members: + + +JSON Web Algorithms +------------------- + +.. automodule:: acme.jose.jwa + :members: + + +JSON Web Key +------------ + +.. automodule:: acme.jose.jwk + :members: + + +JSON Web Signature +------------------ + +.. automodule:: acme.jose.jws + :members: + + +Implementation details +---------------------- + + +Interfaces +~~~~~~~~~~ + +.. automodule:: acme.jose.interfaces + :members: + + +Errors +~~~~~~ + +.. automodule:: acme.jose.errors + :members: + + +JSON utilities +~~~~~~~~~~~~~~ + +.. automodule:: acme.jose.json_util + :members: + + +JOSE Base64 +~~~~~~~~~~~ + +.. automodule:: acme.jose.b64 + :members: + + +Utilities +~~~~~~~~~ + +.. automodule:: acme.jose.util + :members: diff --git a/docs/api/acme/index.rst b/docs/api/acme/index.rst deleted file mode 100644 index 20206183a..000000000 --- a/docs/api/acme/index.rst +++ /dev/null @@ -1,61 +0,0 @@ -:mod:`letsencrypt.acme` -======================= - -.. contents:: - -.. automodule:: letsencrypt.acme - :members: - - -Messages --------- - -v00 -~~~ - -.. automodule:: letsencrypt.acme.messages - :members: - -v02 -~~~ - -.. automodule:: letsencrypt.acme.messages2 - :members: - - -Challenges ----------- - -.. automodule:: letsencrypt.acme.challenges - :members: - - -Other ACME objects ------------------- - -.. automodule:: letsencrypt.acme.other - :members: - - -Fields ------- - -.. automodule:: letsencrypt.acme.fields - :members: - - -Errors ------- - -.. automodule:: letsencrypt.acme.errors - :members: - - - :members: - - -Utilities ---------- - -.. automodule:: letsencrypt.acme.util - :members: diff --git a/docs/api/acme/jose.rst b/docs/api/acme/jose.rst deleted file mode 100644 index 9a64d33d3..000000000 --- a/docs/api/acme/jose.rst +++ /dev/null @@ -1,67 +0,0 @@ -:mod:`letsencrypt.acme.jose` -============================ - -.. contents:: - -.. automodule:: letsencrypt.acme.jose - :members: - - -JSON Web Algorithms -------------------- - -.. automodule:: letsencrypt.acme.jose.jwa - :members: - - -JSON Web Key ------------- - -.. automodule:: letsencrypt.acme.jose.jwk - :members: - - -JSON Web Signature ------------------- - -.. automodule:: letsencrypt.acme.jose.jws - :members: - - -Implementation details ----------------------- - - -Interfaces -~~~~~~~~~~ - -.. automodule:: letsencrypt.acme.jose.interfaces - :members: - - -Errors -~~~~~~ - -.. automodule:: letsencrypt.acme.jose.errors - :members: - - -JSON utilities -~~~~~~~~~~~~~~ - -.. automodule:: letsencrypt.acme.jose.json_util - :members: - - -JOSE Base64 -~~~~~~~~~~~ - -.. automodule:: letsencrypt.acme.jose.b64 - :members: - - -Utilities -~~~~~~~~~ - -.. automodule:: letsencrypt.acme.jose.util - :members: diff --git a/docs/contributing.rst b/docs/contributing.rst index d5088705b..4a61f7388 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -67,7 +67,7 @@ Support for other Linux distributions coming soon. Code components and layout ========================== -letsencrypt/acme +acme contains all protocol specific code letsencrypt/client all client code diff --git a/docs/index.rst b/docs/index.rst index 72be096f9..2edf74636 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,6 +8,7 @@ Welcome to the Let's Encrypt client documentation! using contributing plugins + acme .. toctree:: :maxdepth: 1 diff --git a/letsencrypt/client/account.py b/letsencrypt/client/account.py index 6c0ca9262..053f73a87 100644 --- a/letsencrypt/client/account.py +++ b/letsencrypt/client/account.py @@ -6,7 +6,7 @@ import re import configobj import zope.component -from letsencrypt.acme import messages2 +from acme import messages2 from letsencrypt.client import crypto_util from letsencrypt.client import errors @@ -28,7 +28,7 @@ class Account(object): :ivar str phone: Client's phone number :ivar regr: Registration Resource - :type regr: :class:`~letsencrypt.acme.messages2.RegistrationResource` + :type regr: :class:`~acme.messages2.RegistrationResource` """ diff --git a/letsencrypt/client/achallenges.py b/letsencrypt/client/achallenges.py index 1a5cf9c8e..a88b0dddb 100644 --- a/letsencrypt/client/achallenges.py +++ b/letsencrypt/client/achallenges.py @@ -1,11 +1,11 @@ """Client annotated ACME challenges. Please use names such as ``achall`` to distiguish from variables "of type" -:class:`letsencrypt.acme.challenges.Challenge` (denoted by ``chall``) +:class:`acme.challenges.Challenge` (denoted by ``chall``) and :class:`.ChallengeBody` (denoted by ``challb``):: - from letsencrypt.acme import challenges - from letsencrypt.acme import messages2 + from acme import challenges + from acme import messages2 from letsencrypt.client import achallenges chall = challenges.DNS(token='foo') @@ -17,8 +17,8 @@ Note, that all annotated challenges act as a proxy objects:: achall.token == challb.token """ -from letsencrypt.acme import challenges -from letsencrypt.acme.jose import util as jose_util +from acme import challenges +from acme.jose import util as jose_util from letsencrypt.client import crypto_util @@ -52,7 +52,7 @@ class DVSNI(AnnotatedChallenge): :returns: ``(cert_pem, response)`` tuple, where ``cert_pem`` is the PEM encoded certificate and ``response`` is an instance - :class:`letsencrypt.acme.challenges.DVSNIResponse`. + :class:`acme.challenges.DVSNIResponse`. :rtype: tuple """ diff --git a/letsencrypt/client/auth_handler.py b/letsencrypt/client/auth_handler.py index 0f2d76653..52e2df0c6 100644 --- a/letsencrypt/client/auth_handler.py +++ b/letsencrypt/client/auth_handler.py @@ -3,8 +3,8 @@ import itertools import logging import time -from letsencrypt.acme import challenges -from letsencrypt.acme import messages2 +from acme import challenges +from acme import messages2 from letsencrypt.client import achallenges from letsencrypt.client import constants @@ -15,11 +15,11 @@ class AuthHandler(object): """ACME Authorization Handler for a client. :ivar dv_auth: Authenticator capable of solving - :class:`~letsencrypt.acme.challenges.DVChallenge` types + :class:`~acme.challenges.DVChallenge` types :type dv_auth: :class:`letsencrypt.client.interfaces.IAuthenticator` :ivar cont_auth: Authenticator capable of solving - :class:`~letsencrypt.acme.challenges.ContinuityChallenge` types + :class:`~acme.challenges.ContinuityChallenge` types :type cont_auth: :class:`letsencrypt.client.interfaces.IAuthenticator` :ivar network: Network object for sending and receiving authorization @@ -30,7 +30,7 @@ class AuthHandler(object): :type account: :class:`letsencrypt.client.account.Account` :ivar dict authzr: ACME Authorization Resource dict where keys are domains - and values are :class:`letsencrypt.acme.messages2.AuthorizationResource` + and values are :class:`acme.messages2.AuthorizationResource` :ivar list dv_c: DV challenges in the form of :class:`letsencrypt.client.achallenges.AnnotatedChallenge` :ivar list cont_c: Continuity challenges in the @@ -219,7 +219,7 @@ class AuthHandler(object): each challenge resource. :param authzr: Authorization Resource - :type authzr: :class:`letsencrypt.acme.messages2.AuthorizationResource` + :type authzr: :class:`acme.messages2.AuthorizationResource` :param achall: Annotated challenge for which to get status :type achall: :class:`letsencrypt.client.achallenges.AnnotatedChallenge` @@ -319,7 +319,7 @@ def challb_to_achall(challb, key, domain): """Converts a ChallengeBody object to an AnnotatedChallenge. :param challb: ChallengeBody - :type challb: :class:`letsencrypt.acme.messages2.ChallengeBody` + :type challb: :class:`acme.messages2.ChallengeBody` :param key: Key :type key: :class:`letsencrypt.client.le_util.Key` @@ -368,16 +368,16 @@ def gen_challenge_path(challbs, preferences, combinations): .. todo:: This can be possibly be rewritten to use resolved_combinations. :param tuple challbs: A tuple of challenges - (:class:`letsencrypt.acme.messages2.Challenge`) from - :class:`letsencrypt.acme.messages2.AuthorizationResource` to be + (:class:`acme.messages2.Challenge`) from + :class:`acme.messages2.AuthorizationResource` to be fulfilled by the client in order to prove possession of the identifier. :param list preferences: List of challenge preferences for domain - (:class:`letsencrypt.acme.challenges.Challenge` subclasses) + (:class:`acme.challenges.Challenge` subclasses) :param tuple combinations: A collection of sets of challenges from - :class:`letsencrypt.acme.messages.Challenge`, each of which would + :class:`acme.messages.Challenge`, each of which would be sufficient to prove possession of the identifier. :returns: tuple of indices from ``challenges``. diff --git a/letsencrypt/client/client.py b/letsencrypt/client/client.py index 6622ea8de..b658df90e 100644 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client/client.py @@ -6,8 +6,8 @@ import pkg_resources import M2Crypto import zope.component -from letsencrypt.acme import jose -from letsencrypt.acme.jose import jwk +from acme import jose +from acme.jose import jwk from letsencrypt.client import account from letsencrypt.client import auth_handler @@ -148,7 +148,7 @@ class Client(object): """Saves the certificate received from the ACME server. :param certr: ACME "certificate" resource. - :type certr: :class:`letsencrypt.acme.messages.Certificate` + :type certr: :class:`acme.messages.Certificate` :param str cert_path: Path to attempt to save the cert file :param str chain_path: Path to attempt to save the chain file diff --git a/letsencrypt/client/constants.py b/letsencrypt/client/constants.py index 3f8cf4f05..513b76829 100644 --- a/letsencrypt/client/constants.py +++ b/letsencrypt/client/constants.py @@ -1,7 +1,7 @@ """Let's Encrypt constants.""" import logging -from letsencrypt.acme import challenges +from acme import challenges SETUPTOOLS_PLUGINS_ENTRY_POINT = "letsencrypt.plugins" diff --git a/letsencrypt/client/continuity_auth.py b/letsencrypt/client/continuity_auth.py index 063d3d408..4d75b43cf 100644 --- a/letsencrypt/client/continuity_auth.py +++ b/letsencrypt/client/continuity_auth.py @@ -1,7 +1,7 @@ """Continuity Authenticator""" import zope.interface -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import errors @@ -11,7 +11,7 @@ from letsencrypt.client import recovery_token class ContinuityAuthenticator(object): """IAuthenticator for - :const:`~letsencrypt.acme.challenges.ContinuityChallenge` class challenges. + :const:`~acme.challenges.ContinuityChallenge` class challenges. :ivar rec_token: Performs "recoveryToken" challenges :type rec_token: :class:`letsencrypt.client.recovery_token.RecoveryToken` diff --git a/letsencrypt/client/interfaces.py b/letsencrypt/client/interfaces.py index b005eb02d..e28264759 100644 --- a/letsencrypt/client/interfaces.py +++ b/letsencrypt/client/interfaces.py @@ -100,7 +100,7 @@ class IAuthenticator(IPlugin): :param str domain: Domain for which challenge preferences are sought. :returns: List of challege types (subclasses of - :class:`letsencrypt.acme.challenges.Challenge`) with the most + :class:`acme.challenges.Challenge`) with the most preferred challenges first. If a type is not specified, it means the Authenticator cannot perform the challenge. :rtype: list @@ -116,8 +116,8 @@ class IAuthenticator(IPlugin): :func:`get_chall_pref` only. :returns: List of ACME - :class:`~letsencrypt.acme.challenges.ChallengeResponse` instances - or if the :class:`~letsencrypt.acme.challenges.Challenge` cannot + :class:`~acme.challenges.ChallengeResponse` instances + or if the :class:`~acme.challenges.Challenge` cannot be fulfilled then: ``None`` @@ -126,7 +126,7 @@ class IAuthenticator(IPlugin): Authenticator will never be able to perform (error). :rtype: :class:`list` of - :class:`letsencrypt.acme.challenges.ChallengeResponse` + :class:`acme.challenges.ChallengeResponse` """ diff --git a/letsencrypt/client/network.py b/letsencrypt/client/network.py index 2719583c3..81a3fccdc 100644 --- a/letsencrypt/client/network.py +++ b/letsencrypt/client/network.py @@ -5,8 +5,8 @@ import time import requests -from letsencrypt.acme import jose -from letsencrypt.acme import messages +from acme import jose +from acme import messages from letsencrypt.client import errors @@ -35,12 +35,12 @@ class Network(object): """Send ACME message to server. :param msg: ACME message. - :type msg: :class:`letsencrypt.acme.messages.Message` + :type msg: :class:`acme.messages.Message` :returns: Server response message. - :rtype: :class:`letsencrypt.acme.messages.Message` + :rtype: :class:`acme.messages.Message` - :raises letsencrypt.acme.errors.ValidationError: if `msg` is not + :raises acme.errors.ValidationError: if `msg` is not valid serializable ACME JSON message. :raises errors.LetsEncryptClientError: in case of connection error or if response from server is not a valid ACME message. @@ -68,10 +68,10 @@ class Network(object): """Send ACME message to server and return expected message. :param msg: ACME message. - :type msg: :class:`letsencrypt.acme.Message` + :type msg: :class:`acme.Message` :returns: ACME response message of expected type. - :rtype: :class:`letsencrypt.acme.messages.Message` + :rtype: :class:`acme.messages.Message` :raises errors.LetsEncryptClientError: An exception is thrown @@ -84,10 +84,10 @@ class Network(object): """Is response expected ACME message? :param response: ACME response message from server. - :type response: :class:`letsencrypt.acme.messages.Message` + :type response: :class:`acme.messages.Message` :param expected: Expected response type. - :type expected: subclass of :class:`letsencrypt.acme.messages.Message` + :type expected: subclass of :class:`acme.messages.Message` :param int delay: Number of seconds to delay before next round in case of ACME "defer" response message. @@ -95,7 +95,7 @@ class Network(object): response message. :returns: ACME response message from server. - :rtype: :class:`letsencrypt.acme.messages.Message` + :rtype: :class:`acme.messages.Message` :raises LetsEncryptClientError: if server sent ACME "error" message diff --git a/letsencrypt/client/network2.py b/letsencrypt/client/network2.py index eaa485a8d..2b85ebd3c 100644 --- a/letsencrypt/client/network2.py +++ b/letsencrypt/client/network2.py @@ -9,8 +9,8 @@ import M2Crypto import requests import werkzeug -from letsencrypt.acme import jose -from letsencrypt.acme import messages2 +from acme import jose +from acme import messages2 from letsencrypt.client import errors @@ -127,7 +127,7 @@ class Network(object): :param str content_type: Expected ``Content-Type``, fails if not set. - :raises letsencrypt.acme.messages2.NetworkError: + :raises acme.messages2.NetworkError: :returns: HTTP Response :rtype: `requests.Response` @@ -467,7 +467,7 @@ class Network(object): :param str uri: URI of certificate :returns: tuple of the form - (response, :class:`letsencrypt.acme.jose.ComparableX509`) + (response, :class:`acme.jose.ComparableX509`) :rtype: tuple """ diff --git a/letsencrypt/client/plugins/apache/configurator.py b/letsencrypt/client/plugins/apache/configurator.py index 82d6f323c..7006e7d2f 100644 --- a/letsencrypt/client/plugins/apache/configurator.py +++ b/letsencrypt/client/plugins/apache/configurator.py @@ -9,7 +9,7 @@ import sys import zope.interface -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import augeas_configurator diff --git a/letsencrypt/client/plugins/apache/tests/configurator_test.py b/letsencrypt/client/plugins/apache/tests/configurator_test.py index ae2097b3e..b4881d63b 100644 --- a/letsencrypt/client/plugins/apache/tests/configurator_test.py +++ b/letsencrypt/client/plugins/apache/tests/configurator_test.py @@ -6,7 +6,7 @@ import unittest import mock -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import errors diff --git a/letsencrypt/client/plugins/apache/tests/dvsni_test.py b/letsencrypt/client/plugins/apache/tests/dvsni_test.py index 2780749b5..9694ce69b 100644 --- a/letsencrypt/client/plugins/apache/tests/dvsni_test.py +++ b/letsencrypt/client/plugins/apache/tests/dvsni_test.py @@ -5,7 +5,7 @@ import shutil import mock -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import le_util @@ -34,9 +34,9 @@ class DvsniPerformTest(util.ApacheTest): self.sni = dvsni.ApacheDvsni(config) rsa256_file = pkg_resources.resource_filename( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") rsa256_pem = pkg_resources.resource_string( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") auth_key = le_util.Key(rsa256_file, rsa256_pem) self.achalls = [ diff --git a/letsencrypt/client/plugins/apache/tests/util.py b/letsencrypt/client/plugins/apache/tests/util.py index 618b0975a..98c06af40 100644 --- a/letsencrypt/client/plugins/apache/tests/util.py +++ b/letsencrypt/client/plugins/apache/tests/util.py @@ -26,9 +26,9 @@ class ApacheTest(unittest.TestCase): # pylint: disable=too-few-public-methods self.temp_dir, "debian_apache_2_4/two_vhost_80/apache2") self.rsa256_file = pkg_resources.resource_filename( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") self.rsa256_pem = pkg_resources.resource_string( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") def dir_setup(test_dir="debian_apache_2_4/two_vhost_80"): diff --git a/letsencrypt/client/plugins/common.py b/letsencrypt/client/plugins/common.py index 60b868c37..08e9cf658 100644 --- a/letsencrypt/client/plugins/common.py +++ b/letsencrypt/client/plugins/common.py @@ -1,7 +1,7 @@ """Plugin common functions.""" import zope.interface -from letsencrypt.acme.jose import util as jose_util +from acme.jose import util as jose_util from letsencrypt.client import interfaces diff --git a/letsencrypt/client/plugins/nginx/configurator.py b/letsencrypt/client/plugins/nginx/configurator.py index 49d5a6dd0..f7e64ebdb 100644 --- a/letsencrypt/client/plugins/nginx/configurator.py +++ b/letsencrypt/client/plugins/nginx/configurator.py @@ -9,7 +9,7 @@ import sys import zope.interface -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import constants as core_constants diff --git a/letsencrypt/client/plugins/nginx/tests/configurator_test.py b/letsencrypt/client/plugins/nginx/tests/configurator_test.py index cb5fef6bf..7be3177e3 100644 --- a/letsencrypt/client/plugins/nginx/tests/configurator_test.py +++ b/letsencrypt/client/plugins/nginx/tests/configurator_test.py @@ -4,8 +4,8 @@ import unittest import mock -from letsencrypt.acme import challenges -from letsencrypt.acme import messages2 +from acme import challenges +from acme import messages2 from letsencrypt.client import achallenges from letsencrypt.client import errors diff --git a/letsencrypt/client/plugins/nginx/tests/dvsni_test.py b/letsencrypt/client/plugins/nginx/tests/dvsni_test.py index bf66367e6..24e32bafe 100644 --- a/letsencrypt/client/plugins/nginx/tests/dvsni_test.py +++ b/letsencrypt/client/plugins/nginx/tests/dvsni_test.py @@ -5,8 +5,8 @@ import shutil import mock -from letsencrypt.acme import challenges -from letsencrypt.acme import messages2 +from acme import challenges +from acme import messages2 from letsencrypt.client import achallenges from letsencrypt.client import le_util @@ -25,9 +25,9 @@ class DvsniPerformTest(util.NginxTest): self.ssl_options) rsa256_file = pkg_resources.resource_filename( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") rsa256_pem = pkg_resources.resource_string( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") auth_key = le_util.Key(rsa256_file, rsa256_pem) diff --git a/letsencrypt/client/plugins/nginx/tests/util.py b/letsencrypt/client/plugins/nginx/tests/util.py index a1630b61f..47577daa1 100644 --- a/letsencrypt/client/plugins/nginx/tests/util.py +++ b/letsencrypt/client/plugins/nginx/tests/util.py @@ -25,9 +25,9 @@ class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods self.temp_dir, "testdata") self.rsa256_file = pkg_resources.resource_filename( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") self.rsa256_pem = pkg_resources.resource_string( - "letsencrypt.acme.jose", "testdata/rsa256_key.pem") + "acme.jose", "testdata/rsa256_key.pem") def get_data_filename(filename): diff --git a/letsencrypt/client/plugins/standalone/authenticator.py b/letsencrypt/client/plugins/standalone/authenticator.py index a10ffd32d..dc8b7eac7 100644 --- a/letsencrypt/client/plugins/standalone/authenticator.py +++ b/letsencrypt/client/plugins/standalone/authenticator.py @@ -12,7 +12,7 @@ import OpenSSL.SSL import zope.component import zope.interface -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import interfaces diff --git a/letsencrypt/client/plugins/standalone/tests/authenticator_test.py b/letsencrypt/client/plugins/standalone/tests/authenticator_test.py index 288a04fcc..230756e1d 100644 --- a/letsencrypt/client/plugins/standalone/tests/authenticator_test.py +++ b/letsencrypt/client/plugins/standalone/tests/authenticator_test.py @@ -10,7 +10,7 @@ import mock import OpenSSL.crypto import OpenSSL.SSL -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import le_util @@ -19,7 +19,7 @@ from letsencrypt.client.tests import acme_util KEY = le_util.Key("foo", pkg_resources.resource_string( - "letsencrypt.acme.jose", os.path.join("testdata", "rsa512_key.pem"))) + "acme.jose", os.path.join("testdata", "rsa512_key.pem"))) PRIVATE_KEY = OpenSSL.crypto.load_privatekey( OpenSSL.crypto.FILETYPE_PEM, KEY.pem) diff --git a/letsencrypt/client/recovery_token.py b/letsencrypt/client/recovery_token.py index f0c7d5839..3be0471ab 100644 --- a/letsencrypt/client/recovery_token.py +++ b/letsencrypt/client/recovery_token.py @@ -4,7 +4,7 @@ import os import zope.component -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import le_util from letsencrypt.client import interfaces diff --git a/letsencrypt/client/revoker.py b/letsencrypt/client/revoker.py index c18b5ffa6..31f2d85ce 100644 --- a/letsencrypt/client/revoker.py +++ b/letsencrypt/client/revoker.py @@ -16,8 +16,8 @@ import tempfile import Crypto.PublicKey.RSA import M2Crypto -from letsencrypt.acme import messages -from letsencrypt.acme.jose import util as jose_util +from acme import messages +from acme.jose import util as jose_util from letsencrypt.client import errors from letsencrypt.client import le_util diff --git a/letsencrypt/client/tests/account_test.py b/letsencrypt/client/tests/account_test.py index 6a79a94c7..c99edc8ee 100644 --- a/letsencrypt/client/tests/account_test.py +++ b/letsencrypt/client/tests/account_test.py @@ -7,7 +7,7 @@ import shutil import tempfile import unittest -from letsencrypt.acme import messages2 +from acme import messages2 from letsencrypt.client import configuration from letsencrypt.client import errors @@ -34,9 +34,9 @@ class AccountTest(unittest.TestCase): server="letsencrypt-demo.org") key_file = pkg_resources.resource_filename( - "letsencrypt.acme.jose", os.path.join("testdata", "rsa512_key.pem")) + "acme.jose", os.path.join("testdata", "rsa512_key.pem")) key_pem = pkg_resources.resource_string( - "letsencrypt.acme.jose", os.path.join("testdata", "rsa512_key.pem")) + "acme.jose", os.path.join("testdata", "rsa512_key.pem")) self.key = le_util.Key(key_file, key_pem) self.email = "client@letsencrypt.org" diff --git a/letsencrypt/client/tests/achallenges_test.py b/letsencrypt/client/tests/achallenges_test.py index 72c610f31..476ff7cab 100644 --- a/letsencrypt/client/tests/achallenges_test.py +++ b/letsencrypt/client/tests/achallenges_test.py @@ -6,7 +6,7 @@ import unittest import M2Crypto -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import le_util from letsencrypt.client.tests import acme_util @@ -19,8 +19,7 @@ class DVSNITest(unittest.TestCase): challenges.DVSNI(r="r_value", nonce="12345ABCDE"), "pending") self.response = challenges.DVSNIResponse() key = le_util.Key("path", pkg_resources.resource_string( - "letsencrypt.acme.jose", - os.path.join("testdata", "rsa512_key.pem"))) + "acme.jose", os.path.join("testdata", "rsa512_key.pem"))) from letsencrypt.client.achallenges import DVSNI self.achall = DVSNI(challb=self.chall, domain="example.com", key=key) diff --git a/letsencrypt/client/tests/acme_util.py b/letsencrypt/client/tests/acme_util.py index 0036844e0..93cc35e47 100644 --- a/letsencrypt/client/tests/acme_util.py +++ b/letsencrypt/client/tests/acme_util.py @@ -6,14 +6,14 @@ import pkg_resources import Crypto.PublicKey.RSA -from letsencrypt.acme import challenges -from letsencrypt.acme import jose -from letsencrypt.acme import messages2 +from acme import challenges +from acme import jose +from acme import messages2 KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( - "letsencrypt.acme.jose", os.path.join("testdata", "rsa512_key.pem")))) + "acme.jose", os.path.join("testdata", "rsa512_key.pem")))) # Challenges SIMPLE_HTTPS = challenges.SimpleHTTPS( @@ -106,7 +106,7 @@ def gen_authzr(authz_status, domain, challs, statuses, combos=True): """Generate an authorization resource. :param authz_status: Status object - :type authz_status: :class:`letsencrypt.acme.messages2.Status` + :type authz_status: :class:`acme.messages2.Status` :param list challs: Challenge objects :param list statuses: status of each challenge object :param bool combos: Whether or not to add combinations diff --git a/letsencrypt/client/tests/auth_handler_test.py b/letsencrypt/client/tests/auth_handler_test.py index c6e3b6153..b03f25735 100644 --- a/letsencrypt/client/tests/auth_handler_test.py +++ b/letsencrypt/client/tests/auth_handler_test.py @@ -5,8 +5,8 @@ import unittest import mock -from letsencrypt.acme import challenges -from letsencrypt.acme import messages2 +from acme import challenges +from acme import messages2 from letsencrypt.client import errors from letsencrypt.client import le_util @@ -447,9 +447,9 @@ def gen_path(required, challs): """Generate a combination by picking ``required`` from ``challs``. :param required: Required types of challenges (subclasses of - :class:`~letsencrypt.acme.challenges.Challenge`). + :class:`~acme.challenges.Challenge`). :param challs: Sequence of ACME challenge messages, corresponding to - :attr:`letsencrypt.acme.messages.Challenge.challenges`. + :attr:`acme.messages.Challenge.challenges`. :return: :class:`list` of :class:`int` diff --git a/letsencrypt/client/tests/continuity_auth_test.py b/letsencrypt/client/tests/continuity_auth_test.py index 7a2279bcd..b8b5e7402 100644 --- a/letsencrypt/client/tests/continuity_auth_test.py +++ b/letsencrypt/client/tests/continuity_auth_test.py @@ -3,7 +3,7 @@ import unittest import mock -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges from letsencrypt.client import errors diff --git a/letsencrypt/client/tests/crypto_util_test.py b/letsencrypt/client/tests/crypto_util_test.py index a36b96c99..f0c234598 100644 --- a/letsencrypt/client/tests/crypto_util_test.py +++ b/letsencrypt/client/tests/crypto_util_test.py @@ -11,9 +11,9 @@ import mock RSA256_KEY = pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa256_key.pem')) + 'acme.jose', os.path.join('testdata', 'rsa256_key.pem')) RSA512_KEY = pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem')) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')) class InitSaveKeyTest(unittest.TestCase): diff --git a/letsencrypt/client/tests/network2_test.py b/letsencrypt/client/tests/network2_test.py index d14d27f6a..1a5f7fd27 100644 --- a/letsencrypt/client/tests/network2_test.py +++ b/letsencrypt/client/tests/network2_test.py @@ -9,9 +9,9 @@ import M2Crypto import mock import requests -from letsencrypt.acme import challenges -from letsencrypt.acme import jose -from letsencrypt.acme import messages2 +from acme import challenges +from acme import jose +from acme import messages2 from letsencrypt.client import account from letsencrypt.client import errors @@ -27,9 +27,9 @@ CSR = jose.ComparableX509(M2Crypto.X509.load_request_string( pkg_resources.resource_string( __name__, os.path.join('testdata', 'csr.pem')))) KEY = jose.JWKRSA.load(pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem'))) + 'acme.jose', os.path.join('testdata', 'rsa512_key.pem'))) KEY2 = jose.JWKRSA.load(pkg_resources.resource_string( - 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa256_key.pem'))) + 'acme.jose', os.path.join('testdata', 'rsa256_key.pem'))) class NetworkTest(unittest.TestCase): diff --git a/letsencrypt/client/tests/recovery_token_test.py b/letsencrypt/client/tests/recovery_token_test.py index 0de31a8d0..c0d692c8c 100644 --- a/letsencrypt/client/tests/recovery_token_test.py +++ b/letsencrypt/client/tests/recovery_token_test.py @@ -6,7 +6,7 @@ import tempfile import mock -from letsencrypt.acme import challenges +from acme import challenges from letsencrypt.client import achallenges diff --git a/letsencrypt/client/tests/revoker_test.py b/letsencrypt/client/tests/revoker_test.py index 1ceb8ae9a..75510cc75 100644 --- a/letsencrypt/client/tests/revoker_test.py +++ b/letsencrypt/client/tests/revoker_test.py @@ -99,8 +99,7 @@ class RevokerTest(RevokerBase): mock_display().confirm_revocation.return_value = True key_path = pkg_resources.resource_filename( - "letsencrypt.acme.jose", os.path.join( - "testdata", "rsa256_key.pem")) + "acme.jose", os.path.join("testdata", "rsa256_key.pem")) wrong_key = le_util.Key(key_path, open(key_path).read()) self.revoker.revoke_from_key(wrong_key) diff --git a/setup.cfg b/setup.cfg index 75b1ef1a8..a9fa682f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,5 +6,5 @@ dev = develop easy_install letsencrypt[dev,docs,testing] [nosetests] nocapture=1 -cover-package=letsencrypt +cover-package=letsencrypt,acme cover-erase=1 diff --git a/setup.py b/setup.py index 0302f1435..9256f48ff 100644 --- a/setup.py +++ b/setup.py @@ -107,7 +107,7 @@ setup( }, tests_require=install_requires, - test_suite='letsencrypt', + test_suite='letsencrypt', # TODO: test acme (this is run by tox.ini) entry_points={ 'console_scripts': [ diff --git a/tox.ini b/tox.ini index cd6f3c7b0..5c869d289 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ envlist = py26,py27,cover,lint commands = pip install -r requirements.txt -e .[testing] python setup.py test -q # -q does not suppress errors + # TODO: test_suite is set to letsencrypt only setenv = PYTHONPATH = {toxinidir} @@ -26,4 +27,4 @@ commands = basepython = python2.7 commands = pip install -e .[dev] - pylint --rcfile=.pylintrc letsencrypt + pylint --rcfile=.pylintrc letsencrypt acme