From 41e86df252109c59023e65179e7c73a727a18d9a Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Sun, 10 May 2015 12:25:29 +0000 Subject: [PATCH] Move letsencrypt.client to letsencrypt --- acme/challenges_test.py | 2 +- acme/jose/json_util_test.py | 4 +- acme/jose/jws_test.py | 2 +- acme/jose/testdata/README | 4 +- acme/messages_test.py | 4 +- docs/api/account.rst | 5 + docs/api/achallenges.rst | 5 + docs/api/augeas_configurator.rst | 5 + docs/api/auth_handler.rst | 5 + docs/api/{client/index.rst => client.rst} | 0 docs/api/client/account.rst | 5 - docs/api/client/achallenges.rst | 5 - docs/api/client/augeas_configurator.rst | 5 - docs/api/client/auth_handler.rst | 5 - docs/api/client/client.rst | 5 - docs/api/client/configuration.rst | 5 - docs/api/client/constants.rst | 5 - docs/api/client/continuity_auth.rst | 5 - docs/api/client/crypto_util.rst | 5 - docs/api/client/display.rst | 29 ---- docs/api/client/errors.rst | 5 - docs/api/client/interfaces.rst | 5 - docs/api/client/le_util.rst | 5 - docs/api/client/log.rst | 5 - docs/api/client/network.rst | 5 - docs/api/client/network2.rst | 5 - docs/api/client/recovery_token.rst | 5 - docs/api/client/reverter.rst | 5 - docs/api/client/revoker.rst | 5 - docs/api/configuration.rst | 5 + docs/api/constants.rst | 5 + docs/api/continuity_auth.rst | 5 + docs/api/crypto_util.rst | 5 + docs/api/display.rst | 29 ++++ docs/api/errors.rst | 5 + docs/api/index.rst | 5 + docs/api/interfaces.rst | 5 + docs/api/le_util.rst | 5 + docs/api/log.rst | 5 + docs/api/network.rst | 5 + docs/api/network2.rst | 5 + docs/api/plugins/common.rst | 6 +- docs/api/plugins/disco.rst | 6 +- docs/api/plugins/standalone.rst | 12 +- docs/api/recovery_token.rst | 5 + docs/api/reverter.rst | 5 + docs/api/revoker.rst | 5 + docs/contributing.rst | 16 +-- docs/plugins.rst | 4 +- .../plugins/letsencrypt_example_plugins.py | 6 +- examples/restified.py | 4 +- letsencrypt/{client => }/.gitignore | 0 letsencrypt/__init__.py | 3 +- letsencrypt/{client => }/account.py | 24 ++-- letsencrypt/{client => }/achallenges.py | 4 +- .../{client => }/augeas_configurator.py | 8 +- letsencrypt/{client => }/auth_handler.py | 30 ++--- letsencrypt/{client => }/cli.py | 22 ++-- letsencrypt/{client => }/client.py | 64 ++++----- letsencrypt/client/__init__.py | 1 - letsencrypt/client/display/__init__.py | 1 - .../client/plugins/standalone/__init__.py | 1 - letsencrypt/{client => }/configuration.py | 10 +- letsencrypt/{client => }/constants.py | 2 +- letsencrypt/{client => }/continuity_auth.py | 12 +- letsencrypt/{client => }/crypto_util.py | 8 +- letsencrypt/display/__init__.py | 1 + .../{client => }/display/enhancements.py | 10 +- letsencrypt/{client => }/display/ops.py | 12 +- .../{client => }/display/revocation.py | 8 +- letsencrypt/{client => }/display/util.py | 2 +- letsencrypt/{client => }/errors.py | 0 letsencrypt/{client => }/interfaces.py | 14 +- letsencrypt/{client => }/le_util.py | 2 +- letsencrypt/{client => }/log.py | 2 +- letsencrypt/{client => }/network.py | 2 +- letsencrypt/{client => }/network2.py | 12 +- letsencrypt/{client => }/plugins/__init__.py | 0 letsencrypt/{client => }/plugins/common.py | 2 +- .../{client => }/plugins/common_test.py | 12 +- letsencrypt/{client => }/plugins/disco.py | 6 +- .../{client => }/plugins/disco_test.py | 27 ++-- letsencrypt/plugins/standalone/__init__.py | 1 + .../plugins/standalone/authenticator.py | 10 +- .../plugins/standalone/tests/__init__.py | 0 .../standalone/tests/authenticator_test.py | 124 ++++++++---------- letsencrypt/{client => }/recovery_token.py | 8 +- letsencrypt/{client => }/reverter.py | 28 ++-- letsencrypt/{client => }/revoker.py | 30 ++--- letsencrypt/{client => }/tests/__init__.py | 0 .../{client => }/tests/account_test.py | 52 ++++---- .../{client => }/tests/achallenges_test.py | 10 +- letsencrypt/{client => }/tests/acme_util.py | 0 .../{client => }/tests/auth_handler_test.py | 44 +++---- letsencrypt/{client => }/tests/cli_test.py | 8 +- letsencrypt/{client => }/tests/client_test.py | 38 +++--- .../{client => }/tests/configuration_test.py | 8 +- .../tests/continuity_auth_test.py | 8 +- .../{client => }/tests/crypto_util_test.py | 38 +++--- .../{client => }/tests/display/__init__.py | 0 .../tests/display/enhancements_test.py | 16 +-- .../{client => }/tests/display/ops_test.py | 70 +++++----- .../tests/display/revocation_test.py | 34 ++--- .../{client => }/tests/display/util_test.py | 34 ++--- .../{client => }/tests/le_util_test.py | 12 +- letsencrypt/{client => }/tests/log_test.py | 4 +- .../{client => }/tests/network2_test.py | 28 ++-- .../{client => }/tests/recovery_token_test.py | 6 +- .../{client => }/tests/reverter_test.py | 36 +++-- .../{client => }/tests/revoker_test.py | 76 +++++------ .../{client => }/tests/testdata/cert-san.pem | 0 .../{client => }/tests/testdata/cert.b64jose | 0 .../{client => }/tests/testdata/cert.pem | 0 .../{client => }/tests/testdata/csr-san.der | Bin .../{client => }/tests/testdata/csr-san.pem | 0 .../{client => }/tests/testdata/csr.der | Bin .../{client => }/tests/testdata/csr.pem | 0 .../tests/testdata/rsa512_key.pem | 0 letsencrypt_apache/configurator.py | 18 +-- letsencrypt_apache/dvsni.py | 10 +- letsencrypt_apache/parser.py | 2 +- letsencrypt_apache/tests/configurator_test.py | 8 +- letsencrypt_apache/tests/dvsni_test.py | 6 +- letsencrypt_apache/tests/parser_test.py | 4 +- letsencrypt_nginx/configurator.py | 22 ++-- letsencrypt_nginx/dvsni.py | 2 +- letsencrypt_nginx/parser.py | 2 +- letsencrypt_nginx/tests/configurator_test.py | 6 +- letsencrypt_nginx/tests/dvsni_test.py | 4 +- letsencrypt_nginx/tests/parser_test.py | 2 +- letsencrypt_nginx/tests/util.py | 2 +- setup.py | 4 +- 132 files changed, 697 insertions(+), 728 deletions(-) create mode 100644 docs/api/account.rst create mode 100644 docs/api/achallenges.rst create mode 100644 docs/api/augeas_configurator.rst create mode 100644 docs/api/auth_handler.rst rename docs/api/{client/index.rst => client.rst} (100%) delete mode 100644 docs/api/client/account.rst delete mode 100644 docs/api/client/achallenges.rst delete mode 100644 docs/api/client/augeas_configurator.rst delete mode 100644 docs/api/client/auth_handler.rst delete mode 100644 docs/api/client/client.rst delete mode 100644 docs/api/client/configuration.rst delete mode 100644 docs/api/client/constants.rst delete mode 100644 docs/api/client/continuity_auth.rst delete mode 100644 docs/api/client/crypto_util.rst delete mode 100644 docs/api/client/display.rst delete mode 100644 docs/api/client/errors.rst delete mode 100644 docs/api/client/interfaces.rst delete mode 100644 docs/api/client/le_util.rst delete mode 100644 docs/api/client/log.rst delete mode 100644 docs/api/client/network.rst delete mode 100644 docs/api/client/network2.rst delete mode 100644 docs/api/client/recovery_token.rst delete mode 100644 docs/api/client/reverter.rst delete mode 100644 docs/api/client/revoker.rst create mode 100644 docs/api/configuration.rst create mode 100644 docs/api/constants.rst create mode 100644 docs/api/continuity_auth.rst create mode 100644 docs/api/crypto_util.rst create mode 100644 docs/api/display.rst create mode 100644 docs/api/errors.rst create mode 100644 docs/api/index.rst create mode 100644 docs/api/interfaces.rst create mode 100644 docs/api/le_util.rst create mode 100644 docs/api/log.rst create mode 100644 docs/api/network.rst create mode 100644 docs/api/network2.rst create mode 100644 docs/api/recovery_token.rst create mode 100644 docs/api/reverter.rst create mode 100644 docs/api/revoker.rst rename letsencrypt/{client => }/.gitignore (100%) rename letsencrypt/{client => }/account.py (90%) rename letsencrypt/{client => }/achallenges.py (96%) rename letsencrypt/{client => }/augeas_configurator.py (96%) rename letsencrypt/{client => }/auth_handler.py (94%) rename letsencrypt/{client => }/cli.py (96%) rename letsencrypt/{client => }/client.py (86%) delete mode 100644 letsencrypt/client/__init__.py delete mode 100644 letsencrypt/client/display/__init__.py delete mode 100644 letsencrypt/client/plugins/standalone/__init__.py rename letsencrypt/{client => }/configuration.py (89%) rename letsencrypt/{client => }/constants.py (96%) rename letsencrypt/{client => }/continuity_auth.py (82%) rename letsencrypt/{client => }/crypto_util.py (96%) create mode 100644 letsencrypt/display/__init__.py rename letsencrypt/{client => }/display/enhancements.py (83%) rename letsencrypt/{client => }/display/ops.py (94%) rename letsencrypt/{client => }/display/revocation.py (89%) rename letsencrypt/{client => }/display/util.py (99%) rename letsencrypt/{client => }/errors.py (100%) rename letsencrypt/{client => }/interfaces.py (95%) rename letsencrypt/{client => }/le_util.py (98%) rename letsencrypt/{client => }/log.py (97%) rename letsencrypt/{client => }/network.py (99%) rename letsencrypt/{client => }/network2.py (98%) rename letsencrypt/{client => }/plugins/__init__.py (100%) rename letsencrypt/{client => }/plugins/common.py (98%) rename letsencrypt/{client => }/plugins/common_test.py (81%) rename letsencrypt/{client => }/plugins/disco.py (98%) rename letsencrypt/{client => }/plugins/disco_test.py (91%) create mode 100644 letsencrypt/plugins/standalone/__init__.py rename letsencrypt/{client => }/plugins/standalone/authenticator.py (98%) rename letsencrypt/{client => }/plugins/standalone/tests/__init__.py (100%) rename letsencrypt/{client => }/plugins/standalone/tests/authenticator_test.py (84%) rename letsencrypt/{client => }/recovery_token.py (89%) rename letsencrypt/{client => }/reverter.py (95%) rename letsencrypt/{client => }/revoker.py (95%) rename letsencrypt/{client => }/tests/__init__.py (100%) rename letsencrypt/{client => }/tests/account_test.py (80%) rename letsencrypt/{client => }/tests/achallenges_test.py (83%) rename letsencrypt/{client => }/tests/acme_util.py (100%) rename letsencrypt/{client => }/tests/auth_handler_test.py (92%) rename letsencrypt/{client => }/tests/cli_test.py (77%) rename letsencrypt/{client => }/tests/client_test.py (66%) rename letsencrypt/{client => }/tests/configuration_test.py (86%) rename letsencrypt/{client => }/tests/continuity_auth_test.py (91%) rename letsencrypt/{client => }/tests/crypto_util_test.py (75%) rename letsencrypt/{client => }/tests/display/__init__.py (100%) rename letsencrypt/{client => }/tests/display/enhancements_test.py (71%) rename letsencrypt/{client => }/tests/display/ops_test.py (81%) rename letsencrypt/{client => }/tests/display/revocation_test.py (68%) rename letsencrypt/{client => }/tests/display/util_test.py (91%) rename letsencrypt/{client => }/tests/le_util_test.py (90%) rename letsencrypt/{client => }/tests/log_test.py (94%) rename letsencrypt/{client => }/tests/network2_test.py (96%) rename letsencrypt/{client => }/tests/recovery_token_test.py (93%) rename letsencrypt/{client => }/tests/reverter_test.py (93%) rename letsencrypt/{client => }/tests/revoker_test.py (84%) rename letsencrypt/{client => }/tests/testdata/cert-san.pem (100%) rename letsencrypt/{client => }/tests/testdata/cert.b64jose (100%) rename letsencrypt/{client => }/tests/testdata/cert.pem (100%) rename letsencrypt/{client => }/tests/testdata/csr-san.der (100%) rename letsencrypt/{client => }/tests/testdata/csr-san.pem (100%) rename letsencrypt/{client => }/tests/testdata/csr.der (100%) rename letsencrypt/{client => }/tests/testdata/csr.pem (100%) rename letsencrypt/{client => }/tests/testdata/rsa512_key.pem (100%) diff --git a/acme/challenges_test.py b/acme/challenges_test.py index c2c8bdfea..ab5ddd9aa 100644 --- a/acme/challenges_test.py +++ b/acme/challenges_test.py @@ -12,7 +12,7 @@ from acme import other CERT = jose.ComparableX509(M2Crypto.X509.load_cert( pkg_resources.resource_filename( - 'letsencrypt.client.tests', os.path.join('testdata', 'cert.pem')))) + 'letsencrypt.tests', os.path.join('testdata', 'cert.pem')))) KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( pkg_resources.resource_string( 'acme.jose', os.path.join('testdata', 'rsa512_key.pem')))) diff --git a/acme/jose/json_util_test.py b/acme/jose/json_util_test.py index 42113279e..eed72d57f 100644 --- a/acme/jose/json_util_test.py +++ b/acme/jose/json_util_test.py @@ -12,9 +12,9 @@ from acme.jose import util CERT = M2Crypto.X509.load_cert(pkg_resources.resource_filename( - 'letsencrypt.client.tests', os.path.join('testdata', 'cert.pem'))) + 'letsencrypt.tests', os.path.join('testdata', 'cert.pem'))) CSR = M2Crypto.X509.load_request(pkg_resources.resource_filename( - 'letsencrypt.client.tests', os.path.join('testdata', 'csr.pem'))) + 'letsencrypt.tests', os.path.join('testdata', 'csr.pem'))) class FieldTest(unittest.TestCase): diff --git a/acme/jose/jws_test.py b/acme/jose/jws_test.py index 736391e4c..d15d113b7 100644 --- a/acme/jose/jws_test.py +++ b/acme/jose/jws_test.py @@ -17,7 +17,7 @@ from acme.jose import util CERT = util.ComparableX509(M2Crypto.X509.load_cert( pkg_resources.resource_filename( - 'letsencrypt.client.tests', 'testdata/cert.pem'))) + 'letsencrypt.tests', 'testdata/cert.pem'))) RSA512_KEY = Crypto.PublicKey.RSA.importKey(pkg_resources.resource_string( __name__, os.path.join('testdata', 'rsa512_key.pem'))) diff --git a/acme/jose/testdata/README b/acme/jose/testdata/README index 4b37ae921..72ec557e0 100644 --- a/acme/jose/testdata/README +++ b/acme/jose/testdata/README @@ -4,7 +4,7 @@ The following command has been used to generate test keys: and for the CSR: - python -c from 'letsencrypt.client.crypto_util import make_csr; + python -c from 'letsencrypt.crypto_util import make_csr; import pkg_resources; open("csr2.pem", - "w").write(make_csr(pkg_resources.resource_string("letsencrypt.client.tests", + "w").write(make_csr(pkg_resources.resource_string("letsencrypt.tests", "testdata/rsa512_key.pem"), ["example2.com"])[0])' diff --git a/acme/messages_test.py b/acme/messages_test.py index 1acb0e838..662de3f1c 100644 --- a/acme/messages_test.py +++ b/acme/messages_test.py @@ -17,10 +17,10 @@ KEY = jose.HashableRSAKey(Crypto.PublicKey.RSA.importKey( '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')))) + 'letsencrypt.tests', os.path.join('testdata', 'cert.pem')))) CSR = jose.ComparableX509(M2Crypto.X509.load_request( pkg_resources.resource_filename( - 'letsencrypt.client.tests', os.path.join('testdata', 'csr.pem')))) + 'letsencrypt.tests', os.path.join('testdata', 'csr.pem')))) CSR2 = jose.ComparableX509(M2Crypto.X509.load_request( pkg_resources.resource_filename( 'acme.jose', os.path.join('testdata', 'csr2.pem')))) diff --git a/docs/api/account.rst b/docs/api/account.rst new file mode 100644 index 000000000..16c2061a8 --- /dev/null +++ b/docs/api/account.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.account` +-------------------------- + +.. automodule:: letsencrypt.account + :members: diff --git a/docs/api/achallenges.rst b/docs/api/achallenges.rst new file mode 100644 index 000000000..09cec1702 --- /dev/null +++ b/docs/api/achallenges.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.achallenges` +------------------------------ + +.. automodule:: letsencrypt.achallenges + :members: diff --git a/docs/api/augeas_configurator.rst b/docs/api/augeas_configurator.rst new file mode 100644 index 000000000..402eee797 --- /dev/null +++ b/docs/api/augeas_configurator.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.augeas_configurator` +-------------------------------------- + +.. automodule:: letsencrypt.augeas_configurator + :members: diff --git a/docs/api/auth_handler.rst b/docs/api/auth_handler.rst new file mode 100644 index 000000000..3b168faf8 --- /dev/null +++ b/docs/api/auth_handler.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.auth_handler` +------------------------------- + +.. automodule:: letsencrypt.auth_handler + :members: diff --git a/docs/api/client/index.rst b/docs/api/client.rst similarity index 100% rename from docs/api/client/index.rst rename to docs/api/client.rst diff --git a/docs/api/client/account.rst b/docs/api/client/account.rst deleted file mode 100644 index 6fad87556..000000000 --- a/docs/api/client/account.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.account` ---------------------------------- - -.. automodule:: letsencrypt.client.account - :members: diff --git a/docs/api/client/achallenges.rst b/docs/api/client/achallenges.rst deleted file mode 100644 index 46a13ee8b..000000000 --- a/docs/api/client/achallenges.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.achallenges` -------------------------------------- - -.. automodule:: letsencrypt.client.achallenges - :members: diff --git a/docs/api/client/augeas_configurator.rst b/docs/api/client/augeas_configurator.rst deleted file mode 100644 index 6b8ca4d83..000000000 --- a/docs/api/client/augeas_configurator.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.augeas_configurator` ---------------------------------------------- - -.. automodule:: letsencrypt.client.augeas_configurator - :members: diff --git a/docs/api/client/auth_handler.rst b/docs/api/client/auth_handler.rst deleted file mode 100644 index b52006993..000000000 --- a/docs/api/client/auth_handler.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.auth_handler` --------------------------------------- - -.. automodule:: letsencrypt.client.auth_handler - :members: diff --git a/docs/api/client/client.rst b/docs/api/client/client.rst deleted file mode 100644 index ac68c2764..000000000 --- a/docs/api/client/client.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.client` --------------------------------- - -.. automodule:: letsencrypt.client.client - :members: diff --git a/docs/api/client/configuration.rst b/docs/api/client/configuration.rst deleted file mode 100644 index 0bec61480..000000000 --- a/docs/api/client/configuration.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.configuration` ---------------------------------------- - -.. automodule:: letsencrypt.client.configuration - :members: diff --git a/docs/api/client/constants.rst b/docs/api/client/constants.rst deleted file mode 100644 index c901e13c2..000000000 --- a/docs/api/client/constants.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.constants` ------------------------------------ - -.. automodule:: letsencrypt.client.constants - :members: diff --git a/docs/api/client/continuity_auth.rst b/docs/api/client/continuity_auth.rst deleted file mode 100644 index 29f6a3ffb..000000000 --- a/docs/api/client/continuity_auth.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.continuity_auth` ------------------------------------------ - -.. automodule:: letsencrypt.client.continuity_auth - :members: diff --git a/docs/api/client/crypto_util.rst b/docs/api/client/crypto_util.rst deleted file mode 100644 index 1b47cd151..000000000 --- a/docs/api/client/crypto_util.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.crypto_util` -------------------------------------- - -.. automodule:: letsencrypt.client.crypto_util - :members: diff --git a/docs/api/client/display.rst b/docs/api/client/display.rst deleted file mode 100644 index 59f97d18e..000000000 --- a/docs/api/client/display.rst +++ /dev/null @@ -1,29 +0,0 @@ -:mod:`letsencrypt.client.display` ---------------------------------- - -.. automodule:: letsencrypt.client.display - :members: - -:mod:`letsencrypt.client.display.util` -====================================== - -.. automodule:: letsencrypt.client.display.util - :members: - -:mod:`letsencrypt.client.display.ops` -===================================== - -.. automodule:: letsencrypt.client.display.ops - :members: - -:mod:`letsencrypt.client.display.enhancements` -============================================== - -.. automodule:: letsencrypt.client.display.enhancements - :members: - -:mod:`letsencrypt.client.display.revocation` -============================================ - -.. automodule:: letsencrypt.client.display.revocation - :members: diff --git a/docs/api/client/errors.rst b/docs/api/client/errors.rst deleted file mode 100644 index 40f0ae6c7..000000000 --- a/docs/api/client/errors.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.errors` --------------------------------- - -.. automodule:: letsencrypt.client.errors - :members: diff --git a/docs/api/client/interfaces.rst b/docs/api/client/interfaces.rst deleted file mode 100644 index e14daed7f..000000000 --- a/docs/api/client/interfaces.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.interfaces` ------------------------------------- - -.. automodule:: letsencrypt.client.interfaces - :members: diff --git a/docs/api/client/le_util.rst b/docs/api/client/le_util.rst deleted file mode 100644 index 537e90546..000000000 --- a/docs/api/client/le_util.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.le_util` ---------------------------------- - -.. automodule:: letsencrypt.client.le_util - :members: diff --git a/docs/api/client/log.rst b/docs/api/client/log.rst deleted file mode 100644 index 2ccad738b..000000000 --- a/docs/api/client/log.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.log` ------------------------------ - -.. automodule:: letsencrypt.client.log - :members: diff --git a/docs/api/client/network.rst b/docs/api/client/network.rst deleted file mode 100644 index 7b4ec633a..000000000 --- a/docs/api/client/network.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.network` ---------------------------------- - -.. automodule:: letsencrypt.client.network - :members: diff --git a/docs/api/client/network2.rst b/docs/api/client/network2.rst deleted file mode 100644 index b05017551..000000000 --- a/docs/api/client/network2.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.network2` ----------------------------------- - -.. automodule:: letsencrypt.client.network2 - :members: diff --git a/docs/api/client/recovery_token.rst b/docs/api/client/recovery_token.rst deleted file mode 100644 index cc37e036d..000000000 --- a/docs/api/client/recovery_token.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.recovery_token` --------------------------------------------------- - -.. automodule:: letsencrypt.client.recovery_token - :members: diff --git a/docs/api/client/reverter.rst b/docs/api/client/reverter.rst deleted file mode 100644 index ad2e41437..000000000 --- a/docs/api/client/reverter.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.reverter` ----------------------------------- - -.. automodule:: letsencrypt.client.reverter - :members: diff --git a/docs/api/client/revoker.rst b/docs/api/client/revoker.rst deleted file mode 100644 index e0a7db533..000000000 --- a/docs/api/client/revoker.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`letsencrypt.client.revoker` ---------------------------------- - -.. automodule:: letsencrypt.client.revoker - :members: diff --git a/docs/api/configuration.rst b/docs/api/configuration.rst new file mode 100644 index 000000000..e92392b99 --- /dev/null +++ b/docs/api/configuration.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.configuration` +-------------------------------- + +.. automodule:: letsencrypt.configuration + :members: diff --git a/docs/api/constants.rst b/docs/api/constants.rst new file mode 100644 index 000000000..3a2815b5e --- /dev/null +++ b/docs/api/constants.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.constants` +----------------------------------- + +.. automodule:: letsencrypt.constants + :members: diff --git a/docs/api/continuity_auth.rst b/docs/api/continuity_auth.rst new file mode 100644 index 000000000..82869e6f4 --- /dev/null +++ b/docs/api/continuity_auth.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.continuity_auth` +---------------------------------- + +.. automodule:: letsencrypt.continuity_auth + :members: diff --git a/docs/api/crypto_util.rst b/docs/api/crypto_util.rst new file mode 100644 index 000000000..5d4c77538 --- /dev/null +++ b/docs/api/crypto_util.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.crypto_util` +------------------------------ + +.. automodule:: letsencrypt.crypto_util + :members: diff --git a/docs/api/display.rst b/docs/api/display.rst new file mode 100644 index 000000000..b79ef25d7 --- /dev/null +++ b/docs/api/display.rst @@ -0,0 +1,29 @@ +:mod:`letsencrypt.display` +-------------------------- + +.. automodule:: letsencrypt.display + :members: + +:mod:`letsencrypt.display.util` +=============================== + +.. automodule:: letsencrypt.display.util + :members: + +:mod:`letsencrypt.display.ops` +============================== + +.. automodule:: letsencrypt.display.ops + :members: + +:mod:`letsencrypt.display.enhancements` +======================================= + +.. automodule:: letsencrypt.display.enhancements + :members: + +:mod:`letsencrypt.display.revocation` +===================================== + +.. automodule:: letsencrypt.display.revocation + :members: diff --git a/docs/api/errors.rst b/docs/api/errors.rst new file mode 100644 index 000000000..1ad13235c --- /dev/null +++ b/docs/api/errors.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.errors` +------------------------- + +.. automodule:: letsencrypt.errors + :members: diff --git a/docs/api/index.rst b/docs/api/index.rst new file mode 100644 index 000000000..a2475eeae --- /dev/null +++ b/docs/api/index.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt` +------------------ + +.. automodule:: letsencrypt + :members: diff --git a/docs/api/interfaces.rst b/docs/api/interfaces.rst new file mode 100644 index 000000000..00b0a1e50 --- /dev/null +++ b/docs/api/interfaces.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.interfaces` +----------------------------- + +.. automodule:: letsencrypt.interfaces + :members: diff --git a/docs/api/le_util.rst b/docs/api/le_util.rst new file mode 100644 index 000000000..8c6b717cf --- /dev/null +++ b/docs/api/le_util.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.le_util` +-------------------------- + +.. automodule:: letsencrypt.le_util + :members: diff --git a/docs/api/log.rst b/docs/api/log.rst new file mode 100644 index 000000000..f41c6c4b1 --- /dev/null +++ b/docs/api/log.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.log` +---------------------- + +.. automodule:: letsencrypt.log + :members: diff --git a/docs/api/network.rst b/docs/api/network.rst new file mode 100644 index 000000000..0359379dd --- /dev/null +++ b/docs/api/network.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.network` +-------------------------- + +.. automodule:: letsencrypt.network + :members: diff --git a/docs/api/network2.rst b/docs/api/network2.rst new file mode 100644 index 000000000..a73308e1b --- /dev/null +++ b/docs/api/network2.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.network2` +--------------------------- + +.. automodule:: letsencrypt.network2 + :members: diff --git a/docs/api/plugins/common.rst b/docs/api/plugins/common.rst index 9ee3e6b3e..ca55ba8fb 100644 --- a/docs/api/plugins/common.rst +++ b/docs/api/plugins/common.rst @@ -1,5 +1,5 @@ -:mod:`letsencrypt.client.plugins.common` ----------------------------------------- +:mod:`letsencrypt.plugins.common` +--------------------------------- -.. automodule:: letsencrypt.client.plugins.common +.. automodule:: letsencrypt.plugins.common :members: diff --git a/docs/api/plugins/disco.rst b/docs/api/plugins/disco.rst index 2b877b654..7bf2b76b4 100644 --- a/docs/api/plugins/disco.rst +++ b/docs/api/plugins/disco.rst @@ -1,5 +1,5 @@ -:mod:`letsencrypt.client.plugins.disco` ---------------------------------------- +:mod:`letsencrypt.plugins.disco` +-------------------------------- -.. automodule:: letsencrypt.client.plugins.disco +.. automodule:: letsencrypt.plugins.disco :members: diff --git a/docs/api/plugins/standalone.rst b/docs/api/plugins/standalone.rst index 44cf4b8ca..99e5ea2f8 100644 --- a/docs/api/plugins/standalone.rst +++ b/docs/api/plugins/standalone.rst @@ -1,11 +1,11 @@ -:mod:`letsencrypt.client.plugins.standalone` --------------------------------------------- +:mod:`letsencrypt.plugins.standalone` +------------------------------------- -.. automodule:: letsencrypt.client.plugins.standalone +.. automodule:: letsencrypt.plugins.standalone :members: -:mod:`letsencrypt.client.plugins.standalone.authenticator` -========================================================== +:mod:`letsencrypt.plugins.standalone.authenticator` +=================================================== -.. automodule:: letsencrypt.client.plugins.standalone.authenticator +.. automodule:: letsencrypt.plugins.standalone.authenticator :members: diff --git a/docs/api/recovery_token.rst b/docs/api/recovery_token.rst new file mode 100644 index 000000000..774aa4b3c --- /dev/null +++ b/docs/api/recovery_token.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.recovery_token` +-------------------------------------------------- + +.. automodule:: letsencrypt.recovery_token + :members: diff --git a/docs/api/reverter.rst b/docs/api/reverter.rst new file mode 100644 index 000000000..4c220124f --- /dev/null +++ b/docs/api/reverter.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.reverter` +--------------------------- + +.. automodule:: letsencrypt.reverter + :members: diff --git a/docs/api/revoker.rst b/docs/api/revoker.rst new file mode 100644 index 000000000..a482a138e --- /dev/null +++ b/docs/api/revoker.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.revoker` +-------------------------- + +.. automodule:: letsencrypt.revoker + :members: diff --git a/docs/contributing.rst b/docs/contributing.rst index 4a61f7388..da28686a2 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -69,10 +69,8 @@ Code components and layout acme contains all protocol specific code -letsencrypt/client +letsencrypt all client code -letsencrypt/scripts - just the starting point of the code, main.py Plugin-architecture @@ -84,14 +82,14 @@ The interfaces available for plugins to implement are defined in `interfaces.py`_. The most common kind of plugin is a "Configurator", which is likely to -implement the `~letsencrypt.client.interfaces.IAuthenticator` and -`~letsencrypt.client.interfaces.IInstaller` interfaces (though some +implement the `~letsencrypt.interfaces.IAuthenticator` and +`~letsencrypt.interfaces.IInstaller` interfaces (though some Configurators may implement just one of those). -There are also `~letsencrypt.client.interfaces.IDisplay` plugins, +There are also `~letsencrypt.interfaces.IDisplay` plugins, which implement bindings to alternative UI libraries. -.. _interfaces.py: https://github.com/letsencrypt/lets-encrypt-preview/blob/master/letsencrypt/client/interfaces.py +.. _interfaces.py: https://github.com/letsencrypt/lets-encrypt-preview/blob/master/letsencrypt/interfaces.py Authenticators @@ -138,7 +136,7 @@ Installer Development --------------------- There are a few existing classes that may be beneficial while -developing a new `~letsencrypt.client.interfaces.IInstaller`. +developing a new `~letsencrypt.interfaces.IInstaller`. Installers aimed to reconfigure UNIX servers may use Augeas for configuration parsing and can inherit from `~.AugeasConfigurator` class to handle much of the interface. Installers that are unable to use @@ -150,7 +148,7 @@ Display ~~~~~~~ We currently offer a pythondialog and "text" mode for displays. Display -plugins implement the `~letsencrypt.client.interfaces.IDisplay` +plugins implement the `~letsencrypt.interfaces.IDisplay` interface. diff --git a/docs/plugins.rst b/docs/plugins.rst index 0451bfe3f..c4df1180a 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -5,8 +5,8 @@ Plugins Let's Encrypt client supports dynamic discovery of plugins through the `setuptools entry points`_. This way you can, for example, create a custom implementation of -`~letsencrypt.client.interfaces.IAuthenticator` or the -'~letsencrypt.client.interfaces.IInstaller' without having to +`~letsencrypt.interfaces.IAuthenticator` or the +'~letsencrypt.interfaces.IInstaller' without having to merge it with the core upstream source code. An example is provided in ``examples/plugins/`` directory. diff --git a/examples/plugins/letsencrypt_example_plugins.py b/examples/plugins/letsencrypt_example_plugins.py index 7c6d1311c..a364ae905 100644 --- a/examples/plugins/letsencrypt_example_plugins.py +++ b/examples/plugins/letsencrypt_example_plugins.py @@ -1,12 +1,12 @@ """Example Let's Encrypt plugins. -For full examples, see `letsencrypt.client.plugins`. +For full examples, see `letsencrypt.plugins`. """ import zope.interface -from letsencrypt.client import interfaces -from letsencrypt.client.plugins import common +from letsencrypt import interfaces +from letsencrypt.plugins import common class Authenticator(common.Plugin): diff --git a/examples/restified.py b/examples/restified.py index 651ecccd1..b7b0257e2 100644 --- a/examples/restified.py +++ b/examples/restified.py @@ -7,7 +7,7 @@ import M2Crypto from letsencrypt.acme import messages2 from letsencrypt.acme import jose -from letsencrypt.client import network2 +from letsencrypt import network2 logger = logging.getLogger() @@ -35,7 +35,7 @@ logging.debug(authzr) authzr, authzr_response = net.poll(authzr) csr = M2Crypto.X509.load_request_string(pkg_resources.resource_string( - 'letsencrypt.client.tests', os.path.join('testdata', 'csr.pem'))) + 'letsencrypt.tests', os.path.join('testdata', 'csr.pem'))) try: net.request_issuance(csr, (authzr,)) except messages2.Error as error: diff --git a/letsencrypt/client/.gitignore b/letsencrypt/.gitignore similarity index 100% rename from letsencrypt/client/.gitignore rename to letsencrypt/.gitignore diff --git a/letsencrypt/__init__.py b/letsencrypt/__init__.py index b36747b5f..560191bf1 100644 --- a/letsencrypt/__init__.py +++ b/letsencrypt/__init__.py @@ -1,3 +1,4 @@ -"""Let's Encrypt.""" +"""Let's Encrypt client.""" + # version number like 1.2.3a0, must have at least 2 parts, like 1.2 __version__ = "0.1" diff --git a/letsencrypt/client/account.py b/letsencrypt/account.py similarity index 90% rename from letsencrypt/client/account.py rename to letsencrypt/account.py index 053f73a87..3f8e3d012 100644 --- a/letsencrypt/client/account.py +++ b/letsencrypt/account.py @@ -8,21 +8,21 @@ import zope.component from acme import messages2 -from letsencrypt.client import crypto_util -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util +from letsencrypt import crypto_util +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class Account(object): """ACME protocol registration. :ivar config: Client configuration object - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` :ivar key: Account/Authorized Key - :type key: :class:`~letsencrypt.client.le_util.Key` + :type key: :class:`~letsencrypt.le_util.Key` :ivar str email: Client's email address :ivar str phone: Client's phone number @@ -156,7 +156,7 @@ class Account(object): """Return all current accounts. :param config: Configuration - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ try: @@ -178,10 +178,10 @@ class Account(object): """Generate an account from prompted user input. :param config: Configuration - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` :returns: Account or None - :rtype: :class:`letsencrypt.client.account.Account` + :rtype: :class:`letsencrypt.account.Account` """ while True: @@ -201,11 +201,11 @@ class Account(object): """Generate a new account from an email address. :param config: Configuration - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` :param str email: Email address - :raises letsencrypt.client.errors.LetsEncryptClientError: If invalid + :raises letsencrypt.errors.LetsEncryptClientError: If invalid email address is given. """ diff --git a/letsencrypt/client/achallenges.py b/letsencrypt/achallenges.py similarity index 96% rename from letsencrypt/client/achallenges.py rename to letsencrypt/achallenges.py index a88b0dddb..77e362f22 100644 --- a/letsencrypt/client/achallenges.py +++ b/letsencrypt/achallenges.py @@ -6,7 +6,7 @@ and :class:`.ChallengeBody` (denoted by ``challb``):: from acme import challenges from acme import messages2 - from letsencrypt.client import achallenges + from letsencrypt import achallenges chall = challenges.DNS(token='foo') challb = messages2.ChallengeBody(chall=chall) @@ -20,7 +20,7 @@ Note, that all annotated challenges act as a proxy objects:: from acme import challenges from acme.jose import util as jose_util -from letsencrypt.client import crypto_util +from letsencrypt import crypto_util # pylint: disable=too-few-public-methods diff --git a/letsencrypt/client/augeas_configurator.py b/letsencrypt/augeas_configurator.py similarity index 96% rename from letsencrypt/client/augeas_configurator.py rename to letsencrypt/augeas_configurator.py index 713d49291..c59d755c2 100644 --- a/letsencrypt/client/augeas_configurator.py +++ b/letsencrypt/augeas_configurator.py @@ -3,22 +3,22 @@ import logging import augeas -from letsencrypt.client import reverter -from letsencrypt.client.plugins import common +from letsencrypt import reverter +from letsencrypt.plugins import common class AugeasConfigurator(common.Plugin): """Base Augeas Configurator class. :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` :ivar aug: Augeas object :type aug: :class:`augeas.Augeas` :ivar str save_notes: Human-readable configuration change notes :ivar reverter: saves and reverts checkpoints - :type reverter: :class:`letsencrypt.client.reverter.Reverter` + :type reverter: :class:`letsencrypt.reverter.Reverter` """ diff --git a/letsencrypt/client/auth_handler.py b/letsencrypt/auth_handler.py similarity index 94% rename from letsencrypt/client/auth_handler.py rename to letsencrypt/auth_handler.py index 52e2df0c6..e83cdd717 100644 --- a/letsencrypt/client/auth_handler.py +++ b/letsencrypt/auth_handler.py @@ -6,9 +6,9 @@ import time from acme import challenges from acme import messages2 -from letsencrypt.client import achallenges -from letsencrypt.client import constants -from letsencrypt.client import errors +from letsencrypt import achallenges +from letsencrypt import constants +from letsencrypt import errors class AuthHandler(object): @@ -16,25 +16,25 @@ class AuthHandler(object): :ivar dv_auth: Authenticator capable of solving :class:`~acme.challenges.DVChallenge` types - :type dv_auth: :class:`letsencrypt.client.interfaces.IAuthenticator` + :type dv_auth: :class:`letsencrypt.interfaces.IAuthenticator` :ivar cont_auth: Authenticator capable of solving :class:`~acme.challenges.ContinuityChallenge` types - :type cont_auth: :class:`letsencrypt.client.interfaces.IAuthenticator` + :type cont_auth: :class:`letsencrypt.interfaces.IAuthenticator` :ivar network: Network object for sending and receiving authorization messages - :type network: :class:`letsencrypt.client.network2.Network` + :type network: :class:`letsencrypt.network2.Network` :ivar account: Client's Account - :type account: :class:`letsencrypt.client.account.Account` + :type account: :class:`letsencrypt.account.Account` :ivar dict authzr: ACME Authorization Resource dict where keys are domains and values are :class:`acme.messages2.AuthorizationResource` :ivar list dv_c: DV challenges in the form of - :class:`letsencrypt.client.achallenges.AnnotatedChallenge` + :class:`letsencrypt.achallenges.AnnotatedChallenge` :ivar list cont_c: Continuity challenges in the - form of :class:`letsencrypt.client.achallenges.AnnotatedChallenge` + form of :class:`letsencrypt.achallenges.AnnotatedChallenge` """ def __init__(self, dv_auth, cont_auth, network, account): @@ -222,7 +222,7 @@ class AuthHandler(object): :type authzr: :class:`acme.messages2.AuthorizationResource` :param achall: Annotated challenge for which to get status - :type achall: :class:`letsencrypt.client.achallenges.AnnotatedChallenge` + :type achall: :class:`letsencrypt.achallenges.AnnotatedChallenge` """ for authzr_challb in authzr.body.challenges: @@ -289,9 +289,9 @@ class AuthHandler(object): :param list path: List of indices from `challenges`. :returns: dv_chall, list of DVChallenge type - :class:`letsencrypt.client.achallenges.Indexed` + :class:`letsencrypt.achallenges.Indexed` cont_chall, list of ContinuityChallenge type - :class:`letsencrypt.client.achallenges.Indexed` + :class:`letsencrypt.achallenges.Indexed` :rtype: tuple :raises errors.LetsEncryptClientError: If Challenge type is not @@ -322,12 +322,12 @@ def challb_to_achall(challb, key, domain): :type challb: :class:`acme.messages2.ChallengeBody` :param key: Key - :type key: :class:`letsencrypt.client.le_util.Key` + :type key: :class:`letsencrypt.le_util.Key` :param str domain: Domain of the challb :returns: Appropriate AnnotatedChallenge - :rtype: :class:`letsencrypt.client.achallenges.AnnotatedChallenge` + :rtype: :class:`letsencrypt.achallenges.AnnotatedChallenge` """ chall = challb.chall @@ -383,7 +383,7 @@ def gen_challenge_path(challbs, preferences, combinations): :returns: tuple of indices from ``challenges``. :rtype: tuple - :raises letsencrypt.client.errors.AuthorizationError: If a + :raises letsencrypt.errors.AuthorizationError: If a path cannot be created that satisfies the CA given the preferences and combinations. diff --git a/letsencrypt/client/cli.py b/letsencrypt/cli.py similarity index 96% rename from letsencrypt/client/cli.py rename to letsencrypt/cli.py index a83c0f767..be933d891 100644 --- a/letsencrypt/client/cli.py +++ b/letsencrypt/cli.py @@ -12,19 +12,19 @@ import zope.interface.verify import letsencrypt -from letsencrypt.client import account -from letsencrypt.client import configuration -from letsencrypt.client import constants -from letsencrypt.client import client -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util -from letsencrypt.client import log +from letsencrypt import account +from letsencrypt import configuration +from letsencrypt import constants +from letsencrypt import client +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util +from letsencrypt import log -from letsencrypt.client.display import util as display_util -from letsencrypt.client.display import ops as display_ops +from letsencrypt.display import util as display_util +from letsencrypt.display import ops as display_ops -from letsencrypt.client.plugins import disco as plugins_disco +from letsencrypt.plugins import disco as plugins_disco def _account_init(args, config): diff --git a/letsencrypt/client/client.py b/letsencrypt/client.py similarity index 86% rename from letsencrypt/client/client.py rename to letsencrypt/client.py index b658df90e..b28a7fa74 100644 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client.py @@ -9,40 +9,40 @@ import zope.component from acme import jose from acme.jose import jwk -from letsencrypt.client import account -from letsencrypt.client import auth_handler -from letsencrypt.client import continuity_auth -from letsencrypt.client import crypto_util -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util -from letsencrypt.client import network2 -from letsencrypt.client import reverter -from letsencrypt.client import revoker +from letsencrypt import account +from letsencrypt import auth_handler +from letsencrypt import continuity_auth +from letsencrypt import crypto_util +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util +from letsencrypt import network2 +from letsencrypt import reverter +from letsencrypt import revoker -from letsencrypt.client.display import ops as display_ops -from letsencrypt.client.display import enhancements +from letsencrypt.display import ops as display_ops +from letsencrypt.display import enhancements class Client(object): """ACME protocol client. :ivar network: Network object for sending and receiving messages - :type network: :class:`letsencrypt.client.network2.Network` + :type network: :class:`letsencrypt.network2.Network` :ivar account: Account object used for registration - :type account: :class:`letsencrypt.client.account.Account` + :type account: :class:`letsencrypt.account.Account` :ivar auth_handler: Object that supports the IAuthenticator interface. auth_handler contains both a dv_authenticator and a continuity_authenticator - :type auth_handler: :class:`letsencrypt.client.auth_handler.AuthHandler` + :type auth_handler: :class:`letsencrypt.auth_handler.AuthHandler` :ivar installer: Object supporting the IInstaller interface. - :type installer: :class:`letsencrypt.client.interfaces.IInstaller` + :type installer: :class:`letsencrypt.interfaces.IInstaller` :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` """ @@ -50,10 +50,10 @@ class Client(object): """Initialize a client. :param dv_auth: IAuthenticator that can solve the - :const:`letsencrypt.client.constants.DV_CHALLENGES`. - The :meth:`~letsencrypt.client.interfaces.IAuthenticator.prepare` + :const:`letsencrypt.constants.DV_CHALLENGES`. + The :meth:`~letsencrypt.interfaces.IAuthenticator.prepare` must have already been run. - :type dv_auth: :class:`letsencrypt.client.interfaces.IAuthenticator` + :type dv_auth: :class:`letsencrypt.interfaces.IAuthenticator` """ self.account = account_ @@ -107,7 +107,7 @@ class Client(object): :type csr: :class:`CSR` :returns: cert_key, cert_path, chain_path - :rtype: `tuple` of (:class:`letsencrypt.client.le_util.Key`, str, str) + :rtype: `tuple` of (:class:`letsencrypt.le_util.Key`, str, str) """ if self.auth_handler is None: @@ -196,7 +196,7 @@ class Client(object): :param list domains: list of domains to install the certificate :param privkey: private key for certificate - :type privkey: :class:`letsencrypt.client.le_util.Key` + :type privkey: :class:`letsencrypt.le_util.Key` :param str cert_path: certificate file path :param str chain_path: chain file path @@ -232,7 +232,7 @@ class Client(object): :param redirect: If traffic should be forwarded from HTTP to HTTPS. :type redirect: bool or None - :raises letsencrypt.client.errors.LetsEncryptClientError: if + :raises letsencrypt.errors.LetsEncryptClientError: if no installer is specified in the client. """ @@ -251,7 +251,7 @@ class Client(object): """Redirect all traffic from HTTP to HTTPS :param vhost: list of ssl_vhosts - :type vhost: :class:`letsencrypt.client.interfaces.IInstaller` + :type vhost: :class:`letsencrypt.interfaces.IInstaller` """ for dom in domains: @@ -274,12 +274,12 @@ def validate_key_csr(privkey, csr=None): If csr is left as None, only the key will be validated. :param privkey: Key associated with CSR - :type privkey: :class:`letsencrypt.client.le_util.Key` + :type privkey: :class:`letsencrypt.le_util.Key` :param csr: CSR - :type csr: :class:`letsencrypt.client.le_util.CSR` + :type csr: :class:`letsencrypt.le_util.CSR` - :raises letsencrypt.client.errors.LetsEncryptClientError: when + :raises letsencrypt.errors.LetsEncryptClientError: when validation fails """ @@ -317,10 +317,10 @@ def determine_account(config): Will create an account if necessary. :param config: Configuration object - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` :returns: Account - :rtype: :class:`letsencrypt.client.account.Account` + :rtype: :class:`letsencrypt.account.Account` """ accounts = account.Account.get_accounts(config) @@ -339,7 +339,7 @@ def rollback(default_installer, checkpoints, config, plugins): :param int checkpoints: Number of checkpoints to revert. :param config: Configuration. - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ # Misconfigurations are only a slight problems... allow the user to rollback @@ -359,7 +359,7 @@ def revoke(default_installer, config, plugins, no_confirm, cert, authkey): """Revoke certificates. :param config: Configuration. - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ installer = display_ops.pick_installer( @@ -382,7 +382,7 @@ def view_config_changes(config): .. note:: This assumes that the installation is using a Reverter object. :param config: Configuration. - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ rev = reverter.Reverter(config) diff --git a/letsencrypt/client/__init__.py b/letsencrypt/client/__init__.py deleted file mode 100644 index d6c102964..000000000 --- a/letsencrypt/client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Let's Encrypt client.""" diff --git a/letsencrypt/client/display/__init__.py b/letsencrypt/client/display/__init__.py deleted file mode 100644 index b652c58a9..000000000 --- a/letsencrypt/client/display/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Let's Encrypt client.display""" diff --git a/letsencrypt/client/plugins/standalone/__init__.py b/letsencrypt/client/plugins/standalone/__init__.py deleted file mode 100644 index 41de6eaf7..000000000 --- a/letsencrypt/client/plugins/standalone/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Let's Encrypt client.plugins.standalone.""" diff --git a/letsencrypt/client/configuration.py b/letsencrypt/configuration.py similarity index 89% rename from letsencrypt/client/configuration.py rename to letsencrypt/configuration.py index 14c7b23cd..a83fb9978 100644 --- a/letsencrypt/client/configuration.py +++ b/letsencrypt/configuration.py @@ -2,18 +2,18 @@ import os import zope.interface -from letsencrypt.client import constants -from letsencrypt.client import interfaces +from letsencrypt import constants +from letsencrypt import interfaces class NamespaceConfig(object): """Configuration wrapper around :class:`argparse.Namespace`. For more documentation, including available attributes, please see - :class:`letsencrypt.client.interfaces.IConfig`. However, note that + :class:`letsencrypt.interfaces.IConfig`. However, note that the following attributes are dynamically resolved using - :attr:`~letsencrypt.client.interfaces.IConfig.work_dir` and relative - paths defined in :py:mod:`letsencrypt.client.constants`: + :attr:`~letsencrypt.interfaces.IConfig.work_dir` and relative + paths defined in :py:mod:`letsencrypt.constants`: - ``temp_checkpoint_dir`` - ``in_progress_dir`` diff --git a/letsencrypt/client/constants.py b/letsencrypt/constants.py similarity index 96% rename from letsencrypt/client/constants.py rename to letsencrypt/constants.py index 513b76829..4eba69f20 100644 --- a/letsencrypt/client/constants.py +++ b/letsencrypt/constants.py @@ -31,7 +31,7 @@ EXCLUSIVE_CHALLENGES = frozenset([frozenset([ ENHANCEMENTS = ["redirect", "http-header", "ocsp-stapling", "spdy"] -"""List of possible :class:`letsencrypt.client.interfaces.IInstaller` +"""List of possible :class:`letsencrypt.interfaces.IInstaller` enhancements. List of expected options parameters: diff --git a/letsencrypt/client/continuity_auth.py b/letsencrypt/continuity_auth.py similarity index 82% rename from letsencrypt/client/continuity_auth.py rename to letsencrypt/continuity_auth.py index 4d75b43cf..e4bbbe13d 100644 --- a/letsencrypt/client/continuity_auth.py +++ b/letsencrypt/continuity_auth.py @@ -3,10 +3,10 @@ import zope.interface from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import recovery_token +from letsencrypt import achallenges +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import recovery_token class ContinuityAuthenticator(object): @@ -14,7 +14,7 @@ class ContinuityAuthenticator(object): :const:`~acme.challenges.ContinuityChallenge` class challenges. :ivar rec_token: Performs "recoveryToken" challenges - :type rec_token: :class:`letsencrypt.client.recovery_token.RecoveryToken` + :type rec_token: :class:`letsencrypt.recovery_token.RecoveryToken` """ zope.interface.implements(interfaces.IAuthenticator) @@ -24,7 +24,7 @@ class ContinuityAuthenticator(object): """Initialize Client Authenticator. :param config: Configuration. - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ self.rec_token = recovery_token.RecoveryToken( diff --git a/letsencrypt/client/crypto_util.py b/letsencrypt/crypto_util.py similarity index 96% rename from letsencrypt/client/crypto_util.py rename to letsencrypt/crypto_util.py index c2b761d59..f89f281cb 100644 --- a/letsencrypt/client/crypto_util.py +++ b/letsencrypt/crypto_util.py @@ -14,7 +14,7 @@ import Crypto.Signature.PKCS1_v1_5 import M2Crypto -from letsencrypt.client import le_util +from letsencrypt import le_util # High level functions @@ -31,7 +31,7 @@ def init_save_key(key_size, key_dir, keyname="key-letsencrypt.pem"): :param str keyname: Filename of key :returns: Key - :rtype: :class:`letsencrypt.client.le_util.Key` + :rtype: :class:`letsencrypt.le_util.Key` :raises ValueError: If unable to generate the key given key_size. @@ -58,14 +58,14 @@ def init_save_csr(privkey, names, cert_dir, csrname="csr-letsencrypt.pem"): """Initialize a CSR with the given private key. :param privkey: Key to include in the CSR - :type privkey: :class:`letsencrypt.client.le_util.Key` + :type privkey: :class:`letsencrypt.le_util.Key` :param set names: `str` names to include in the CSR :param str cert_dir: Certificate save directory. :returns: CSR - :rtype: :class:`letsencrypt.client.le_util.CSR` + :rtype: :class:`letsencrypt.le_util.CSR` """ csr_pem, csr_der = make_csr(privkey.pem, names) diff --git a/letsencrypt/display/__init__.py b/letsencrypt/display/__init__.py new file mode 100644 index 000000000..01e3ca11f --- /dev/null +++ b/letsencrypt/display/__init__.py @@ -0,0 +1 @@ +"""Let's Encrypt display utilities.""" diff --git a/letsencrypt/client/display/enhancements.py b/letsencrypt/display/enhancements.py similarity index 83% rename from letsencrypt/client/display/enhancements.py rename to letsencrypt/display/enhancements.py index d7ea3a66a..48f168441 100644 --- a/letsencrypt/client/display/enhancements.py +++ b/letsencrypt/display/enhancements.py @@ -3,9 +3,9 @@ import logging import zope.component -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client.display import util as display_util +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt.display import util as display_util # Define a helper function to avoid verbose code @@ -16,12 +16,12 @@ def ask(enhancement): """Display the enhancement to the user. :param str enhancement: One of the - :class:`letsencrypt.client.CONFIG.ENHANCEMENTS` enhancements + :class:`letsencrypt.CONFIG.ENHANCEMENTS` enhancements :returns: True if feature is desired, False otherwise :rtype: bool - :raises letsencrypt.client.errors.LetsEncryptClientError: If + :raises letsencrypt.errors.LetsEncryptClientError: If the enhancement provided is not supported. """ diff --git a/letsencrypt/client/display/ops.py b/letsencrypt/display/ops.py similarity index 94% rename from letsencrypt/client/display/ops.py rename to letsencrypt/display/ops.py index dc6992c8c..e05a19b14 100644 --- a/letsencrypt/client/display/ops.py +++ b/letsencrypt/display/ops.py @@ -4,8 +4,8 @@ import os import zope.component -from letsencrypt.client import interfaces -from letsencrypt.client.display import util as display_util +from letsencrypt import interfaces +from letsencrypt.display import util as display_util # Define a helper function to avoid verbose code @@ -46,9 +46,9 @@ def choose_plugin(prepared, question): def pick_plugin(config, default, plugins, question, ifaces): """Pick plugin. - :param letsencrypt.client.interfaces.IConfig: Configuration + :param letsencrypt.interfaces.IConfig: Configuration :param str default: Plugin name supplied by user or ``None``. - :param letsencrypt.client.plugins.disco.PluginsRegistry plugins: + :param letsencrypt.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. :param str question: Question to be presented to the user in case multiple candidates are found. @@ -114,7 +114,7 @@ def choose_account(accounts): """Choose an account. :param list accounts: Containing at least one - :class:`~letsencrypt.client.account.Account` + :class:`~letsencrypt.account.Account` """ # Note this will get more complicated once we start recording authorizations @@ -136,7 +136,7 @@ def choose_names(installer): """Display screen to select domains to validate. :param installer: An installer object - :type installer: :class:`letsencrypt.client.interfaces.IInstaller` + :type installer: :class:`letsencrypt.interfaces.IInstaller` :returns: List of selected names :rtype: `list` of `str` diff --git a/letsencrypt/client/display/revocation.py b/letsencrypt/display/revocation.py similarity index 89% rename from letsencrypt/client/display/revocation.py rename to letsencrypt/display/revocation.py index 65dbd9f63..02a253676 100644 --- a/letsencrypt/client/display/revocation.py +++ b/letsencrypt/display/revocation.py @@ -3,8 +3,8 @@ import os import zope.component -from letsencrypt.client import interfaces -from letsencrypt.client.display import util as display_util +from letsencrypt import interfaces +from letsencrypt.display import util as display_util # Define a helper function to avoid verbose code util = zope.component.getUtility # pylint: disable=invalid-name @@ -13,7 +13,7 @@ util = zope.component.getUtility # pylint: disable=invalid-name def display_certs(certs): """Display the certificates in a menu for revocation. - :param list certs: each is a :class:`letsencrypt.client.revoker.Cert` + :param list certs: each is a :class:`letsencrypt.revoker.Cert` :returns: tuple of the form (code, selection) where code is a display exit code @@ -69,7 +69,7 @@ def success_revocation(cert): """Display a success message. :param cert: cert that was revoked - :type cert: :class:`letsencrypt.client.revoker.Cert` + :type cert: :class:`letsencrypt.revoker.Cert` """ util(interfaces.IDisplay).notification( diff --git a/letsencrypt/client/display/util.py b/letsencrypt/display/util.py similarity index 99% rename from letsencrypt/client/display/util.py rename to letsencrypt/display/util.py index d34c6b46b..bd509dd28 100644 --- a/letsencrypt/client/display/util.py +++ b/letsencrypt/display/util.py @@ -5,7 +5,7 @@ import textwrap import dialog import zope.interface -from letsencrypt.client import interfaces +from letsencrypt import interfaces WIDTH = 72 diff --git a/letsencrypt/client/errors.py b/letsencrypt/errors.py similarity index 100% rename from letsencrypt/client/errors.py rename to letsencrypt/errors.py diff --git a/letsencrypt/client/interfaces.py b/letsencrypt/interfaces.py similarity index 95% rename from letsencrypt/client/interfaces.py rename to letsencrypt/interfaces.py index e28264759..e6c0588c5 100644 --- a/letsencrypt/client/interfaces.py +++ b/letsencrypt/interfaces.py @@ -68,10 +68,10 @@ class IPlugin(zope.interface.Interface): Finish up any additional initialization. - :raises letsencrypt.client.errors.LetsEncryptMisconfigurationError: + :raises letsencrypt.errors.LetsEncryptMisconfigurationError: when full initialization cannot be completed. Plugin will be displayed on a list of available plugins. - :raises letsencrypt.client.errors.LetsEncryptNoInstallationError: + :raises letsencrypt.errors.LetsEncryptNoInstallationError: when the necessary programs/files cannot be located. Plugin will NOT be displayed on a list of available plugins. @@ -111,7 +111,7 @@ class IAuthenticator(IPlugin): """Perform the given challenge. :param list achalls: Non-empty (guaranteed) list of - :class:`~letsencrypt.client.achallenges.AnnotatedChallenge` + :class:`~letsencrypt.achallenges.AnnotatedChallenge` instances, such that it contains types found within :func:`get_chall_pref` only. @@ -134,7 +134,7 @@ class IAuthenticator(IPlugin): """Revert changes and shutdown after challenges complete. :param list achalls: Non-empty (guaranteed) list of - :class:`~letsencrypt.client.achallenges.AnnotatedChallenge` + :class:`~letsencrypt.achallenges.AnnotatedChallenge` instances, a subset of those previously passed to :func:`perform`. """ @@ -203,10 +203,10 @@ class IInstaller(IPlugin): :param str domain: domain for which to provide enhancement :param str enhancement: An enhancement as defined in - :const:`~letsencrypt.client.constants.ENHANCEMENTS` + :const:`~letsencrypt.constants.ENHANCEMENTS` :param options: Flexible options parameter for enhancement. Check documentation of - :const:`~letsencrypt.client.constants.ENHANCEMENTS` + :const:`~letsencrypt.constants.ENHANCEMENTS` for expected options for each enhancement. """ @@ -215,7 +215,7 @@ class IInstaller(IPlugin): """Returns a list of supported enhancements. :returns: supported enhancements which should be a subset of - :const:`~letsencrypt.client.constants.ENHANCEMENTS` + :const:`~letsencrypt.constants.ENHANCEMENTS` :rtype: :class:`list` of :class:`str` """ diff --git a/letsencrypt/client/le_util.py b/letsencrypt/le_util.py similarity index 98% rename from letsencrypt/client/le_util.py rename to letsencrypt/le_util.py index 1615fc29d..27d795749 100644 --- a/letsencrypt/client/le_util.py +++ b/letsencrypt/le_util.py @@ -4,7 +4,7 @@ import errno import os import stat -from letsencrypt.client import errors +from letsencrypt import errors Key = collections.namedtuple("Key", "file pem") diff --git a/letsencrypt/client/log.py b/letsencrypt/log.py similarity index 97% rename from letsencrypt/client/log.py rename to letsencrypt/log.py index 57c642ce2..a31bad8e3 100644 --- a/letsencrypt/client/log.py +++ b/letsencrypt/log.py @@ -3,7 +3,7 @@ import logging import dialog -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class DialogHandler(logging.Handler): # pylint: disable=too-few-public-methods diff --git a/letsencrypt/client/network.py b/letsencrypt/network.py similarity index 99% rename from letsencrypt/client/network.py rename to letsencrypt/network.py index 81a3fccdc..f59794971 100644 --- a/letsencrypt/client/network.py +++ b/letsencrypt/network.py @@ -8,7 +8,7 @@ import requests from acme import jose from acme import messages -from letsencrypt.client import errors +from letsencrypt import errors # https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning diff --git a/letsencrypt/client/network2.py b/letsencrypt/network2.py similarity index 98% rename from letsencrypt/client/network2.py rename to letsencrypt/network2.py index 2b85ebd3c..e66afb3a6 100644 --- a/letsencrypt/client/network2.py +++ b/letsencrypt/network2.py @@ -12,7 +12,7 @@ import werkzeug from acme import jose from acme import messages2 -from letsencrypt.client import errors +from letsencrypt import errors # https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning @@ -109,7 +109,7 @@ class Network(object): def _get(self, uri, content_type=JSON_CONTENT_TYPE, **kwargs): """Send GET request. - :raises letsencrypt.client.errors.NetworkError: + :raises letsencrypt.errors.NetworkError: :returns: HTTP Response :rtype: `requests.Response` @@ -172,7 +172,7 @@ class Network(object): :returns: Registration Resource. :rtype: `.RegistrationResource` - :raises letsencrypt.client.errors.UnexpectedUpdate: + :raises letsencrypt.errors.UnexpectedUpdate: """ new_reg = messages2.Registration(contact=contact) @@ -190,10 +190,10 @@ class Network(object): """Register with server. :param account: Account - :type account: :class:`letsencrypt.client.account.Account` + :type account: :class:`letsencrypt.account.Account` :returns: Updated account - :rtype: :class:`letsencrypt.client.account.Account` + :rtype: :class:`letsencrypt.account.Account` """ details = ( @@ -535,7 +535,7 @@ class Network(object): :param when: When should the revocation take place? Takes the same values as `.messages2.Revocation.revoke`. - :raises letsencrypt.client.errors.NetworkError: If revocation is + :raises letsencrypt.errors.NetworkError: If revocation is unsuccessful. """ diff --git a/letsencrypt/client/plugins/__init__.py b/letsencrypt/plugins/__init__.py similarity index 100% rename from letsencrypt/client/plugins/__init__.py rename to letsencrypt/plugins/__init__.py diff --git a/letsencrypt/client/plugins/common.py b/letsencrypt/plugins/common.py similarity index 98% rename from letsencrypt/client/plugins/common.py rename to letsencrypt/plugins/common.py index 08e9cf658..32bee2b49 100644 --- a/letsencrypt/client/plugins/common.py +++ b/letsencrypt/plugins/common.py @@ -3,7 +3,7 @@ import zope.interface from acme.jose import util as jose_util -from letsencrypt.client import interfaces +from letsencrypt import interfaces def option_namespace(name): diff --git a/letsencrypt/client/plugins/common_test.py b/letsencrypt/plugins/common_test.py similarity index 81% rename from letsencrypt/client/plugins/common_test.py rename to letsencrypt/plugins/common_test.py index bdb5f7f3c..348ed9379 100644 --- a/letsencrypt/client/plugins/common_test.py +++ b/letsencrypt/plugins/common_test.py @@ -1,26 +1,26 @@ -"""Tests for letsencrypt.client.plugins.common.""" +"""Tests for letsencrypt.plugins.common.""" import unittest import mock class NamespaceFunctionsTest(unittest.TestCase): - """Tests for letsencrypt.client.plugins.common.*_namespace functions.""" + """Tests for letsencrypt.plugins.common.*_namespace functions.""" def test_option_namespace(self): - from letsencrypt.client.plugins.common import option_namespace + from letsencrypt.plugins.common import option_namespace self.assertEqual("foo-", option_namespace("foo")) def test_dest_namespace(self): - from letsencrypt.client.plugins.common import dest_namespace + from letsencrypt.plugins.common import dest_namespace self.assertEqual("foo_", dest_namespace("foo")) class PluginTest(unittest.TestCase): - """Test for letsencrypt.client.plugins.common.Plugin.""" + """Test for letsencrypt.plugins.common.Plugin.""" def setUp(self): - from letsencrypt.client.plugins.common import Plugin + from letsencrypt.plugins.common import Plugin class MockPlugin(Plugin): # pylint: disable=missing-docstring @classmethod diff --git a/letsencrypt/client/plugins/disco.py b/letsencrypt/plugins/disco.py similarity index 98% rename from letsencrypt/client/plugins/disco.py rename to letsencrypt/plugins/disco.py index 50e0bce50..072c3ef42 100644 --- a/letsencrypt/client/plugins/disco.py +++ b/letsencrypt/plugins/disco.py @@ -5,9 +5,9 @@ import pkg_resources import zope.interface -from letsencrypt.client import constants -from letsencrypt.client import errors -from letsencrypt.client import interfaces +from letsencrypt import constants +from letsencrypt import errors +from letsencrypt import interfaces class PluginEntryPoint(object): diff --git a/letsencrypt/client/plugins/disco_test.py b/letsencrypt/plugins/disco_test.py similarity index 91% rename from letsencrypt/client/plugins/disco_test.py rename to letsencrypt/plugins/disco_test.py index f5ea9e6ee..c90db7b7e 100644 --- a/letsencrypt/client/plugins/disco_test.py +++ b/letsencrypt/plugins/disco_test.py @@ -1,23 +1,23 @@ -"""Tests for letsencrypt.client.plugins.disco.""" +"""Tests for letsencrypt.plugins.disco.""" import pkg_resources import unittest import mock import zope.interface -from letsencrypt.client import errors -from letsencrypt.client import interfaces +from letsencrypt import errors +from letsencrypt import interfaces -from letsencrypt.client.plugins.standalone import authenticator +from letsencrypt.plugins.standalone import authenticator EP_SA = pkg_resources.EntryPoint( - "sa", "letsencrypt.client.plugins.standalone.authenticator", + "sa", "letsencrypt.plugins.standalone.authenticator", attrs=("StandaloneAuthenticator",), dist=mock.MagicMock(key="letsencrypt")) class PluginEntryPointTest(unittest.TestCase): - """Tests for letsencrypt.client.plugins.disco.PluginEntryPoint.""" + """Tests for letsencrypt.plugins.disco.PluginEntryPoint.""" def setUp(self): self.ep1 = pkg_resources.EntryPoint( @@ -31,11 +31,11 @@ class PluginEntryPointTest(unittest.TestCase): self.ep3 = pkg_resources.EntryPoint( "ep3", "a.ep3", dist=mock.MagicMock(key="p3")) - from letsencrypt.client.plugins.disco import PluginEntryPoint + from letsencrypt.plugins.disco import PluginEntryPoint self.plugin_ep = PluginEntryPoint(EP_SA) def test_entry_point_to_plugin_name(self): - from letsencrypt.client.plugins.disco import PluginEntryPoint + from letsencrypt.plugins.disco import PluginEntryPoint names = { self.ep1: "p1:ep1", @@ -97,7 +97,7 @@ class PluginEntryPointTest(unittest.TestCase): self.plugin_ep._initialized = plugin = mock.MagicMock() exceptions = zope.interface.exceptions - with mock.patch("letsencrypt.client.plugins." + with mock.patch("letsencrypt.plugins." "disco.zope.interface") as mock_zope: mock_zope.exceptions = exceptions def verify_object(iface, obj): # pylint: disable=missing-docstring @@ -148,18 +148,17 @@ class PluginEntryPointTest(unittest.TestCase): class PluginsRegistryTest(unittest.TestCase): - """Tests for letsencrypt.client.plugins.disco.PluginsRegistry.""" + """Tests for letsencrypt.plugins.disco.PluginsRegistry.""" def setUp(self): - from letsencrypt.client.plugins.disco import PluginsRegistry + from letsencrypt.plugins.disco import PluginsRegistry self.plugin_ep = mock.MagicMock(name="mock") self.plugins = {"mock": self.plugin_ep} self.reg = PluginsRegistry(self.plugins) def test_find_all(self): - from letsencrypt.client.plugins.disco import PluginsRegistry - with mock.patch("letsencrypt.client.plugins.disco" - ".pkg_resources") as mock_pkg: + from letsencrypt.plugins.disco import PluginsRegistry + with mock.patch("letsencrypt.plugins.disco.pkg_resources") as mock_pkg: mock_pkg.iter_entry_points.return_value = iter([EP_SA]) plugins = PluginsRegistry.find_all() self.assertTrue(plugins["sa"].plugin_cls diff --git a/letsencrypt/plugins/standalone/__init__.py b/letsencrypt/plugins/standalone/__init__.py new file mode 100644 index 000000000..972c484ed --- /dev/null +++ b/letsencrypt/plugins/standalone/__init__.py @@ -0,0 +1 @@ +"""Let's Encrypt Standalone Authenticator plugin.""" diff --git a/letsencrypt/client/plugins/standalone/authenticator.py b/letsencrypt/plugins/standalone/authenticator.py similarity index 98% rename from letsencrypt/client/plugins/standalone/authenticator.py rename to letsencrypt/plugins/standalone/authenticator.py index dc8b7eac7..746cd505a 100644 --- a/letsencrypt/client/plugins/standalone/authenticator.py +++ b/letsencrypt/plugins/standalone/authenticator.py @@ -14,10 +14,10 @@ import zope.interface from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import interfaces +from letsencrypt import achallenges +from letsencrypt import interfaces -from letsencrypt.client.plugins import common +from letsencrypt.plugins import common class StandaloneAuthenticator(common.Plugin): @@ -196,7 +196,7 @@ class StandaloneAuthenticator(common.Plugin): :param int port: Which TCP port to bind. :param key: The private key to use to respond to DVSNI challenge requests. - :type key: `letsencrypt.client.le_util.Key` + :type key: `letsencrypt.le_util.Key` """ signal.signal(signal.SIGINT, self.subproc_signal_handler) @@ -252,7 +252,7 @@ class StandaloneAuthenticator(common.Plugin): :param int port: The TCP port to bind. :param key: The private key to use to respond to DVSNI challenge requests. - :type key: :class:`letsencrypt.client.le_util.Key` + :type key: :class:`letsencrypt.le_util.Key` :returns: ``True`` or ``False`` to indicate success or failure creating the subprocess. diff --git a/letsencrypt/client/plugins/standalone/tests/__init__.py b/letsencrypt/plugins/standalone/tests/__init__.py similarity index 100% rename from letsencrypt/client/plugins/standalone/tests/__init__.py rename to letsencrypt/plugins/standalone/tests/__init__.py diff --git a/letsencrypt/client/plugins/standalone/tests/authenticator_test.py b/letsencrypt/plugins/standalone/tests/authenticator_test.py similarity index 84% rename from letsencrypt/client/plugins/standalone/tests/authenticator_test.py rename to letsencrypt/plugins/standalone/tests/authenticator_test.py index 230756e1d..5cfae33cc 100644 --- a/letsencrypt/client/plugins/standalone/tests/authenticator_test.py +++ b/letsencrypt/plugins/standalone/tests/authenticator_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.plugins.standalone.authenticator.""" +"""Tests for letsencrypt.plugins.standalone.authenticator.""" import os import pkg_resources import psutil @@ -12,10 +12,10 @@ import OpenSSL.SSL from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import le_util -from letsencrypt.client.tests import acme_util +from letsencrypt.tests import acme_util KEY = le_util.Key("foo", pkg_resources.resource_string( @@ -57,7 +57,7 @@ class CallableExhausted(Exception): class ChallPrefTest(unittest.TestCase): """Tests for chall_pref() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) @@ -69,7 +69,7 @@ class ChallPrefTest(unittest.TestCase): class SNICallbackTest(unittest.TestCase): """Tests for sni_callback() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) self.cert = achallenges.DVSNI( @@ -107,7 +107,7 @@ class SNICallbackTest(unittest.TestCase): class ClientSignalHandlerTest(unittest.TestCase): """Tests for client_signal_handler() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) self.authenticator.tasks = {"foononce.acme.invalid": "stuff"} @@ -136,15 +136,15 @@ class ClientSignalHandlerTest(unittest.TestCase): class SubprocSignalHandlerTest(unittest.TestCase): """Tests for subproc_signal_handler() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) self.authenticator.tasks = {"foononce.acme.invalid": "stuff"} self.authenticator.child_pid = 12345 self.authenticator.parent_pid = 23456 - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.sys.exit") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.sys.exit") def test_subproc_signal_handler(self, mock_exit, mock_kill): self.authenticator.ssl_conn = mock.MagicMock() self.authenticator.connection = mock.MagicMock() @@ -158,8 +158,8 @@ class SubprocSignalHandlerTest(unittest.TestCase): self.authenticator.parent_pid, signal.SIGUSR1) mock_exit.assert_called_once_with(0) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.sys.exit") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.sys.exit") def test_subproc_signal_handler_trouble(self, mock_exit, mock_kill): """Test attempting to shut down a non-existent connection. @@ -188,15 +188,14 @@ class SubprocSignalHandlerTest(unittest.TestCase): class AlreadyListeningTest(unittest.TestCase): """Tests for already_listening() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.psutil." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil." "net_connections") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "psutil.Process") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil.Process") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_race_condition(self, mock_get_utility, mock_process, mock_net): # This tests a race condition, or permission problem, or OS @@ -220,11 +219,10 @@ class AlreadyListeningTest(unittest.TestCase): self.assertEqual(mock_get_utility.generic_notification.call_count, 0) mock_process.assert_called_once_with(4416) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.psutil." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil." "net_connections") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "psutil.Process") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil.Process") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_not_listening(self, mock_get_utility, mock_process, mock_net): from psutil._common import sconn @@ -241,11 +239,10 @@ class AlreadyListeningTest(unittest.TestCase): self.assertEqual(mock_get_utility.generic_notification.call_count, 0) self.assertEqual(mock_process.call_count, 0) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.psutil." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil." "net_connections") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "psutil.Process") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil.Process") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_listening_ipv4(self, mock_get_utility, mock_process, mock_net): from psutil._common import sconn @@ -265,11 +262,10 @@ class AlreadyListeningTest(unittest.TestCase): self.assertEqual(mock_get_utility.call_count, 1) mock_process.assert_called_once_with(4416) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.psutil." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil." "net_connections") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "psutil.Process") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.psutil.Process") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_listening_ipv6(self, mock_get_utility, mock_process, mock_net): from psutil._common import sconn @@ -295,7 +291,7 @@ class AlreadyListeningTest(unittest.TestCase): class PerformTest(unittest.TestCase): """Tests for perform() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) @@ -369,13 +365,13 @@ class PerformTest(unittest.TestCase): class StartListenerTest(unittest.TestCase): """Tests for start_listener() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator." "Crypto.Random.atfork") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.fork") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.fork") def test_start_listener_fork_parent(self, mock_fork, mock_atfork): self.authenticator.do_parent_process = mock.Mock() self.authenticator.do_parent_process.return_value = True @@ -388,9 +384,9 @@ class StartListenerTest(unittest.TestCase): self.authenticator.do_parent_process.assert_called_once_with(1717) mock_atfork.assert_called_once_with() - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator." "Crypto.Random.atfork") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.fork") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.fork") def test_start_listener_fork_child(self, mock_fork, mock_atfork): self.authenticator.do_parent_process = mock.Mock() self.authenticator.do_child_process = mock.Mock() @@ -404,13 +400,12 @@ class StartListenerTest(unittest.TestCase): class DoParentProcessTest(unittest.TestCase): """Tests for do_parent_process() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "signal.signal") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.signal.signal") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_do_parent_process_ok(self, mock_get_utility, mock_signal): self.authenticator.subproc_state = "ready" @@ -419,9 +414,8 @@ class DoParentProcessTest(unittest.TestCase): self.assertEqual(mock_get_utility.call_count, 1) self.assertEqual(mock_signal.call_count, 3) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "signal.signal") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.signal.signal") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_do_parent_process_inuse(self, mock_get_utility, mock_signal): self.authenticator.subproc_state = "inuse" @@ -430,9 +424,8 @@ class DoParentProcessTest(unittest.TestCase): self.assertEqual(mock_get_utility.call_count, 1) self.assertEqual(mock_signal.call_count, 3) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "signal.signal") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.signal.signal") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_do_parent_process_cantbind(self, mock_get_utility, mock_signal): self.authenticator.subproc_state = "cantbind" @@ -441,9 +434,8 @@ class DoParentProcessTest(unittest.TestCase): self.assertEqual(mock_get_utility.call_count, 1) self.assertEqual(mock_signal.call_count, 3) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "signal.signal") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator.signal.signal") + @mock.patch("letsencrypt.plugins.standalone.authenticator." "zope.component.getUtility") def test_do_parent_process_timeout(self, mock_get_utility, mock_signal): # Normally times out in 5 seconds and returns False. We can @@ -458,7 +450,7 @@ class DoParentProcessTest(unittest.TestCase): class DoChildProcessTest(unittest.TestCase): """Tests for do_child_process() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) self.cert = achallenges.DVSNI( @@ -469,10 +461,9 @@ class DoChildProcessTest(unittest.TestCase): self.authenticator.tasks = {"abcdef.acme.invalid": self.cert} self.authenticator.parent_pid = 12345 - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "socket.socket") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.sys.exit") + @mock.patch("letsencrypt.plugins.standalone.authenticator.socket.socket") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.sys.exit") def test_do_child_process_cantbind1( self, mock_exit, mock_kill, mock_socket): mock_exit.side_effect = IndentationError("subprocess would exit here") @@ -491,10 +482,9 @@ class DoChildProcessTest(unittest.TestCase): mock_exit.assert_called_once_with(1) mock_kill.assert_called_once_with(12345, signal.SIGUSR2) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "socket.socket") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.sys.exit") + @mock.patch("letsencrypt.plugins.standalone.authenticator.socket.socket") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.sys.exit") def test_do_child_process_cantbind2(self, mock_exit, mock_kill, mock_socket): mock_exit.side_effect = IndentationError("subprocess would exit here") @@ -507,7 +497,7 @@ class DoChildProcessTest(unittest.TestCase): mock_exit.assert_called_once_with(1) mock_kill.assert_called_once_with(12345, signal.SIGUSR1) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator." "socket.socket") def test_do_child_process_cantbind3(self, mock_socket): """Test case where attempt to bind socket results in an unhandled @@ -521,11 +511,10 @@ class DoChildProcessTest(unittest.TestCase): self.assertRaises( socket.error, self.authenticator.do_child_process, 1717, KEY) - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." + @mock.patch("letsencrypt.plugins.standalone.authenticator." "OpenSSL.SSL.Connection") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "socket.socket") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.socket.socket") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") def test_do_child_process_success( self, mock_kill, mock_socket, mock_connection): sample_socket = mock.MagicMock() @@ -547,7 +536,7 @@ class DoChildProcessTest(unittest.TestCase): class CleanupTest(unittest.TestCase): """Tests for cleanup() method.""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import \ + from letsencrypt.plugins.standalone.authenticator import \ StandaloneAuthenticator self.authenticator = StandaloneAuthenticator(config=None, name=None) self.achall = achallenges.DVSNI( @@ -557,9 +546,8 @@ class CleanupTest(unittest.TestCase): self.authenticator.tasks = {self.achall.nonce_domain: "stuff"} self.authenticator.child_pid = 12345 - @mock.patch("letsencrypt.client.plugins.standalone.authenticator.os.kill") - @mock.patch("letsencrypt.client.plugins.standalone.authenticator." - "time.sleep") + @mock.patch("letsencrypt.plugins.standalone.authenticator.os.kill") + @mock.patch("letsencrypt.plugins.standalone.authenticator.time.sleep") def test_cleanup(self, mock_sleep, mock_kill): mock_sleep.return_value = None mock_kill.return_value = None @@ -580,7 +568,7 @@ class CleanupTest(unittest.TestCase): class MoreInfoTest(unittest.TestCase): """Tests for more_info() method. (trivially)""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import ( + from letsencrypt.plugins.standalone.authenticator import ( StandaloneAuthenticator) self.authenticator = StandaloneAuthenticator(config=None, name=None) @@ -592,7 +580,7 @@ class MoreInfoTest(unittest.TestCase): class InitTest(unittest.TestCase): """Tests for more_info() method. (trivially)""" def setUp(self): - from letsencrypt.client.plugins.standalone.authenticator import ( + from letsencrypt.plugins.standalone.authenticator import ( StandaloneAuthenticator) self.authenticator = StandaloneAuthenticator(config=None, name=None) diff --git a/letsencrypt/client/recovery_token.py b/letsencrypt/recovery_token.py similarity index 89% rename from letsencrypt/client/recovery_token.py rename to letsencrypt/recovery_token.py index 3be0471ab..c5796d581 100644 --- a/letsencrypt/client/recovery_token.py +++ b/letsencrypt/recovery_token.py @@ -6,8 +6,8 @@ import zope.component from acme import challenges -from letsencrypt.client import le_util -from letsencrypt.client import interfaces +from letsencrypt import le_util +from letsencrypt import interfaces class RecoveryToken(object): @@ -23,7 +23,7 @@ class RecoveryToken(object): """Perform the Recovery Token Challenge. :param chall: Recovery Token Challenge - :type chall: :class:`letsencrypt.client.achallenges.RecoveryToken` + :type chall: :class:`letsencrypt.achallenges.RecoveryToken` :returns: response :rtype: dict @@ -46,7 +46,7 @@ class RecoveryToken(object): """Cleanup the saved recovery token if it exists. :param chall: Recovery Token Challenge - :type chall: :class:`letsencrypt.client.achallenges.RecoveryToken` + :type chall: :class:`letsencrypt.achallenges.RecoveryToken` """ try: diff --git a/letsencrypt/client/reverter.py b/letsencrypt/reverter.py similarity index 95% rename from letsencrypt/client/reverter.py rename to letsencrypt/reverter.py index 9d739f37e..604c3999a 100644 --- a/letsencrypt/client/reverter.py +++ b/letsencrypt/reverter.py @@ -6,19 +6,19 @@ import time import zope.component -from letsencrypt.client import constants -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util +from letsencrypt import constants +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class Reverter(object): """Reverter Class - save and revert configuration checkpoints. :param config: Configuration. - :type config: :class:`letsencrypt.client.interfaces.IConfig` + :type config: :class:`letsencrypt.interfaces.IConfig` """ def __init__(self, config): @@ -30,7 +30,7 @@ class Reverter(object): This function should reinstall the users original configuration files for all saves with temporary=True - :raises letsencrypt.client.errors.LetsEncryptReverterError: when + :raises letsencrypt.errors.LetsEncryptReverterError: when unable to revert config """ @@ -50,7 +50,7 @@ class Reverter(object): :param int rollback: Number of checkpoints to reverse. A str num will be cast to an integer. So "2" is also acceptable. - :raises letsencrypt.client.errors.LetsEncryptReverterError: If + :raises letsencrypt.errors.LetsEncryptReverterError: If there is a problem with the input or if the function is unable to correctly revert the configuration checkpoints. @@ -86,7 +86,7 @@ class Reverter(object): """Displays all saved checkpoints. All checkpoints are printed by - :meth:`letsencrypt.client.interfaces.IDisplay.notification`. + :meth:`letsencrypt.interfaces.IDisplay.notification`. .. todo:: Decide on a policy for error handling, OSError IOError... @@ -162,7 +162,7 @@ class Reverter(object): :param str save_notes: notes about changes made during the save :raises IOError: If unable to open cp_dir + FILEPATHS file - :raises letsencrypt.client.errors.LetsEncryptReverterError: If + :raises letsencrypt.errors.LetsEncryptReverterError: If unable to add checkpoint """ @@ -256,7 +256,7 @@ class Reverter(object): :param set save_files: Set of files about to be saved. - :raises letsencrypt.client.errors.LetsEncryptReverterError: + :raises letsencrypt.errors.LetsEncryptReverterError: when save is attempting to overwrite a temporary file. """ @@ -292,7 +292,7 @@ class Reverter(object): a temp or permanent save. :param \*files: file paths (str) to be registered - :raises letsencrypt.client.errors.LetsEncryptReverterError: If + :raises letsencrypt.errors.LetsEncryptReverterError: If call does not contain necessary parameters or if the file creation is unable to be registered. @@ -362,7 +362,7 @@ class Reverter(object): :returns: Success :rtype: bool - :raises letsencrypt.client.errors.LetsEncryptReverterError: If + :raises letsencrypt.errors.LetsEncryptReverterError: If all files within file_list cannot be removed """ @@ -400,7 +400,7 @@ class Reverter(object): :param str title: Title describing checkpoint - :raises letsencrypt.client.errors.LetsEncryptReverterError: when the + :raises letsencrypt.errors.LetsEncryptReverterError: when the checkpoint is not able to be finalized. """ diff --git a/letsencrypt/client/revoker.py b/letsencrypt/revoker.py similarity index 95% rename from letsencrypt/client/revoker.py rename to letsencrypt/revoker.py index 31f2d85ce..a1ea27e71 100644 --- a/letsencrypt/client/revoker.py +++ b/letsencrypt/revoker.py @@ -19,12 +19,12 @@ import M2Crypto from acme import messages from acme.jose import util as jose_util -from letsencrypt.client import errors -from letsencrypt.client import le_util -from letsencrypt.client import network +from letsencrypt import errors +from letsencrypt import le_util +from letsencrypt import network -from letsencrypt.client.display import util as display_util -from letsencrypt.client.display import revocation +from letsencrypt.display import util as display_util +from letsencrypt.display import revocation class Revoker(object): @@ -33,13 +33,13 @@ class Revoker(object): .. todo:: Add a method to specify your own certificate for revocation - CLI :ivar network: Network object - :type network: :class:`letsencrypt.client.network` + :type network: :class:`letsencrypt.network` :ivar installer: Installer object - :type installer: :class:`~letsencrypt.client.interfaces.IInstaller` + :type installer: :class:`~letsencrypt.interfaces.IInstaller` :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` :ivar bool no_confirm: Whether or not to ask for confirmation for revocation @@ -61,7 +61,7 @@ class Revoker(object): """Revoke all certificates under an authorized key. :param authkey: Authorized key used in previous transactions - :type authkey: :class:`letsencrypt.client.le_util.Key` + :type authkey: :class:`letsencrypt.le_util.Key` """ certs = [] @@ -205,10 +205,10 @@ class Revoker(object): """Confirm and revoke certificates. :param certs: certs intended to be revoked - :type certs: :class:`list` of :class:`letsencrypt.client.revoker.Cert` + :type certs: :class:`list` of :class:`letsencrypt.revoker.Cert` :returns: certs successfully revoked - :rtype: :class:`list` of :class:`letsencrypt.client.revoker.Cert` + :rtype: :class:`list` of :class:`letsencrypt.revoker.Cert` """ success_list = [] @@ -233,7 +233,7 @@ class Revoker(object): """Revoke the certificate with the ACME server. :param cert: certificate to revoke - :type cert: :class:`letsencrypt.client.revoker.Cert` + :type cert: :class:`letsencrypt.revoker.Cert` :returns: TODO @@ -259,7 +259,7 @@ class Revoker(object): """Remove certificate and key. :param list cert_list: Must contain certs, each is of type - :class:`letsencrypt.client.revoker.Cert` + :class:`letsencrypt.revoker.Cert` """ # This must occur first, LIST is the official key @@ -274,7 +274,7 @@ class Revoker(object): """Remove a certificate from the LIST file. :param list cert_list: Must contain valid certs, each is of type - :class:`letsencrypt.client.revoker.Cert` + :class:`letsencrypt.revoker.Cert` """ list_path2 = tempfile.mktemp(".tmp", "LIST") @@ -319,7 +319,7 @@ class Revoker(object): :param str key_path: Path to authorized key for certificate :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` """ list_path = os.path.join(config.cert_key_backup, "LIST") diff --git a/letsencrypt/client/tests/__init__.py b/letsencrypt/tests/__init__.py similarity index 100% rename from letsencrypt/client/tests/__init__.py rename to letsencrypt/tests/__init__.py diff --git a/letsencrypt/client/tests/account_test.py b/letsencrypt/tests/account_test.py similarity index 80% rename from letsencrypt/client/tests/account_test.py rename to letsencrypt/tests/account_test.py index c99edc8ee..f0153e18c 100644 --- a/letsencrypt/client/tests/account_test.py +++ b/letsencrypt/tests/account_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.account.""" +"""Tests for letsencrypt.account.""" import logging import mock import os @@ -9,18 +9,18 @@ import unittest from acme import messages2 -from letsencrypt.client import configuration -from letsencrypt.client import errors -from letsencrypt.client import le_util +from letsencrypt import configuration +from letsencrypt import errors +from letsencrypt import le_util -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class AccountTest(unittest.TestCase): - """Tests letsencrypt.client.account.Account.""" + """Tests letsencrypt.account.Account.""" def setUp(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account logging.disable(logging.CRITICAL) @@ -55,10 +55,10 @@ class AccountTest(unittest.TestCase): shutil.rmtree(self.accounts_dir) logging.disable(logging.NOTSET) - @mock.patch("letsencrypt.client.account.zope.component.getUtility") - @mock.patch("letsencrypt.client.account.crypto_util.init_save_key") + @mock.patch("letsencrypt.account.zope.component.getUtility") + @mock.patch("letsencrypt.account.crypto_util.init_save_key") def test_prompts(self, mock_key, mock_util): - from letsencrypt.client.account import Account + from letsencrypt.account import Account mock_util().input.return_value = (display_util.OK, self.email) mock_key.return_value = self.key @@ -68,10 +68,10 @@ class AccountTest(unittest.TestCase): self.assertEqual(acc.key, self.key) self.assertEqual(acc.config, self.config) - @mock.patch("letsencrypt.client.account.zope.component.getUtility") - @mock.patch("letsencrypt.client.account.Account.from_email") + @mock.patch("letsencrypt.account.zope.component.getUtility") + @mock.patch("letsencrypt.account.Account.from_email") def test_prompts_bad_email(self, mock_from_email, mock_util): - from letsencrypt.client.account import Account + from letsencrypt.account import Account mock_from_email.side_effect = (errors.LetsEncryptClientError, "acc") mock_util().input.return_value = (display_util.OK, self.email) @@ -79,10 +79,10 @@ class AccountTest(unittest.TestCase): self.assertEqual(Account.from_prompts(self.config), "acc") - @mock.patch("letsencrypt.client.account.zope.component.getUtility") - @mock.patch("letsencrypt.client.account.crypto_util.init_save_key") + @mock.patch("letsencrypt.account.zope.component.getUtility") + @mock.patch("letsencrypt.account.crypto_util.init_save_key") def test_prompts_empty_email(self, mock_key, mock_util): - from letsencrypt.client.account import Account + from letsencrypt.account import Account mock_util().input.return_value = (display_util.OK, "") acc = Account.from_prompts(self.config) @@ -91,22 +91,22 @@ class AccountTest(unittest.TestCase): mock_key.assert_called_once_with( mock.ANY, mock.ANY, acc._get_config_filename(None)) - @mock.patch("letsencrypt.client.account.zope.component.getUtility") + @mock.patch("letsencrypt.account.zope.component.getUtility") def test_prompts_cancel(self, mock_util): - from letsencrypt.client.account import Account + from letsencrypt.account import Account mock_util().input.return_value = (display_util.CANCEL, "") self.assertTrue(Account.from_prompts(self.config) is None) def test_from_email(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account self.assertRaises(errors.LetsEncryptClientError, Account.from_email, self.config, "not_valid...email") def test_save_from_existing_account(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account self.test_account.save() acc = Account.from_existing_account(self.config, self.email) @@ -123,7 +123,7 @@ class AccountTest(unittest.TestCase): self.assertEqual(self.test_account.recovery_token, "recovery_token") def test_partial_properties(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account partial = Account(self.config, self.key) @@ -133,7 +133,7 @@ class AccountTest(unittest.TestCase): self.assertTrue(partial.recovery_token is None) def test_partial_account_default(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account partial = Account(self.config, self.key) partial.save() @@ -146,7 +146,7 @@ class AccountTest(unittest.TestCase): self.assertEqual(partial.regr, acc.regr) def test_get_accounts(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account accs = Account.get_accounts(self.config) self.assertFalse(accs) @@ -162,13 +162,13 @@ class AccountTest(unittest.TestCase): self.assertEqual(len(accs), 2) def test_get_accounts_no_accounts(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account self.assertEqual(Account.get_accounts( mock.Mock(accounts_dir="non-existant")), []) def test_failed_existing_account(self): - from letsencrypt.client.account import Account + from letsencrypt.account import Account self.assertRaises( errors.LetsEncryptClientError, @@ -185,7 +185,7 @@ class SafeEmailTest(unittest.TestCase): @classmethod def _call(cls, addr): - from letsencrypt.client.account import Account + from letsencrypt.account import Account return Account.safe_email(addr) def test_valid_emails(self): diff --git a/letsencrypt/client/tests/achallenges_test.py b/letsencrypt/tests/achallenges_test.py similarity index 83% rename from letsencrypt/client/tests/achallenges_test.py rename to letsencrypt/tests/achallenges_test.py index 476ff7cab..c22ff6227 100644 --- a/letsencrypt/client/tests/achallenges_test.py +++ b/letsencrypt/tests/achallenges_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.achallenges.""" +"""Tests for letsencrypt.achallenges.""" import os import pkg_resources import re @@ -7,12 +7,12 @@ import unittest import M2Crypto from acme import challenges -from letsencrypt.client import le_util -from letsencrypt.client.tests import acme_util +from letsencrypt import le_util +from letsencrypt.tests import acme_util class DVSNITest(unittest.TestCase): - """Tests for letsencrypt.client.achallenges.DVSNI.""" + """Tests for letsencrypt.achallenges.DVSNI.""" def setUp(self): self.chall = acme_util.chall_to_challb( @@ -21,7 +21,7 @@ class DVSNITest(unittest.TestCase): key = le_util.Key("path", pkg_resources.resource_string( "acme.jose", os.path.join("testdata", "rsa512_key.pem"))) - from letsencrypt.client.achallenges import DVSNI + from letsencrypt.achallenges import DVSNI self.achall = DVSNI(challb=self.chall, domain="example.com", key=key) def test_proxy(self): diff --git a/letsencrypt/client/tests/acme_util.py b/letsencrypt/tests/acme_util.py similarity index 100% rename from letsencrypt/client/tests/acme_util.py rename to letsencrypt/tests/acme_util.py diff --git a/letsencrypt/client/tests/auth_handler_test.py b/letsencrypt/tests/auth_handler_test.py similarity index 92% rename from letsencrypt/client/tests/auth_handler_test.py rename to letsencrypt/tests/auth_handler_test.py index b03f25735..effc09990 100644 --- a/letsencrypt/client/tests/auth_handler_test.py +++ b/letsencrypt/tests/auth_handler_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.auth_handler.""" +"""Tests for letsencrypt.auth_handler.""" import functools import logging import unittest @@ -8,11 +8,11 @@ import mock from acme import challenges from acme import messages2 -from letsencrypt.client import errors -from letsencrypt.client import le_util -from letsencrypt.client import network2 +from letsencrypt import errors +from letsencrypt import le_util +from letsencrypt import network2 -from letsencrypt.client.tests import acme_util +from letsencrypt.tests import acme_util TRANSLATE = { @@ -29,7 +29,7 @@ class ChallengeFactoryTest(unittest.TestCase): # pylint: disable=protected-access def setUp(self): - from letsencrypt.client.auth_handler import AuthHandler + from letsencrypt.auth_handler import AuthHandler # Account is mocked... self.handler = AuthHandler( @@ -73,7 +73,7 @@ class GetAuthorizationsTest(unittest.TestCase): """ def setUp(self): - from letsencrypt.client.auth_handler import AuthHandler + from letsencrypt.auth_handler import AuthHandler self.mock_dv_auth = mock.MagicMock(name="ApacheConfigurator") self.mock_cont_auth = mock.MagicMock(name="ContinuityAuthenticator") @@ -97,7 +97,7 @@ class GetAuthorizationsTest(unittest.TestCase): def tearDown(self): logging.disable(logging.NOTSET) - @mock.patch("letsencrypt.client.auth_handler.AuthHandler._poll_challenges") + @mock.patch("letsencrypt.auth_handler.AuthHandler._poll_challenges") def test_name1_dvsni1(self, mock_poll): self.mock_net.request_domain_challenges.side_effect = functools.partial( gen_dom_authzr, challs=acme_util.DV_CHALLENGES) @@ -121,7 +121,7 @@ class GetAuthorizationsTest(unittest.TestCase): self.assertEqual(len(authzr), 1) - @mock.patch("letsencrypt.client.auth_handler.AuthHandler._poll_challenges") + @mock.patch("letsencrypt.auth_handler.AuthHandler._poll_challenges") def test_name3_dvsni3_rectok_3(self, mock_poll): self.mock_net.request_domain_challenges.side_effect = functools.partial( gen_dom_authzr, challs=acme_util.CHALLENGES) @@ -180,8 +180,8 @@ class PollChallengesTest(unittest.TestCase): """Test poll challenges.""" def setUp(self): - from letsencrypt.client.auth_handler import challb_to_achall - from letsencrypt.client.auth_handler import AuthHandler + from letsencrypt.auth_handler import challb_to_achall + from letsencrypt.auth_handler import AuthHandler # Account and network are mocked... self.mock_net = mock.MagicMock() @@ -207,7 +207,7 @@ class PollChallengesTest(unittest.TestCase): challb_to_achall(challb, "dummy_key", dom) for challb in self.handler.authzr[dom].body.challenges] - @mock.patch("letsencrypt.client.auth_handler.time") + @mock.patch("letsencrypt.auth_handler.time") def test_poll_challenges(self, unused_mock_time): self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid self.handler._poll_challenges(self.chall_update, False) @@ -215,7 +215,7 @@ class PollChallengesTest(unittest.TestCase): for authzr in self.handler.authzr.values(): self.assertEqual(authzr.body.status, messages2.STATUS_VALID) - @mock.patch("letsencrypt.client.auth_handler.time") + @mock.patch("letsencrypt.auth_handler.time") def test_poll_challenges_failure_best_effort(self, unused_mock_time): self.mock_net.poll.side_effect = self._mock_poll_solve_one_invalid self.handler._poll_challenges(self.chall_update, True) @@ -223,16 +223,16 @@ class PollChallengesTest(unittest.TestCase): for authzr in self.handler.authzr.values(): self.assertEqual(authzr.body.status, messages2.STATUS_PENDING) - @mock.patch("letsencrypt.client.auth_handler.time") + @mock.patch("letsencrypt.auth_handler.time") def test_poll_challenges_failure(self, unused_mock_time): self.mock_net.poll.side_effect = self._mock_poll_solve_one_invalid self.assertRaises(errors.AuthorizationError, self.handler._poll_challenges, self.chall_update, False) - @mock.patch("letsencrypt.client.auth_handler.time") + @mock.patch("letsencrypt.auth_handler.time") def test_unable_to_find_challenge_status(self, unused_mock_time): - from letsencrypt.client.auth_handler import challb_to_achall + from letsencrypt.auth_handler import challb_to_achall self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid self.chall_update[self.doms[0]].append( challb_to_achall(acme_util.RECOVERY_CONTACT_P, "key", self.doms[0])) @@ -292,7 +292,7 @@ class PollChallengesTest(unittest.TestCase): return (new_authzr, "response") class GenChallengePathTest(unittest.TestCase): - """Tests for letsencrypt.client.auth_handler.gen_challenge_path. + """Tests for letsencrypt.auth_handler.gen_challenge_path. .. todo:: Add more tests for dumb_path... depending on what we want to do. @@ -305,7 +305,7 @@ class GenChallengePathTest(unittest.TestCase): @classmethod def _call(cls, challbs, preferences, combinations): - from letsencrypt.client.auth_handler import gen_challenge_path + from letsencrypt.auth_handler import gen_challenge_path return gen_challenge_path(challbs, preferences, combinations) def test_common_case(self): @@ -363,7 +363,7 @@ class GenChallengePathTest(unittest.TestCase): class MutuallyExclusiveTest(unittest.TestCase): - """Tests for letsencrypt.client.auth_handler.mutually_exclusive.""" + """Tests for letsencrypt.auth_handler.mutually_exclusive.""" # pylint: disable=invalid-name,missing-docstring,too-few-public-methods class A(object): @@ -380,7 +380,7 @@ class MutuallyExclusiveTest(unittest.TestCase): @classmethod def _call(cls, chall1, chall2, different=False): - from letsencrypt.client.auth_handler import mutually_exclusive + from letsencrypt.auth_handler import mutually_exclusive return mutually_exclusive(chall1, chall2, groups=frozenset([ frozenset([cls.A, cls.B]), frozenset([cls.A, cls.C]), ]), different=different) @@ -407,11 +407,11 @@ class MutuallyExclusiveTest(unittest.TestCase): class IsPreferredTest(unittest.TestCase): - """Tests for letsencrypt.client.auth_handler.is_preferred.""" + """Tests for letsencrypt.auth_handler.is_preferred.""" @classmethod def _call(cls, chall, satisfied): - from letsencrypt.client.auth_handler import is_preferred + from letsencrypt.auth_handler import is_preferred return is_preferred(chall, satisfied, exclusive_groups=frozenset([ frozenset([challenges.DVSNI, challenges.SimpleHTTPS]), frozenset([challenges.DNS, challenges.SimpleHTTPS]), diff --git a/letsencrypt/client/tests/cli_test.py b/letsencrypt/tests/cli_test.py similarity index 77% rename from letsencrypt/client/tests/cli_test.py rename to letsencrypt/tests/cli_test.py index bd25a9792..fc6e493ea 100644 --- a/letsencrypt/client/tests/cli_test.py +++ b/letsencrypt/tests/cli_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.cli.""" +"""Tests for letsencrypt.cli.""" import itertools import unittest @@ -10,10 +10,10 @@ class CLITest(unittest.TestCase): @classmethod def _call(cls, args): - from letsencrypt.client import cli + from letsencrypt import cli args = ['--text'] + args - with mock.patch("letsencrypt.client.cli.sys.stdout") as stdout: - with mock.patch("letsencrypt.client.cli.sys.stderr") as stderr: + with mock.patch("letsencrypt.cli.sys.stdout") as stdout: + with mock.patch("letsencrypt.cli.sys.stderr") as stderr: ret = cli.main(args) return ret, stdout, stderr diff --git a/letsencrypt/client/tests/client_test.py b/letsencrypt/tests/client_test.py similarity index 66% rename from letsencrypt/client/tests/client_test.py rename to letsencrypt/tests/client_test.py index 52fc1be94..58e95e5cf 100644 --- a/letsencrypt/client/tests/client_test.py +++ b/letsencrypt/tests/client_test.py @@ -1,4 +1,4 @@ -"""letsencrypt.client.client.py tests.""" +"""Tests for letsencrypt.client.""" import os import unittest import shutil @@ -6,9 +6,9 @@ import tempfile import mock -from letsencrypt.client import account -from letsencrypt.client import configuration -from letsencrypt.client import le_util +from letsencrypt import account +from letsencrypt import configuration +from letsencrypt import le_util class DetermineAccountTest(unittest.TestCase): @@ -25,11 +25,11 @@ class DetermineAccountTest(unittest.TestCase): def tearDown(self): shutil.rmtree(self.accounts_dir) - @mock.patch("letsencrypt.client.client.account.Account.from_prompts") - @mock.patch("letsencrypt.client.client.display_ops.choose_account") + @mock.patch("letsencrypt.account.Account.from_prompts") + @mock.patch("letsencrypt.client.display_ops.choose_account") def determine_account(self, mock_op, mock_prompt): """Test determine account""" - from letsencrypt.client import client + from letsencrypt import client key = le_util.Key("file", "pem") test_acc = account.Account(self.config, key, "email1@gmail.com") @@ -60,24 +60,20 @@ class RollbackTest(unittest.TestCase): self.m_install = mock.MagicMock(spec=ApacheConfigurator) @classmethod - def _call(cls, checkpoints): - from letsencrypt.client.client import rollback - rollback(None, checkpoints, {}, mock.MagicMock()) - - @mock.patch("letsencrypt.client.client.display_ops.pick_installer") - def test_no_problems(self, mock_pick_installer): - mock_pick_installer.side_effect = self.m_install - - self._call(1) + def _call(cls, checkpoints, side_effect): + from letsencrypt.client import rollback + with mock.patch("letsencrypt.client" + ".display_ops.pick_installer") as mock_pick_installer: + mock_pick_installer.side_effect = side_effect + rollback(None, checkpoints, {}, mock.MagicMock()) + def test_no_problems(self): + self._call(1, self.m_install) self.assertEqual(self.m_install().rollback_checkpoints.call_count, 1) self.assertEqual(self.m_install().restart.call_count, 1) - @mock.patch("letsencrypt.client.client.display_ops.pick_installer") - def test_no_installer(self, mock_pick_installer): - mock_pick_installer.return_value = None - self._call(1) - # Just make sure no exceptions are raised + def test_no_installer(self): + self._call(1, None) # Just make sure no exceptions are raised if __name__ == "__main__": diff --git a/letsencrypt/client/tests/configuration_test.py b/letsencrypt/tests/configuration_test.py similarity index 86% rename from letsencrypt/client/tests/configuration_test.py rename to letsencrypt/tests/configuration_test.py index cbbcd57ba..ddfc9de23 100644 --- a/letsencrypt/client/tests/configuration_test.py +++ b/letsencrypt/tests/configuration_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.configuration.""" +"""Tests for letsencrypt.configuration.""" import os import unittest @@ -6,10 +6,10 @@ import mock class NamespaceConfigTest(unittest.TestCase): - """Tests for letsencrypt.client.configuration.NamespaceConfig.""" + """Tests for letsencrypt.configuration.NamespaceConfig.""" def setUp(self): - from letsencrypt.client.configuration import NamespaceConfig + from letsencrypt.configuration import NamespaceConfig namespace = mock.MagicMock( config_dir='/tmp/config', work_dir='/tmp/foo', foo='bar', server='acme-server.org:443/new') @@ -27,7 +27,7 @@ class NamespaceConfigTest(unittest.TestCase): self.assertEqual( self.config.server_url, 'https://acme-server.org:443/new') - @mock.patch('letsencrypt.client.configuration.constants') + @mock.patch('letsencrypt.configuration.constants') def test_dynamic_dirs(self, constants): constants.TEMP_CHECKPOINT_DIR = 't' constants.IN_PROGRESS_DIR = '../p' diff --git a/letsencrypt/client/tests/continuity_auth_test.py b/letsencrypt/tests/continuity_auth_test.py similarity index 91% rename from letsencrypt/client/tests/continuity_auth_test.py rename to letsencrypt/tests/continuity_auth_test.py index b8b5e7402..715651f19 100644 --- a/letsencrypt/client/tests/continuity_auth_test.py +++ b/letsencrypt/tests/continuity_auth_test.py @@ -5,15 +5,15 @@ import mock from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import errors +from letsencrypt import achallenges +from letsencrypt import errors class PerformTest(unittest.TestCase): """Test client perform function.""" def setUp(self): - from letsencrypt.client.continuity_auth import ContinuityAuthenticator + from letsencrypt.continuity_auth import ContinuityAuthenticator self.auth = ContinuityAuthenticator( mock.MagicMock(server="demo_server.org")) @@ -50,7 +50,7 @@ class CleanupTest(unittest.TestCase): """Test the Authenticator cleanup function.""" def setUp(self): - from letsencrypt.client.continuity_auth import ContinuityAuthenticator + from letsencrypt.continuity_auth import ContinuityAuthenticator self.auth = ContinuityAuthenticator( mock.MagicMock(server="demo_server.org")) diff --git a/letsencrypt/client/tests/crypto_util_test.py b/letsencrypt/tests/crypto_util_test.py similarity index 75% rename from letsencrypt/client/tests/crypto_util_test.py rename to letsencrypt/tests/crypto_util_test.py index f0c234598..91b3f1c85 100644 --- a/letsencrypt/client/tests/crypto_util_test.py +++ b/letsencrypt/tests/crypto_util_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.crypto_util.""" +"""Tests for letsencrypt.crypto_util.""" import logging import os import pkg_resources @@ -17,7 +17,7 @@ RSA512_KEY = pkg_resources.resource_string( class InitSaveKeyTest(unittest.TestCase): - """Tests for letsencrypt.client.crypto_util.init_save_key.""" + """Tests for letsencrypt.crypto_util.init_save_key.""" def setUp(self): logging.disable(logging.CRITICAL) self.key_dir = tempfile.mkdtemp('key_dir') @@ -28,24 +28,24 @@ class InitSaveKeyTest(unittest.TestCase): @classmethod def _call(cls, key_size, key_dir): - from letsencrypt.client.crypto_util import init_save_key + from letsencrypt.crypto_util import init_save_key return init_save_key(key_size, key_dir, 'key-letsencrypt.pem') - @mock.patch('letsencrypt.client.crypto_util.make_key') + @mock.patch('letsencrypt.crypto_util.make_key') def test_success(self, mock_make): mock_make.return_value = 'key_pem' key = self._call(1024, self.key_dir) self.assertEqual(key.pem, 'key_pem') self.assertTrue('key-letsencrypt.pem' in key.file) - @mock.patch('letsencrypt.client.crypto_util.make_key') + @mock.patch('letsencrypt.crypto_util.make_key') def test_key_failure(self, mock_make): mock_make.side_effect = ValueError self.assertRaises(ValueError, self._call, 431, self.key_dir) class InitSaveCSRTest(unittest.TestCase): - """Tests for letsencrypt.client.crypto_util.init_save_csr.""" + """Tests for letsencrypt.crypto_util.init_save_csr.""" def setUp(self): self.csr_dir = tempfile.mkdtemp('csr_dir') @@ -53,10 +53,10 @@ class InitSaveCSRTest(unittest.TestCase): def tearDown(self): shutil.rmtree(self.csr_dir) - @mock.patch('letsencrypt.client.crypto_util.make_csr') - @mock.patch('letsencrypt.client.crypto_util.le_util.make_or_verify_dir') + @mock.patch('letsencrypt.crypto_util.make_csr') + @mock.patch('letsencrypt.crypto_util.le_util.make_or_verify_dir') def test_it(self, unused_mock_verify, mock_csr): - from letsencrypt.client.crypto_util import init_save_csr + from letsencrypt.crypto_util import init_save_csr mock_csr.return_value = ('csr_pem', 'csr_der') @@ -68,11 +68,11 @@ class InitSaveCSRTest(unittest.TestCase): self.assertTrue('csr-letsencrypt.pem' in csr.file) class ValidCSRTest(unittest.TestCase): - """Tests for letsencrypt.client.crypto_util.valid_csr.""" + """Tests for letsencrypt.crypto_util.valid_csr.""" @classmethod def _call(cls, csr): - from letsencrypt.client.crypto_util import valid_csr + from letsencrypt.crypto_util import valid_csr return valid_csr(csr) def _call_testdata(self, name): @@ -99,11 +99,11 @@ class ValidCSRTest(unittest.TestCase): class CSRMatchesPubkeyTest(unittest.TestCase): - """Tests for letsencrypt.client.crypto_util.csr_matches_pubkey.""" + """Tests for letsencrypt.crypto_util.csr_matches_pubkey.""" @classmethod def _call_testdata(cls, name, privkey): - from letsencrypt.client.crypto_util import csr_matches_pubkey + from letsencrypt.crypto_util import csr_matches_pubkey return csr_matches_pubkey(pkg_resources.resource_string( __name__, os.path.join('testdata', name)), privkey) @@ -115,20 +115,20 @@ class CSRMatchesPubkeyTest(unittest.TestCase): class MakeKeyTest(unittest.TestCase): # pylint: disable=too-few-public-methods - """Tests for letsencrypt.client.crypto_util.make_key.""" + """Tests for letsencrypt.crypto_util.make_key.""" def test_it(self): # pylint: disable=no-self-use - from letsencrypt.client.crypto_util import make_key + from letsencrypt.crypto_util import make_key # Do not test larger keys as it takes too long. M2Crypto.RSA.load_key_string(make_key(1024)) class ValidPrivkeyTest(unittest.TestCase): - """Tests for letsencrypt.client.crypto_util.valid_privkey.""" + """Tests for letsencrypt.crypto_util.valid_privkey.""" @classmethod def _call(cls, privkey): - from letsencrypt.client.crypto_util import valid_privkey + from letsencrypt.crypto_util import valid_privkey return valid_privkey(privkey) def test_valid_true(self): @@ -143,10 +143,10 @@ class ValidPrivkeyTest(unittest.TestCase): class MakeSSCertTest(unittest.TestCase): # pylint: disable=too-few-public-methods - """Tests for letsencrypt.client.crypto_util.make_ss_cert.""" + """Tests for letsencrypt.crypto_util.make_ss_cert.""" def test_it(self): # pylint: disable=no-self-use - from letsencrypt.client.crypto_util import make_ss_cert + from letsencrypt.crypto_util import make_ss_cert make_ss_cert(RSA512_KEY, ['example.com', 'www.example.com']) diff --git a/letsencrypt/client/tests/display/__init__.py b/letsencrypt/tests/display/__init__.py similarity index 100% rename from letsencrypt/client/tests/display/__init__.py rename to letsencrypt/tests/display/__init__.py diff --git a/letsencrypt/client/tests/display/enhancements_test.py b/letsencrypt/tests/display/enhancements_test.py similarity index 71% rename from letsencrypt/client/tests/display/enhancements_test.py rename to letsencrypt/tests/display/enhancements_test.py index a7fb7f246..648eaecb1 100644 --- a/letsencrypt/client/tests/display/enhancements_test.py +++ b/letsencrypt/tests/display/enhancements_test.py @@ -4,8 +4,8 @@ import unittest import mock -from letsencrypt.client import errors -from letsencrypt.client.display import util as display_util +from letsencrypt import errors +from letsencrypt.display import util as display_util class AskTest(unittest.TestCase): @@ -18,10 +18,10 @@ class AskTest(unittest.TestCase): @classmethod def _call(cls, enhancement): - from letsencrypt.client.display.enhancements import ask + from letsencrypt.display.enhancements import ask return ask(enhancement) - @mock.patch("letsencrypt.client.display.enhancements.util") + @mock.patch("letsencrypt.display.enhancements.util") def test_redirect(self, mock_util): mock_util().menu.return_value = (display_util.OK, 1) self.assertTrue(self._call("redirect")) @@ -35,20 +35,20 @@ class RedirectTest(unittest.TestCase): """Test the redirect_by_default method.""" @classmethod def _call(cls): - from letsencrypt.client.display.enhancements import redirect_by_default + from letsencrypt.display.enhancements import redirect_by_default return redirect_by_default() - @mock.patch("letsencrypt.client.display.enhancements.util") + @mock.patch("letsencrypt.display.enhancements.util") def test_secure(self, mock_util): mock_util().menu.return_value = (display_util.OK, 1) self.assertTrue(self._call()) - @mock.patch("letsencrypt.client.display.enhancements.util") + @mock.patch("letsencrypt.display.enhancements.util") def test_cancel(self, mock_util): mock_util().menu.return_value = (display_util.CANCEL, 1) self.assertFalse(self._call()) - @mock.patch("letsencrypt.client.display.enhancements.util") + @mock.patch("letsencrypt.display.enhancements.util") def test_easy(self, mock_util): mock_util().menu.return_value = (display_util.OK, 0) self.assertFalse(self._call()) diff --git a/letsencrypt/client/tests/display/ops_test.py b/letsencrypt/tests/display/ops_test.py similarity index 81% rename from letsencrypt/client/tests/display/ops_test.py rename to letsencrypt/tests/display/ops_test.py index 7c5c1f74f..d71237676 100644 --- a/letsencrypt/client/tests/display/ops_test.py +++ b/letsencrypt/tests/display/ops_test.py @@ -1,4 +1,4 @@ -"""Test letsencrypt.client.display.ops.""" +"""Test letsencrypt.display.ops.""" import os import sys import tempfile @@ -7,15 +7,15 @@ import unittest import mock import zope.component -from letsencrypt.client import account -from letsencrypt.client import interfaces -from letsencrypt.client import le_util +from letsencrypt import account +from letsencrypt import interfaces +from letsencrypt import le_util -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class ChoosePluginTest(unittest.TestCase): - """Tests for letsencrypt.client.display.ops.choose_plugin.""" + """Tests for letsencrypt.display.ops.choose_plugin.""" def setUp(self): zope.component.provideUtility(display_util.FileDisplay(sys.stdout)) @@ -30,15 +30,15 @@ class ChoosePluginTest(unittest.TestCase): ] def _call(self): - from letsencrypt.client.display.ops import choose_plugin + from letsencrypt.display.ops import choose_plugin return choose_plugin(self.plugins, "Question?") - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_successful_choice(self, mock_util): mock_util().menu.return_value = (display_util.OK, 0) self.assertEqual(self.mock_apache, self._call()) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_more_info(self, mock_util): mock_util().menu.side_effect = [ (display_util.HELP, 0), @@ -49,14 +49,14 @@ class ChoosePluginTest(unittest.TestCase): self.assertEqual(self.mock_stand, self._call()) self.assertEqual(mock_util().notification.call_count, 2) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_no_choice(self, mock_util): mock_util().menu.return_value = (display_util.CANCEL, 0) self.assertTrue(self._call() is None) class PickPluginTest(unittest.TestCase): - """Tests for letsencrypt.client.display.ops.pick_plugin.""" + """Tests for letsencrypt.display.ops.pick_plugin.""" def setUp(self): self.config = mock.Mock() @@ -66,7 +66,7 @@ class PickPluginTest(unittest.TestCase): self.ifaces = [] def _call(self): - from letsencrypt.client.display.ops import pick_plugin + from letsencrypt.display.ops import pick_plugin return pick_plugin(self.config, self.default, self.reg, self.question, self.ifaces) @@ -95,8 +95,7 @@ class PickPluginTest(unittest.TestCase): "bar": plugin_ep, "baz": plugin_ep, } - with mock.patch("letsencrypt.client.display" - ".ops.choose_plugin") as mock_choose: + with mock.patch("letsencrypt.display.ops.choose_plugin") as mock_choose: mock_choose.return_value = plugin_ep self.assertEqual("foo", self._call()) mock_choose.assert_called_once_with( @@ -108,36 +107,35 @@ class PickPluginTest(unittest.TestCase): "baz": None, } - with mock.patch("letsencrypt.client.display" - ".ops.choose_plugin") as mock_choose: + with mock.patch("letsencrypt.display.ops.choose_plugin") as mock_choose: mock_choose.return_value = None self.assertTrue(self._call() is None) class ConveniencePickPluginTest(unittest.TestCase): - """Tests for letsencrypt.client.display.ops.pick_*.""" + """Tests for letsencrypt.display.ops.pick_*.""" def _test(self, fun, ifaces): config = mock.Mock() default = mock.Mock() plugins = mock.Mock() - with mock.patch("letsencrypt.client.display.ops.pick_plugin") as mock_p: + with mock.patch("letsencrypt.display.ops.pick_plugin") as mock_p: mock_p.return_value = "foo" self.assertEqual("foo", fun(config, default, plugins, "Question?")) mock_p.assert_called_once_with( config, default, plugins, "Question?", ifaces) def test_authenticator(self): - from letsencrypt.client.display.ops import pick_authenticator + from letsencrypt.display.ops import pick_authenticator self._test(pick_authenticator, (interfaces.IAuthenticator,)) def test_installer(self): - from letsencrypt.client.display.ops import pick_installer + from letsencrypt.display.ops import pick_installer self._test(pick_installer, (interfaces.IInstaller,)) def test_configurator(self): - from letsencrypt.client.display.ops import pick_configurator + from letsencrypt.display.ops import pick_configurator self._test(pick_configurator, ( interfaces.IAuthenticator, interfaces.IInstaller)) @@ -165,20 +163,20 @@ class ChooseAccountTest(unittest.TestCase): @classmethod def _call(cls, accounts): - from letsencrypt.client.display import ops + from letsencrypt.display import ops return ops.choose_account(accounts) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_one(self, mock_util): mock_util().menu.return_value = (display_util.OK, 0) self.assertEqual(self._call([self.acc1]), self.acc1) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_two(self, mock_util): mock_util().menu.return_value = (display_util.OK, 1) self.assertEqual(self._call([self.acc1, self.acc2]), self.acc2) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_cancel(self, mock_util): mock_util().menu.return_value = (display_util.CANCEL, 1) self.assertTrue(self._call([self.acc1, self.acc2]) is None) @@ -191,7 +189,7 @@ class GenHttpsNamesTest(unittest.TestCase): @classmethod def _call(cls, domains): - from letsencrypt.client.display.ops import _gen_https_names + from letsencrypt.display.ops import _gen_https_names return _gen_https_names(domains) def test_zero(self): @@ -239,20 +237,20 @@ class ChooseNamesTest(unittest.TestCase): @classmethod def _call(cls, installer): - from letsencrypt.client.display.ops import choose_names + from letsencrypt.display.ops import choose_names return choose_names(installer) - @mock.patch("letsencrypt.client.display.ops._choose_names_manually") + @mock.patch("letsencrypt.display.ops._choose_names_manually") def test_no_installer(self, mock_manual): self._call(None) self.assertEqual(mock_manual.call_count, 1) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_no_installer_cancel(self, mock_util): mock_util().input.return_value = (display_util.CANCEL, []) self.assertEqual(self._call(None), []) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_no_names_choose(self, mock_util): self.mock_install().get_all_names.return_value = set() mock_util().yesno.return_value = True @@ -263,14 +261,14 @@ class ChooseNamesTest(unittest.TestCase): self.assertEqual(mock_util().input.call_count, 1) self.assertEqual(actual_doms, [domain]) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_no_names_quit(self, mock_util): self.mock_install().get_all_names.return_value = set() mock_util().yesno.return_value = False self.assertEqual(self._call(self.mock_install), []) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_filter_names_valid_return(self, mock_util): self.mock_install.get_all_names.return_value = set(["example.com"]) mock_util().checklist.return_value = (display_util.OK, ["example.com"]) @@ -279,14 +277,14 @@ class ChooseNamesTest(unittest.TestCase): self.assertEqual(names, ["example.com"]) self.assertEqual(mock_util().checklist.call_count, 1) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_filter_names_nothing_selected(self, mock_util): self.mock_install.get_all_names.return_value = set(["example.com"]) mock_util().checklist.return_value = (display_util.OK, []) self.assertEqual(self._call(self.mock_install), []) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_filter_names_cancel(self, mock_util): self.mock_install.get_all_names.return_value = set(["example.com"]) mock_util().checklist.return_value = ( @@ -300,10 +298,10 @@ class SuccessInstallationTest(unittest.TestCase): """Test the success installation message.""" @classmethod def _call(cls, names): - from letsencrypt.client.display.ops import success_installation + from letsencrypt.display.ops import success_installation success_installation(names) - @mock.patch("letsencrypt.client.display.ops.util") + @mock.patch("letsencrypt.display.ops.util") def test_success_installation(self, mock_util): mock_util().notification.return_value = None names = ["example.com", "abc.com"] diff --git a/letsencrypt/client/tests/display/revocation_test.py b/letsencrypt/tests/display/revocation_test.py similarity index 68% rename from letsencrypt/client/tests/display/revocation_test.py rename to letsencrypt/tests/display/revocation_test.py index 557648d9d..f07c2cbfd 100644 --- a/letsencrypt/client/tests/display/revocation_test.py +++ b/letsencrypt/tests/display/revocation_test.py @@ -1,4 +1,4 @@ -"""Test :mod:`letsencrypt.client.display.revocation`.""" +"""Test :mod:`letsencrypt.display.revocation`.""" import os import pkg_resources import sys @@ -7,13 +7,13 @@ import unittest import mock import zope.component -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class DisplayCertsTest(unittest.TestCase): def setUp(self): - from letsencrypt.client.revoker import Cert - base_package = "letsencrypt.client.tests" + from letsencrypt.revoker import Cert + base_package = "letsencrypt.tests" self.cert0 = Cert(pkg_resources.resource_filename( base_package, os.path.join("testdata", "cert.pem"))) self.cert1 = Cert(pkg_resources.resource_filename( @@ -25,10 +25,10 @@ class DisplayCertsTest(unittest.TestCase): @classmethod def _call(cls, certs): - from letsencrypt.client.display.revocation import display_certs + from letsencrypt.display.revocation import display_certs return display_certs(certs) - @mock.patch("letsencrypt.client.display.revocation.util") + @mock.patch("letsencrypt.display.revocation.util") def test_revocation(self, mock_util): mock_util().menu.return_value = (display_util.OK, 0) @@ -37,7 +37,7 @@ class DisplayCertsTest(unittest.TestCase): self.assertEqual(display_util.OK, code) self.assertEqual(self.certs[choice], self.cert0) - @mock.patch("letsencrypt.client.display.revocation.util") + @mock.patch("letsencrypt.display.revocation.util") def test_cancel(self, mock_util): mock_util().menu.return_value = (display_util.CANCEL, -1) @@ -49,10 +49,10 @@ class MoreInfoCertTest(unittest.TestCase): # pylint: disable=too-few-public-methods @classmethod def _call(cls, cert): - from letsencrypt.client.display.revocation import more_info_cert + from letsencrypt.display.revocation import more_info_cert more_info_cert(cert) - @mock.patch("letsencrypt.client.display.revocation.util") + @mock.patch("letsencrypt.display.revocation.util") def test_more_info(self, mock_util): self._call(mock.MagicMock()) @@ -61,18 +61,18 @@ class MoreInfoCertTest(unittest.TestCase): class SuccessRevocationTest(unittest.TestCase): def setUp(self): - from letsencrypt.client.revoker import Cert - base_package = "letsencrypt.client.tests" + from letsencrypt.revoker import Cert + base_package = "letsencrypt.tests" self.cert = Cert(pkg_resources.resource_filename( base_package, os.path.join("testdata", "cert.pem"))) @classmethod def _call(cls, cert): - from letsencrypt.client.display.revocation import success_revocation + from letsencrypt.display.revocation import success_revocation success_revocation(cert) # Pretty trivial test... something is displayed... - @mock.patch("letsencrypt.client.display.revocation.util") + @mock.patch("letsencrypt.display.revocation.util") def test_success_revocation(self, mock_util): self._call(self.cert) @@ -81,16 +81,16 @@ class SuccessRevocationTest(unittest.TestCase): class ConfirmRevocationTest(unittest.TestCase): def setUp(self): - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert self.cert = Cert(pkg_resources.resource_filename( - "letsencrypt.client.tests", os.path.join("testdata", "cert.pem"))) + "letsencrypt.tests", os.path.join("testdata", "cert.pem"))) @classmethod def _call(cls, cert): - from letsencrypt.client.display.revocation import confirm_revocation + from letsencrypt.display.revocation import confirm_revocation return confirm_revocation(cert) - @mock.patch("letsencrypt.client.display.revocation.util") + @mock.patch("letsencrypt.display.revocation.util") def test_confirm_revocation(self, mock_util): mock_util().yesno.return_value = True self.assertTrue(self._call(self.cert)) diff --git a/letsencrypt/client/tests/display/util_test.py b/letsencrypt/tests/display/util_test.py similarity index 91% rename from letsencrypt/client/tests/display/util_test.py rename to letsencrypt/tests/display/util_test.py index 42c948c79..6cebf88ba 100644 --- a/letsencrypt/client/tests/display/util_test.py +++ b/letsencrypt/tests/display/util_test.py @@ -1,10 +1,10 @@ -"""Test :mod:`letsencrypt.client.display.util`.""" +"""Test :mod:`letsencrypt.display.util`.""" import os import unittest import mock -from letsencrypt.client.display import util as display_util +from letsencrypt.display import util as display_util class DisplayT(unittest.TestCase): @@ -53,13 +53,13 @@ class NcursesDisplayTest(DisplayT): "menu_height": display_util.HEIGHT-6, } - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.msgbox") + @mock.patch("letsencrypt.display.util.dialog.Dialog.msgbox") def test_notification(self, mock_msgbox): """Kind of worthless... one liner.""" self.displayer.notification("message") self.assertEqual(mock_msgbox.call_count, 1) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.menu") + @mock.patch("letsencrypt.display.util.dialog.Dialog.menu") def test_menu_tag_and_desc(self, mock_menu): mock_menu.return_value = (display_util.OK, "First") @@ -68,7 +68,7 @@ class NcursesDisplayTest(DisplayT): self.assertEqual(ret, (display_util.OK, 0)) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.menu") + @mock.patch("letsencrypt.display.util.dialog.Dialog.menu") def test_menu_tag_and_desc_cancel(self, mock_menu): mock_menu.return_value = (display_util.CANCEL, "") @@ -78,7 +78,7 @@ class NcursesDisplayTest(DisplayT): self.assertEqual(ret, (display_util.CANCEL, -1)) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.menu") + @mock.patch("letsencrypt.display.util.dialog.Dialog.menu") def test_menu_desc_only(self, mock_menu): mock_menu.return_value = (display_util.OK, "1") @@ -90,7 +90,7 @@ class NcursesDisplayTest(DisplayT): self.assertEqual(ret, (display_util.OK, 0)) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.menu") + @mock.patch("letsencrypt.display.util.dialog.Dialog.menu") def test_menu_desc_only_help(self, mock_menu): mock_menu.return_value = (display_util.HELP, "2") @@ -98,7 +98,7 @@ class NcursesDisplayTest(DisplayT): self.assertEqual(ret, (display_util.HELP, 1)) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.menu") + @mock.patch("letsencrypt.display.util.dialog.Dialog.menu") def test_menu_desc_only_cancel(self, mock_menu): mock_menu.return_value = (display_util.CANCEL, "") @@ -106,13 +106,13 @@ class NcursesDisplayTest(DisplayT): self.assertEqual(ret, (display_util.CANCEL, -1)) - @mock.patch("letsencrypt.client.display.util." + @mock.patch("letsencrypt.display.util." "dialog.Dialog.inputbox") def test_input(self, mock_input): self.displayer.input("message") self.assertEqual(mock_input.call_count, 1) - @mock.patch("letsencrypt.client.display.util.dialog.Dialog.yesno") + @mock.patch("letsencrypt.display.util.dialog.Dialog.yesno") def test_yesno(self, mock_yesno): mock_yesno.return_value = display_util.OK @@ -122,7 +122,7 @@ class NcursesDisplayTest(DisplayT): "message", display_util.HEIGHT, display_util.WIDTH, yes_label="Yes", no_label="No") - @mock.patch("letsencrypt.client.display.util." + @mock.patch("letsencrypt.display.util." "dialog.Dialog.checklist") def test_checklist(self, mock_checklist): self.displayer.checklist("message", self.tags) @@ -164,7 +164,7 @@ class FileOutputDisplayTest(DisplayT): self.assertTrue("message" in self.mock_stdout.write.call_args[0][0]) - @mock.patch("letsencrypt.client.display.util." + @mock.patch("letsencrypt.display.util." "FileDisplay._get_valid_int_ans") def test_menu(self, mock_ans): mock_ans.return_value = (display_util.OK, 1) @@ -199,14 +199,14 @@ class FileOutputDisplayTest(DisplayT): with mock.patch("__builtin__.raw_input", return_value="a"): self.assertTrue(self.displayer.yesno("msg", yes_label="Agree")) - @mock.patch("letsencrypt.client.display.util.FileDisplay.input") + @mock.patch("letsencrypt.display.util.FileDisplay.input") def test_checklist_valid(self, mock_input): mock_input.return_value = (display_util.OK, "2 1") code, tag_list = self.displayer.checklist("msg", self.tags) self.assertEqual( (code, set(tag_list)), (display_util.OK, set(["tag1", "tag2"]))) - @mock.patch("letsencrypt.client.display.util.FileDisplay.input") + @mock.patch("letsencrypt.display.util.FileDisplay.input") def test_checklist_miss_valid(self, mock_input): mock_input.side_effect = [ (display_util.OK, "10"), @@ -217,7 +217,7 @@ class FileOutputDisplayTest(DisplayT): ret = self.displayer.checklist("msg", self.tags) self.assertEqual(ret, (display_util.OK, ["tag1"])) - @mock.patch("letsencrypt.client.display.util.FileDisplay.input") + @mock.patch("letsencrypt.display.util.FileDisplay.input") def test_checklist_miss_quit(self, mock_input): mock_input.side_effect = [ (display_util.OK, "10"), @@ -308,7 +308,7 @@ class SeparateListInputTest(unittest.TestCase): @classmethod def _call(cls, input_): - from letsencrypt.client.display.util import separate_list_input + from letsencrypt.display.util import separate_list_input return separate_list_input(input_) def test_commas(self): @@ -334,7 +334,7 @@ class SeparateListInputTest(unittest.TestCase): class PlaceParensTest(unittest.TestCase): @classmethod def _call(cls, label): # pylint: disable=protected-access - from letsencrypt.client.display.util import _parens_around_char + from letsencrypt.display.util import _parens_around_char return _parens_around_char(label) def test_single_letter(self): diff --git a/letsencrypt/client/tests/le_util_test.py b/letsencrypt/tests/le_util_test.py similarity index 90% rename from letsencrypt/client/tests/le_util_test.py rename to letsencrypt/tests/le_util_test.py index 39926a9b5..0d37a780b 100644 --- a/letsencrypt/client/tests/le_util_test.py +++ b/letsencrypt/tests/le_util_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.le_util.""" +"""Tests for letsencrypt.le_util.""" import os import shutil import stat @@ -9,7 +9,7 @@ import mock class MakeOrVerifyDirTest(unittest.TestCase): - """Tests for letsencrypt.client.le_util.make_or_verify_dir. + """Tests for letsencrypt.le_util.make_or_verify_dir. Note that it is not possible to test for a wrong directory owner, as this testing script would have to be run as root. @@ -27,7 +27,7 @@ class MakeOrVerifyDirTest(unittest.TestCase): shutil.rmtree(self.root_path, ignore_errors=True) def _call(self, directory, mode): - from letsencrypt.client.le_util import make_or_verify_dir + from letsencrypt.le_util import make_or_verify_dir return make_or_verify_dir(directory, mode, self.uid) def test_creates_dir_when_missing(self): @@ -50,7 +50,7 @@ class MakeOrVerifyDirTest(unittest.TestCase): class CheckPermissionsTest(unittest.TestCase): - """Tests for letsencrypt.client.le_util.check_permissions. + """Tests for letsencrypt.le_util.check_permissions. Note that it is not possible to test for a wrong file owner, as this testing script would have to be run as root. @@ -65,7 +65,7 @@ class CheckPermissionsTest(unittest.TestCase): os.remove(self.path) def _call(self, mode): - from letsencrypt.client.le_util import check_permissions + from letsencrypt.le_util import check_permissions return check_permissions(self.path, mode, self.uid) def test_ok_mode(self): @@ -88,7 +88,7 @@ class UniqueFileTest(unittest.TestCase): shutil.rmtree(self.root_path, ignore_errors=True) def _call(self, mode=0o600): - from letsencrypt.client.le_util import unique_file + from letsencrypt.le_util import unique_file return unique_file(self.default_name, mode) def test_returns_fd_for_writing(self): diff --git a/letsencrypt/client/tests/log_test.py b/letsencrypt/tests/log_test.py similarity index 94% rename from letsencrypt/client/tests/log_test.py rename to letsencrypt/tests/log_test.py index 49fbdc7c2..e5760184d 100644 --- a/letsencrypt/client/tests/log_test.py +++ b/letsencrypt/tests/log_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.log.""" +"""Tests for letsencrypt.log.""" import logging import unittest @@ -10,7 +10,7 @@ class DialogHandlerTest(unittest.TestCase): def setUp(self): self.d = mock.MagicMock() # pylint: disable=invalid-name - from letsencrypt.client.log import DialogHandler + from letsencrypt.log import DialogHandler self.handler = DialogHandler(height=2, width=6, d=self.d) self.handler.PADDING_HEIGHT = 2 self.handler.PADDING_WIDTH = 4 diff --git a/letsencrypt/client/tests/network2_test.py b/letsencrypt/tests/network2_test.py similarity index 96% rename from letsencrypt/client/tests/network2_test.py rename to letsencrypt/tests/network2_test.py index 1a5f7fd27..434fafad5 100644 --- a/letsencrypt/client/tests/network2_test.py +++ b/letsencrypt/tests/network2_test.py @@ -1,4 +1,4 @@ -"""Tests for letsencrypt.client.network2.""" +"""Tests for letsencrypt.network2.""" import datetime import httplib import os @@ -13,8 +13,8 @@ from acme import challenges from acme import jose from acme import messages2 -from letsencrypt.client import account -from letsencrypt.client import errors +from letsencrypt import account +from letsencrypt import errors CERT = jose.ComparableX509(M2Crypto.X509.load_cert_string( @@ -33,12 +33,12 @@ KEY2 = jose.JWKRSA.load(pkg_resources.resource_string( class NetworkTest(unittest.TestCase): - """Tests for letsencrypt.client.network2.Network.""" + """Tests for letsencrypt.network2.Network.""" # pylint: disable=too-many-instance-attributes,too-many-public-methods def setUp(self): - from letsencrypt.client.network2 import Network + from letsencrypt.network2 import Network self.net = Network( new_reg_uri='https://www.letsencrypt-demo.org/acme/new-reg', key=KEY, alg=jose.RS256) @@ -142,14 +142,14 @@ class NetworkTest(unittest.TestCase): # pylint: disable=protected-access self.net._check_response(self.response) - @mock.patch('letsencrypt.client.network2.requests') + @mock.patch('letsencrypt.network2.requests') def test_get_requests_error_passthrough(self, requests_mock): requests_mock.exceptions = requests.exceptions requests_mock.get.side_effect = requests.exceptions.RequestException # pylint: disable=protected-access self.assertRaises(errors.NetworkError, self.net._get, 'uri') - @mock.patch('letsencrypt.client.network2.requests') + @mock.patch('letsencrypt.network2.requests') def test_get(self, requests_mock): # pylint: disable=protected-access self.net._check_response = mock.MagicMock() @@ -157,14 +157,14 @@ class NetworkTest(unittest.TestCase): self.net._check_response.assert_called_once_with( requests_mock.get('uri'), content_type='ct') - @mock.patch('letsencrypt.client.network2.requests') + @mock.patch('letsencrypt.network2.requests') def test_post_requests_error_passthrough(self, requests_mock): requests_mock.exceptions = requests.exceptions requests_mock.post.side_effect = requests.exceptions.RequestException # pylint: disable=protected-access self.assertRaises(errors.NetworkError, self.net._post, 'uri', 'data') - @mock.patch('letsencrypt.client.network2.requests') + @mock.patch('letsencrypt.network2.requests') def test_post(self, requests_mock): # pylint: disable=protected-access self.net._check_response = mock.MagicMock() @@ -295,7 +295,7 @@ class NetworkTest(unittest.TestCase): datetime.datetime(1999, 12, 31, 23, 59, 59), self.net.retry_after(response=self.response, default=10)) - @mock.patch('letsencrypt.client.network2.datetime') + @mock.patch('letsencrypt.network2.datetime') def test_retry_after_invalid(self, dt_mock): dt_mock.datetime.now.return_value = datetime.datetime(2015, 3, 27) dt_mock.timedelta = datetime.timedelta @@ -305,7 +305,7 @@ class NetworkTest(unittest.TestCase): datetime.datetime(2015, 3, 27, 0, 0, 10), self.net.retry_after(response=self.response, default=10)) - @mock.patch('letsencrypt.client.network2.datetime') + @mock.patch('letsencrypt.network2.datetime') def test_retry_after_seconds(self, dt_mock): dt_mock.datetime.now.return_value = datetime.datetime(2015, 3, 27) dt_mock.timedelta = datetime.timedelta @@ -315,7 +315,7 @@ class NetworkTest(unittest.TestCase): datetime.datetime(2015, 3, 27, 0, 0, 50), self.net.retry_after(response=self.response, default=10)) - @mock.patch('letsencrypt.client.network2.datetime') + @mock.patch('letsencrypt.network2.datetime') def test_retry_after_missing(self, dt_mock): dt_mock.datetime.now.return_value = datetime.datetime(2015, 3, 27) dt_mock.timedelta = datetime.timedelta @@ -353,8 +353,8 @@ class NetworkTest(unittest.TestCase): errors.NetworkError, self.net.request_issuance, CSR, (self.authzr,)) - @mock.patch('letsencrypt.client.network2.datetime') - @mock.patch('letsencrypt.client.network2.time') + @mock.patch('letsencrypt.network2.datetime') + @mock.patch('letsencrypt.network2.time') def test_poll_and_request_issuance(self, time_mock, dt_mock): # clock.dt | pylint: disable=no-member clock = mock.MagicMock(dt=datetime.datetime(2015, 3, 27)) diff --git a/letsencrypt/client/tests/recovery_token_test.py b/letsencrypt/tests/recovery_token_test.py similarity index 93% rename from letsencrypt/client/tests/recovery_token_test.py rename to letsencrypt/tests/recovery_token_test.py index c0d692c8c..238aa07a3 100644 --- a/letsencrypt/client/tests/recovery_token_test.py +++ b/letsencrypt/tests/recovery_token_test.py @@ -8,12 +8,12 @@ import mock from acme import challenges -from letsencrypt.client import achallenges +from letsencrypt import achallenges class RecoveryTokenTest(unittest.TestCase): def setUp(self): - from letsencrypt.client.recovery_token import RecoveryToken + from letsencrypt.recovery_token import RecoveryToken server = "demo_server" self.base_dir = tempfile.mkdtemp("tokens") self.token_dir = os.path.join(self.base_dir, server) @@ -61,7 +61,7 @@ class RecoveryTokenTest(unittest.TestCase): self.assertEqual( response, challenges.RecoveryTokenResponse(token="444")) - @mock.patch("letsencrypt.client.recovery_token.zope.component.getUtility") + @mock.patch("letsencrypt.recovery_token.zope.component.getUtility") def test_perform_not_stored(self, mock_input): mock_input().input.side_effect = [(0, "555"), (1, "000")] response = self.rec_token.perform( diff --git a/letsencrypt/client/tests/reverter_test.py b/letsencrypt/tests/reverter_test.py similarity index 93% rename from letsencrypt/client/tests/reverter_test.py rename to letsencrypt/tests/reverter_test.py index 25da75611..402866a37 100644 --- a/letsencrypt/client/tests/reverter_test.py +++ b/letsencrypt/tests/reverter_test.py @@ -1,4 +1,4 @@ -"""Test letsencrypt.client.reverter.""" +"""Test letsencrypt.reverter.""" import logging import os import shutil @@ -7,14 +7,14 @@ import unittest import mock -from letsencrypt.client import errors +from letsencrypt import errors class ReverterCheckpointLocalTest(unittest.TestCase): # pylint: disable=too-many-instance-attributes """Test the Reverter Class.""" def setUp(self): - from letsencrypt.client.reverter import Reverter + from letsencrypt.reverter import Reverter # Disable spurious errors... we are trying to test for them logging.disable(logging.CRITICAL) @@ -48,8 +48,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase): "{0}\n{1}\n".format(self.config1, self.config2)) def test_add_to_checkpoint_copy_failure(self): - with mock.patch("letsencrypt.client.reverter." - "shutil.copy2") as mock_copy2: + with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2: mock_copy2.side_effect = IOError("bad copy") self.assertRaises(errors.LetsEncryptReverterError, self.reverter.add_to_checkpoint, @@ -119,8 +118,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase): def test_register_file_creation_write_error(self): m_open = mock.mock_open() - with mock.patch("letsencrypt.client.reverter.open", - m_open, create=True): + with mock.patch("letsencrypt.reverter.open", m_open, create=True): m_open.side_effect = OSError("bad open") self.assertRaises(errors.LetsEncryptReverterError, self.reverter.register_file_creation, @@ -169,8 +167,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase): def test_recover_checkpoint_copy_failure(self): self.reverter.add_to_temp_checkpoint(self.sets[0], "save1") - with mock.patch("letsencrypt.client.reverter.shutil." - "copy2") as mock_copy2: + with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2: mock_copy2.side_effect = OSError("bad copy") self.assertRaises(errors.LetsEncryptReverterError, self.reverter.revert_temporary_config) @@ -178,20 +175,19 @@ class ReverterCheckpointLocalTest(unittest.TestCase): def test_recover_checkpoint_rm_failure(self): self.reverter.add_to_temp_checkpoint(self.sets[0], "temp save") - with mock.patch("letsencrypt.client.reverter.shutil." - "rmtree") as mock_rmtree: + with mock.patch("letsencrypt.reverter.shutil.rmtree") as mock_rmtree: mock_rmtree.side_effect = OSError("Cannot remove tree") self.assertRaises(errors.LetsEncryptReverterError, self.reverter.revert_temporary_config) - @mock.patch("letsencrypt.client.reverter.logging.warning") + @mock.patch("letsencrypt.reverter.logging.warning") def test_recover_checkpoint_missing_new_files(self, mock_warn): self.reverter.register_file_creation( True, os.path.join(self.dir1, "missing_file.txt")) self.reverter.revert_temporary_config() self.assertEqual(mock_warn.call_count, 1) - @mock.patch("letsencrypt.client.reverter.os.remove") + @mock.patch("letsencrypt.reverter.os.remove") def test_recover_checkpoint_remove_failure(self, mock_remove): self.reverter.register_file_creation(True, self.config1) mock_remove.side_effect = OSError("Can't remove") @@ -236,7 +232,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): # pylint: disable=too-many-instance-attributes """Tests functions having to deal with full checkpoints.""" def setUp(self): - from letsencrypt.client.reverter import Reverter + from letsencrypt.reverter import Reverter # Disable spurious errors... logging.disable(logging.CRITICAL) @@ -298,7 +294,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): # No need to warn for this... just make sure there are no errors. self.reverter.finalize_checkpoint("No checkpoint...") - @mock.patch("letsencrypt.client.reverter.shutil.move") + @mock.patch("letsencrypt.reverter.shutil.move") def test_finalize_checkpoint_cannot_title(self, mock_move): self.reverter.add_to_checkpoint(self.sets[0], "perm save") mock_move.side_effect = OSError("cannot move") @@ -307,7 +303,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): self.reverter.finalize_checkpoint, "Title") - @mock.patch("letsencrypt.client.reverter.os.rename") + @mock.patch("letsencrypt.reverter.os.rename") def test_finalize_checkpoint_no_rename_directory(self, mock_rename): # pylint: disable=invalid-name self.reverter.add_to_checkpoint(self.sets[0], "perm save") @@ -317,7 +313,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): self.reverter.finalize_checkpoint, "Title") - @mock.patch("letsencrypt.client.reverter.logging") + @mock.patch("letsencrypt.reverter.logging") def test_rollback_too_many(self, mock_logging): self.reverter.rollback_checkpoints(1) self.assertEqual(mock_logging.warning.call_count, 1) @@ -330,7 +326,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): self.assertEqual(read_in(self.config2), "directive-dir2") self.assertFalse(os.path.isfile(config3)) - @mock.patch("letsencrypt.client.reverter.zope.component.getUtility") + @mock.patch("letsencrypt.reverter.zope.component.getUtility") def test_view_config_changes(self, mock_output): """This is not strict as this is subject to change.""" self._setup_three_checkpoints() @@ -341,7 +337,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): # Make sure notification is output self.assertEqual(mock_output().notification.call_count, 1) - @mock.patch("letsencrypt.client.reverter.logging") + @mock.patch("letsencrypt.reverter.logging") def test_view_config_changes_no_backups(self, mock_logging): self.reverter.view_config_changes() self.assertTrue(mock_logging.info.call_count > 0) @@ -386,7 +382,7 @@ class TestFullCheckpointsReverter(unittest.TestCase): def setup_work_direc(): """Setup directories. - :returns: Mocked :class:`letsencrypt.client.interfaces.IConfig` + :returns: Mocked :class:`letsencrypt.interfaces.IConfig` """ work_dir = tempfile.mkdtemp("work") diff --git a/letsencrypt/client/tests/revoker_test.py b/letsencrypt/tests/revoker_test.py similarity index 84% rename from letsencrypt/client/tests/revoker_test.py rename to letsencrypt/tests/revoker_test.py index 6810a1115..798f28c50 100644 --- a/letsencrypt/client/tests/revoker_test.py +++ b/letsencrypt/tests/revoker_test.py @@ -1,4 +1,4 @@ -"""Test letsencrypt.client.revoker.""" +"""Test letsencrypt.revoker.""" import csv import os import pkg_resources @@ -8,9 +8,9 @@ import unittest import mock -from letsencrypt.client import errors -from letsencrypt.client import le_util -from letsencrypt.client.display import util as display_util +from letsencrypt import errors +from letsencrypt import le_util +from letsencrypt.display import util as display_util from letsencrypt_apache import configurator @@ -27,7 +27,7 @@ class RevokerBase(unittest.TestCase): # pylint: disable=too-few-public-methods def _store_certs(self): # pylint: disable=protected-access - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker Revoker.store_cert_key(self.paths[0], self.key_path, self.mock_config) Revoker.store_cert_key(self.paths[1], self.key_path, self.mock_config) @@ -51,7 +51,7 @@ class RevokerBase(unittest.TestCase): # pylint: disable=too-few-public-methods class RevokerTest(RevokerBase): def setUp(self): - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker super(RevokerTest, self).setUp() with open(self.key_path) as key_file: @@ -66,9 +66,8 @@ class RevokerTest(RevokerBase): def tearDown(self): shutil.rmtree(self.backup_dir) - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_key_all(self, mock_display, mock_net): mock_display().confirm_revocation.return_value = True @@ -81,7 +80,7 @@ class RevokerTest(RevokerBase): self.assertEqual(mock_net.call_count, 2) - @mock.patch("letsencrypt.client.revoker.Crypto.PublicKey.RSA.importKey") + @mock.patch("letsencrypt.revoker.Crypto.PublicKey.RSA.importKey") def test_revoke_by_invalid_keys(self, mock_import): mock_import.side_effect = ValueError self.assertRaises(errors.LetsEncryptRevokerError, @@ -93,9 +92,8 @@ class RevokerTest(RevokerBase): self.revoker.revoke_from_key, self.key) - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_wrong_key(self, mock_display, mock_net): mock_display().confirm_revocation.return_value = True @@ -110,9 +108,8 @@ class RevokerTest(RevokerBase): # No revocation went through self.assertEqual(mock_net.call_count, 0) - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_cert(self, mock_display, mock_net): mock_display().confirm_revocation.return_value = True @@ -128,9 +125,8 @@ class RevokerTest(RevokerBase): self.assertEqual(mock_net.call_count, 1) - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_cert_not_found(self, mock_display, mock_net): mock_display().confirm_revocation.return_value = True @@ -148,9 +144,8 @@ class RevokerTest(RevokerBase): self.assertEqual(mock_net.call_count, 1) - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_menu(self, mock_display, mock_net): mock_display().confirm_revocation.return_value = True mock_display.display_certs.side_effect = [ @@ -172,10 +167,9 @@ class RevokerTest(RevokerBase): self.assertEqual(mock_net.call_count, 1) self.assertEqual(mock_display.more_info_cert.call_count, 1) - @mock.patch("letsencrypt.client.revoker.logging") - @mock.patch("letsencrypt.client.revoker.network." - "Network.send_and_receive_expected") - @mock.patch("letsencrypt.client.revoker.revocation") + @mock.patch("letsencrypt.revoker.logging") + @mock.patch("letsencrypt.revoker.network.Network.send_and_receive_expected") + @mock.patch("letsencrypt.revoker.revocation") def test_revoke_by_menu_delete_all(self, mock_display, mock_net, mock_log): mock_display().confirm_revocation.return_value = True mock_display.display_certs.return_value = (display_util.OK, 0) @@ -192,9 +186,9 @@ class RevokerTest(RevokerBase): # Info is called when there aren't any certs left... self.assertTrue(mock_log.info.called) - @mock.patch("letsencrypt.client.revoker.revocation") - @mock.patch("letsencrypt.client.revoker.Revoker._acme_revoke") - @mock.patch("letsencrypt.client.revoker.logging") + @mock.patch("letsencrypt.revoker.revocation") + @mock.patch("letsencrypt.revoker.Revoker._acme_revoke") + @mock.patch("letsencrypt.revoker.logging") def test_safe_revoke_acme_fail(self, mock_log, mock_revoke, mock_display): # pylint: disable=protected-access mock_revoke.side_effect = errors.LetsEncryptClientError @@ -203,7 +197,7 @@ class RevokerTest(RevokerBase): self.revoker._safe_revoke(self.certs) self.assertTrue(mock_log.error.called) - @mock.patch("letsencrypt.client.revoker.Crypto.PublicKey.RSA.importKey") + @mock.patch("letsencrypt.revoker.Crypto.PublicKey.RSA.importKey") def test_acme_revoke_failure(self, mock_crypto): # pylint: disable=protected-access mock_crypto.side_effect = ValueError @@ -213,7 +207,7 @@ class RevokerTest(RevokerBase): def test_remove_certs_from_list_bad_certs(self): # pylint: disable=protected-access - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert new_cert = Cert(self.paths[0]) @@ -252,7 +246,7 @@ class RevokerInstallerTest(RevokerBase): self._store_certs() def _get_revoker(self, installer): - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker return Revoker(installer, self.mock_config) def test_no_installer_get_installed_locations(self): @@ -274,7 +268,7 @@ class RevokerInstallerTest(RevokerBase): self.assertEqual( sha_vh[cert.get_fingerprint()], self.installs[i]) - @mock.patch("letsencrypt.client.revoker.M2Crypto.X509.load_cert") + @mock.patch("letsencrypt.revoker.M2Crypto.X509.load_cert") def test_get_installed_load_failure(self, mock_m2): mock_installer = mock.MagicMock() mock_installer.get_all_certs_keys.return_value = self.certs_keys @@ -296,11 +290,11 @@ class RevokerClassMethodsTest(RevokerBase): shutil.rmtree(self.backup_dir) def _call(self, cert_path, key_path): - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker Revoker.store_cert_key(cert_path, key_path, self.mock_config) def test_store_two(self): - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker self._call(self.paths[0], self.key_path) self._call(self.paths[1], self.key_path) @@ -318,7 +312,7 @@ class RevokerClassMethodsTest(RevokerBase): self.assertEqual(len(rows), 2) def test_store_one_mixed(self): - from letsencrypt.client.revoker import Revoker + from letsencrypt.revoker import Revoker self._write_rows( [["5", "blank", "blank"], ["18", "dc", "dc"], ["21", "b", "b"]]) self._call(self.paths[0], self.key_path) @@ -338,14 +332,14 @@ class CertTest(unittest.TestCase): self.paths, self.certs, self.key_path = create_revoker_certs() def test_failed_load(self): - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert self.assertRaises(errors.LetsEncryptRevokerError, Cert, self.key_path) def test_no_row(self): self.assertEqual(self.certs[0].get_row(), None) def test_meta_moved_files(self): - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert fake_path = "/not/a/real/path/r72d3t6" self.certs[0].add_meta( 0, fake_path, fake_path, self.paths[0], self.key_path) @@ -354,7 +348,7 @@ class CertTest(unittest.TestCase): self.assertEqual(self.certs[0].orig_key.status, Cert.DELETED_MSG) def test_meta_changed_files(self): - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert self.certs[0].add_meta( 0, self.paths[1], self.paths[1], self.paths[0], self.key_path) @@ -385,9 +379,9 @@ class CertTest(unittest.TestCase): def create_revoker_certs(): """Create a few revoker.Cert objects.""" - from letsencrypt.client.revoker import Cert + from letsencrypt.revoker import Cert - base_package = "letsencrypt.client.tests" + base_package = "letsencrypt.tests" cert0_path = pkg_resources.resource_filename( base_package, os.path.join("testdata", "cert.pem")) diff --git a/letsencrypt/client/tests/testdata/cert-san.pem b/letsencrypt/tests/testdata/cert-san.pem similarity index 100% rename from letsencrypt/client/tests/testdata/cert-san.pem rename to letsencrypt/tests/testdata/cert-san.pem diff --git a/letsencrypt/client/tests/testdata/cert.b64jose b/letsencrypt/tests/testdata/cert.b64jose similarity index 100% rename from letsencrypt/client/tests/testdata/cert.b64jose rename to letsencrypt/tests/testdata/cert.b64jose diff --git a/letsencrypt/client/tests/testdata/cert.pem b/letsencrypt/tests/testdata/cert.pem similarity index 100% rename from letsencrypt/client/tests/testdata/cert.pem rename to letsencrypt/tests/testdata/cert.pem diff --git a/letsencrypt/client/tests/testdata/csr-san.der b/letsencrypt/tests/testdata/csr-san.der similarity index 100% rename from letsencrypt/client/tests/testdata/csr-san.der rename to letsencrypt/tests/testdata/csr-san.der diff --git a/letsencrypt/client/tests/testdata/csr-san.pem b/letsencrypt/tests/testdata/csr-san.pem similarity index 100% rename from letsencrypt/client/tests/testdata/csr-san.pem rename to letsencrypt/tests/testdata/csr-san.pem diff --git a/letsencrypt/client/tests/testdata/csr.der b/letsencrypt/tests/testdata/csr.der similarity index 100% rename from letsencrypt/client/tests/testdata/csr.der rename to letsencrypt/tests/testdata/csr.der diff --git a/letsencrypt/client/tests/testdata/csr.pem b/letsencrypt/tests/testdata/csr.pem similarity index 100% rename from letsencrypt/client/tests/testdata/csr.pem rename to letsencrypt/tests/testdata/csr.pem diff --git a/letsencrypt/client/tests/testdata/rsa512_key.pem b/letsencrypt/tests/testdata/rsa512_key.pem similarity index 100% rename from letsencrypt/client/tests/testdata/rsa512_key.pem rename to letsencrypt/tests/testdata/rsa512_key.pem diff --git a/letsencrypt_apache/configurator.py b/letsencrypt_apache/configurator.py index a7c7b68dc..102718e13 100644 --- a/letsencrypt_apache/configurator.py +++ b/letsencrypt_apache/configurator.py @@ -11,12 +11,12 @@ import zope.interface from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import augeas_configurator -from letsencrypt.client import constants as core_constants -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import augeas_configurator +from letsencrypt import constants as core_constants +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util from letsencrypt_apache import constants from letsencrypt_apache import dvsni @@ -66,7 +66,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): needs of clients are clarified with the new and developing protocol. :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` :ivar parser: Handles low level parsing :type parser: :class:`~letsencrypt_apache.parser` @@ -547,9 +547,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): :param str domain: domain to enhance :param str enhancement: enhancement type defined in - :const:`~letsencrypt.client.constants.ENHANCEMENTS` + :const:`~letsencrypt.constants.ENHANCEMENTS` :param options: options for the enhancement - See :const:`~letsencrypt.client.constants.ENHANCEMENTS` + See :const:`~letsencrypt.constants.ENHANCEMENTS` documentation for appropriate parameter. """ diff --git a/letsencrypt_apache/dvsni.py b/letsencrypt_apache/dvsni.py index 790c4e025..ed7a216bb 100644 --- a/letsencrypt_apache/dvsni.py +++ b/letsencrypt_apache/dvsni.py @@ -11,7 +11,7 @@ class ApacheDvsni(object): :ivar configurator: ApacheConfigurator object :type configurator: :class:`~apache.configurator.ApacheConfigurator` - :ivar list achalls: Annotated :class:`~letsencrypt.client.achallenges.DVSNI` + :ivar list achalls: Annotated :class:`~letsencrypt.achallenges.DVSNI` challenges. :param list indices: Meant to hold indices of challenges in a @@ -54,7 +54,7 @@ class ApacheDvsni(object): """Add challenge to DVSNI object to perform at once. :param achall: Annotated DVSNI challenge. - :type achall: :class:`letsencrypt.client.achallenges.DVSNI` + :type achall: :class:`letsencrypt.achallenges.DVSNI` :param int idx: index to challenge in a larger array @@ -128,7 +128,7 @@ class ApacheDvsni(object): Result: Apache config includes virtual servers for issued challs :param list ll_addrs: list of list of - :class:`letsencrypt.client.plugins.apache.obj.Addr` to apply + :class:`letsencrypt.plugins.apache.obj.Addr` to apply """ # TODO: Use ip address of existing vhost instead of relying on FQDN @@ -164,7 +164,7 @@ class ApacheDvsni(object): """Chocolate virtual server configuration text :param achall: Annotated DVSNI challenge. - :type achall: :class:`letsencrypt.client.achallenges.DVSNI` + :type achall: :class:`letsencrypt.achallenges.DVSNI` :param list ip_addrs: addresses of challenged domain :class:`list` of type :class:`~apache.obj.Addr` @@ -191,7 +191,7 @@ class ApacheDvsni(object): """Returns standardized name for challenge certificate. :param achall: Annotated DVSNI challenge. - :type achall: :class:`letsencrypt.client.achallenges.DVSNI` + :type achall: :class:`letsencrypt.achallenges.DVSNI` :returns: certificate file name :rtype: str diff --git a/letsencrypt_apache/parser.py b/letsencrypt_apache/parser.py index b713c8f6a..9e6e9efe6 100644 --- a/letsencrypt_apache/parser.py +++ b/letsencrypt_apache/parser.py @@ -2,7 +2,7 @@ import os import re -from letsencrypt.client import errors +from letsencrypt import errors class ApacheParser(object): diff --git a/letsencrypt_apache/tests/configurator_test.py b/letsencrypt_apache/tests/configurator_test.py index d7e6b95cf..5cfa22842 100644 --- a/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt_apache/tests/configurator_test.py @@ -8,11 +8,11 @@ import mock from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import errors -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import errors +from letsencrypt import le_util -from letsencrypt.client.tests import acme_util +from letsencrypt.tests import acme_util from letsencrypt_apache import configurator from letsencrypt_apache import obj diff --git a/letsencrypt_apache/tests/dvsni_test.py b/letsencrypt_apache/tests/dvsni_test.py index 323bf8c31..958918529 100644 --- a/letsencrypt_apache/tests/dvsni_test.py +++ b/letsencrypt_apache/tests/dvsni_test.py @@ -7,10 +7,10 @@ import mock from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import le_util -from letsencrypt.client.tests import acme_util +from letsencrypt.tests import acme_util from letsencrypt_apache import obj from letsencrypt_apache.tests import util diff --git a/letsencrypt_apache/tests/parser_test.py b/letsencrypt_apache/tests/parser_test.py index b8fbb5dea..17a34cad8 100644 --- a/letsencrypt_apache/tests/parser_test.py +++ b/letsencrypt_apache/tests/parser_test.py @@ -8,8 +8,8 @@ import augeas import mock import zope.component -from letsencrypt.client import errors -from letsencrypt.client.display import util as display_util +from letsencrypt import errors +from letsencrypt.display import util as display_util from letsencrypt_apache.tests import util diff --git a/letsencrypt_nginx/configurator.py b/letsencrypt_nginx/configurator.py index e1d3bd367..e13cc555a 100644 --- a/letsencrypt_nginx/configurator.py +++ b/letsencrypt_nginx/configurator.py @@ -11,14 +11,14 @@ import zope.interface from acme import challenges -from letsencrypt.client import achallenges -from letsencrypt.client import constants as core_constants -from letsencrypt.client import errors -from letsencrypt.client import interfaces -from letsencrypt.client import le_util -from letsencrypt.client import reverter +from letsencrypt import achallenges +from letsencrypt import constants as core_constants +from letsencrypt import errors +from letsencrypt import interfaces +from letsencrypt import le_util +from letsencrypt import reverter -from letsencrypt.client.plugins import common +from letsencrypt.plugins import common from letsencrypt_nginx import constants from letsencrypt_nginx import dvsni @@ -35,7 +35,7 @@ class NginxConfigurator(common.Plugin): config files modified by the configurator will lose all their comments. :ivar config: Configuration. - :type config: :class:`~letsencrypt.client.interfaces.IConfig` + :type config: :class:`~letsencrypt.interfaces.IConfig` :ivar parser: Handles low level parsing :type parser: :class:`~letsencrypt_nginx.parser` @@ -43,7 +43,7 @@ class NginxConfigurator(common.Plugin): :ivar str save_notes: Human-readable config change notes :ivar reverter: saves and reverts checkpoints - :type reverter: :class:`letsencrypt.client.reverter.Reverter` + :type reverter: :class:`letsencrypt.reverter.Reverter` :ivar tup version: version of Nginx @@ -302,9 +302,9 @@ class NginxConfigurator(common.Plugin): :param str domain: domain to enhance :param str enhancement: enhancement type defined in - :const:`~letsencrypt.client.constants.ENHANCEMENTS` + :const:`~letsencrypt.constants.ENHANCEMENTS` :param options: options for the enhancement - See :const:`~letsencrypt.client.constants.ENHANCEMENTS` + See :const:`~letsencrypt.constants.ENHANCEMENTS` documentation for appropriate parameter. """ diff --git a/letsencrypt_nginx/dvsni.py b/letsencrypt_nginx/dvsni.py index c845db916..7ea69e052 100644 --- a/letsencrypt_nginx/dvsni.py +++ b/letsencrypt_nginx/dvsni.py @@ -13,7 +13,7 @@ class NginxDvsni(ApacheDvsni): :ivar configurator: NginxConfigurator object :type configurator: :class:`~nginx.configurator.NginxConfigurator` - :ivar list achalls: Annotated :class:`~letsencrypt.client.achallenges.DVSNI` + :ivar list achalls: Annotated :class:`~letsencrypt.achallenges.DVSNI` challenges. :param list indices: Meant to hold indices of challenges in a diff --git a/letsencrypt_nginx/parser.py b/letsencrypt_nginx/parser.py index 7e11fe0c3..22e062ee0 100644 --- a/letsencrypt_nginx/parser.py +++ b/letsencrypt_nginx/parser.py @@ -5,7 +5,7 @@ import os import pyparsing import re -from letsencrypt.client import errors +from letsencrypt import errors from letsencrypt_nginx import obj from letsencrypt_nginx import nginxparser diff --git a/letsencrypt_nginx/tests/configurator_test.py b/letsencrypt_nginx/tests/configurator_test.py index 12101949f..86fe55499 100644 --- a/letsencrypt_nginx/tests/configurator_test.py +++ b/letsencrypt_nginx/tests/configurator_test.py @@ -7,9 +7,9 @@ import mock from acme import challenges from acme import messages2 -from letsencrypt.client import achallenges -from letsencrypt.client import errors -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import errors +from letsencrypt import le_util from letsencrypt_nginx.tests import util diff --git a/letsencrypt_nginx/tests/dvsni_test.py b/letsencrypt_nginx/tests/dvsni_test.py index 94708e282..a13638069 100644 --- a/letsencrypt_nginx/tests/dvsni_test.py +++ b/letsencrypt_nginx/tests/dvsni_test.py @@ -8,8 +8,8 @@ import mock from acme import challenges from acme import messages2 -from letsencrypt.client import achallenges -from letsencrypt.client import le_util +from letsencrypt import achallenges +from letsencrypt import le_util from letsencrypt_nginx.tests import util diff --git a/letsencrypt_nginx/tests/parser_test.py b/letsencrypt_nginx/tests/parser_test.py index 47b44e671..2770320a1 100644 --- a/letsencrypt_nginx/tests/parser_test.py +++ b/letsencrypt_nginx/tests/parser_test.py @@ -5,7 +5,7 @@ import re import shutil import unittest -from letsencrypt.client.errors import LetsEncryptMisconfigurationError +from letsencrypt.errors import LetsEncryptMisconfigurationError from letsencrypt_nginx import nginxparser from letsencrypt_nginx import obj diff --git a/letsencrypt_nginx/tests/util.py b/letsencrypt_nginx/tests/util.py index 57d11c188..5faa3da18 100644 --- a/letsencrypt_nginx/tests/util.py +++ b/letsencrypt_nginx/tests/util.py @@ -1,4 +1,4 @@ -"""Common utilities for letsencrypt.client.nginx.""" +"""Common utilities for letsencrypt_nginx.""" import os import pkg_resources import shutil diff --git a/setup.py b/setup.py index 1c65ff880..8478ab132 100644 --- a/setup.py +++ b/setup.py @@ -111,11 +111,11 @@ setup( entry_points={ 'console_scripts': [ - 'letsencrypt = letsencrypt.client.cli:main', + 'letsencrypt = letsencrypt.cli:main', 'jws = letsencrypt.acme.jose.jws:CLI.run', ], 'letsencrypt.plugins': [ - 'standalone = letsencrypt.client.plugins.standalone.authenticator' + 'standalone = letsencrypt.plugins.standalone.authenticator' ':StandaloneAuthenticator', # to be moved to separate pypi packages