Update and run isort (#9573)

I want to use isort as part of https://github.com/certbot/certbot/issues/9572 because I want to do it programmatically, however, I felt like the config needed to be tweaked a bit due to it not understanding what is and is not our own code.

This PR updates the isort config so it recognizes our own modules and runs `isort .` from the root of the repo to update everything.

* update isort config

* run "isort ."
This commit is contained in:
Brad Warren
2023-02-10 10:51:20 -08:00
committed by GitHub
parent d8d177ce72
commit 1bb09da270
81 changed files with 166 additions and 163 deletions
+1
View File
@@ -4,3 +4,4 @@ force_sort_within_sections=True
force_single_line=True
order_by_type=False
line_length=400
src_paths=acme/acme,acme/tests,certbot*/certbot*,certbot*/tests
+1 -1
View File
@@ -5,8 +5,8 @@ import functools
import hashlib
import logging
import socket
from typing import cast
from typing import Any
from typing import cast
from typing import Dict
from typing import Mapping
from typing import Optional
+1 -2
View File
@@ -1,8 +1,7 @@
"""ACME JSON fields."""
import datetime
from typing import Any
import logging
from typing import Any
import josepy as jose
import pyrfc3339
+1 -2
View File
@@ -1,6 +1,6 @@
"""ACME protocol messages."""
import datetime
from collections.abc import Hashable
import datetime
import json
from typing import Any
from typing import Dict
@@ -21,7 +21,6 @@ from acme import fields
from acme import jws
from acme import util
ERROR_PREFIX = "urn:ietf:params:acme:error:"
ERROR_CODES = {
+2 -3
View File
@@ -1,15 +1,14 @@
"""Tests for acme.challenges."""
import urllib.parse as urllib_parse
import unittest
from unittest import mock
import urllib.parse as urllib_parse
import josepy as jose
from josepy.jwk import JWKEC
import OpenSSL
import requests
from josepy.jwk import JWKEC
from acme import errors
import test_util
CERT = test_util.load_comparable_cert('cert.pem')
+1 -1
View File
@@ -4,8 +4,8 @@ import copy
import datetime
import http.client as http_client
import json
import unittest
from typing import Dict
import unittest
from unittest import mock
import josepy as jose
+2 -2
View File
@@ -1,12 +1,12 @@
"""Tests for acme.crypto_util."""
import itertools
import ipaddress
import itertools
import socket
import socketserver
import threading
import time
import unittest
from typing import List
import unittest
import josepy as jose
import OpenSSL
+2 -1
View File
@@ -21,8 +21,9 @@ class JoseTest(unittest.TestCase):
# We use the imports below with eval, but pylint doesn't
# understand that.
import acme # pylint: disable=unused-import
import josepy # pylint: disable=unused-import
import acme # pylint: disable=unused-import
acme_jose_mod = eval(acme_jose_path) # pylint: disable=eval-used
josepy_mod = eval(josepy_path) # pylint: disable=eval-used
self.assertIs(acme_jose_mod, josepy_mod)
+14 -6
View File
@@ -1,7 +1,7 @@
"""Tests for acme.messages."""
import contextlib
from typing import Dict
import unittest
import contextlib
from unittest import mock
import warnings
@@ -19,7 +19,10 @@ class ErrorTest(unittest.TestCase):
"""Tests for acme.messages.Error."""
def setUp(self):
from acme.messages import Error, ERROR_PREFIX, Identifier, IDENTIFIER_FQDN
from acme.messages import Error
from acme.messages import ERROR_PREFIX
from acme.messages import Identifier
from acme.messages import IDENTIFIER_FQDN
self.error = Error.with_code('malformed', detail='foo', title='title')
self.jobj = {
'detail': 'foo',
@@ -63,7 +66,8 @@ class ErrorTest(unittest.TestCase):
self.assertIsNone(Error().code)
def test_is_acme_error(self):
from acme.messages import is_acme_error, Error
from acme.messages import Error
from acme.messages import is_acme_error
self.assertTrue(is_acme_error(self.error))
self.assertFalse(is_acme_error(self.error_custom))
self.assertFalse(is_acme_error(Error()))
@@ -71,13 +75,15 @@ class ErrorTest(unittest.TestCase):
self.assertFalse(is_acme_error("must pet all the {dogs|rabbits}"))
def test_unicode_error(self):
from acme.messages import Error, is_acme_error
from acme.messages import Error
from acme.messages import is_acme_error
arabic_error = Error.with_code(
'malformed', detail=u'\u0639\u062f\u0627\u0644\u0629', title='title')
self.assertTrue(is_acme_error(arabic_error))
def test_with_code(self):
from acme.messages import Error, is_acme_error
from acme.messages import Error
from acme.messages import is_acme_error
self.assertTrue(is_acme_error(Error.with_code('badCSR')))
self.assertRaises(ValueError, Error.with_code, 'not an ACME error code')
@@ -247,7 +253,9 @@ class RegistrationTest(unittest.TestCase):
))
def test_new_registration_from_data_with_eab(self):
from acme.messages import NewRegistration, ExternalAccountBinding, Directory
from acme.messages import Directory
from acme.messages import ExternalAccountBinding
from acme.messages import NewRegistration
key = jose.jwk.JWKRSA(key=KEY.public_key())
kid = "kid-for-testing"
hmac_key = "hmac-key-for-testing"
+2 -2
View File
@@ -3,8 +3,8 @@ import http.client as http_client
import socket
import socketserver
import threading
import unittest
from typing import Set
import unittest
from unittest import mock
import josepy as jose
@@ -13,7 +13,6 @@ import requests
from acme import challenges
from acme import crypto_util
from acme import errors
import test_util
@@ -190,6 +189,7 @@ class BaseDualNetworkedServersTest(unittest.TestCase):
@mock.patch("socket.socket.bind")
def test_fail_to_bind(self, mock_bind):
from errno import EADDRINUSE
from acme.standalone import BaseDualNetworkedServers
mock_bind.side_effect = socket.error(EADDRINUSE, "Fake addr in use error")
+1 -1
View File
@@ -8,9 +8,9 @@ import os
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
import josepy as jose
from josepy.util import ComparableECKey
from OpenSSL import crypto
import pkg_resources
from josepy.util import ComparableECKey
def load_vector(*names):
@@ -74,15 +74,14 @@ from typing import Set
from typing import Tuple
from typing import Union
from certbot import errors
from certbot.compat import os
from certbot_apache._internal import apache_util
from certbot_apache._internal import assertions
from certbot_apache._internal import interfaces
from certbot_apache._internal import parser
from certbot_apache._internal import parsernode_util as util
from certbot import errors
from certbot.compat import os
class AugeasParserNode(interfaces.ParserNode):
""" Augeas implementation of ParserNode interface """
@@ -21,16 +21,6 @@ from typing import Tuple
from typing import Type
from typing import Union
from certbot_apache._internal import apache_util
from certbot_apache._internal import assertions
from certbot_apache._internal import constants
from certbot_apache._internal import display_ops
from certbot_apache._internal import dualparser
from certbot_apache._internal import http_01
from certbot_apache._internal import obj
from certbot_apache._internal import parser
from certbot_apache._internal.apacheparser import ApacheBlockNode
from acme import challenges
from certbot import achallenges
from certbot import errors
@@ -42,6 +32,15 @@ from certbot.interfaces import RenewableCert
from certbot.plugins import common
from certbot.plugins.enhancements import AutoHSTSEnhancement
from certbot.plugins.util import path_surgery
from certbot_apache._internal import apache_util
from certbot_apache._internal import assertions
from certbot_apache._internal import constants
from certbot_apache._internal import display_ops
from certbot_apache._internal import dualparser
from certbot_apache._internal import http_01
from certbot_apache._internal import obj
from certbot_apache._internal import parser
from certbot_apache._internal.apacheparser import ApacheBlockNode
try:
import apacheconfig
@@ -6,11 +6,10 @@ from typing import Optional
from typing import Sequence
from typing import Tuple
from certbot_apache._internal.obj import VirtualHost
from certbot import errors
from certbot.compat import os
from certbot.display import util as display_util
from certbot_apache._internal.obj import VirtualHost
logger = logging.getLogger(__name__)
@@ -2,6 +2,7 @@
from typing import Dict
from typing import Type
from certbot import util
from certbot_apache._internal import configurator
from certbot_apache._internal import override_arch
from certbot_apache._internal import override_centos
@@ -12,8 +13,6 @@ from certbot_apache._internal import override_gentoo
from certbot_apache._internal import override_suse
from certbot_apache._internal import override_void
from certbot import util
OVERRIDE_CLASSES: Dict[str, Type[configurator.ApacheConfigurator]] = {
"arch": override_arch.ArchConfigurator,
"cloudlinux": override_centos.CentOSConfigurator,
@@ -5,15 +5,14 @@ from typing import List
from typing import Set
from typing import TYPE_CHECKING
from certbot_apache._internal.obj import VirtualHost
from certbot_apache._internal.parser import get_aug_path
from acme.challenges import KeyAuthorizationChallengeResponse
from certbot import errors
from certbot.achallenges import KeyAuthorizationAnnotatedChallenge
from certbot.compat import filesystem
from certbot.compat import os
from certbot.plugins import common
from certbot_apache._internal.obj import VirtualHost
from certbot_apache._internal.parser import get_aug_path
if TYPE_CHECKING:
from certbot_apache._internal.configurator import ApacheConfigurator # pragma: no cover
@@ -7,12 +7,11 @@ from typing import Pattern
from typing import Set
from typing import Union
from certbot.plugins import common
from certbot_apache._internal.apacheparser import ApacheBlockNode
from certbot_apache._internal.augeasparser import AugeasBlockNode
from certbot_apache._internal.dualparser import DualBlockNode
from certbot.plugins import common
class Addr(common.Addr):
"""Represents an Apache address."""
@@ -2,14 +2,13 @@
import logging
from typing import Any
from certbot import errors
from certbot import util
from certbot_apache._internal import apache_util
from certbot_apache._internal import configurator
from certbot_apache._internal import parser
from certbot_apache._internal.configurator import OsOptions
from certbot import errors
from certbot import util
logger = logging.getLogger(__name__)
@@ -1,15 +1,14 @@
""" Distribution specific override class for Debian family (Ubuntu/Debian) """
import logging
from certbot_apache._internal import apache_util
from certbot_apache._internal import configurator
from certbot_apache._internal.configurator import OsOptions
from certbot_apache._internal.obj import VirtualHost
from certbot import errors
from certbot import util
from certbot.compat import filesystem
from certbot.compat import os
from certbot_apache._internal import apache_util
from certbot_apache._internal import configurator
from certbot_apache._internal.configurator import OsOptions
from certbot_apache._internal.obj import VirtualHost
logger = logging.getLogger(__name__)
@@ -1,14 +1,13 @@
""" Distribution specific override class for Fedora 29+ """
from typing import Any
from certbot import errors
from certbot import util
from certbot_apache._internal import apache_util
from certbot_apache._internal import configurator
from certbot_apache._internal import parser
from certbot_apache._internal.configurator import OsOptions
from certbot import errors
from certbot import util
class FedoraConfigurator(configurator.ApacheConfigurator):
"""Fedora 29+ specific ApacheConfigurator override class"""
@@ -15,11 +15,10 @@ from typing import Tuple
from typing import TYPE_CHECKING
from typing import Union
from certbot_apache._internal import apache_util
from certbot_apache._internal import constants
from certbot import errors
from certbot.compat import os
from certbot_apache._internal import apache_util
from certbot_apache._internal import constants
if TYPE_CHECKING:
from certbot_apache._internal.configurator import ApacheConfigurator # pragma: no cover
+2 -4
View File
@@ -1,14 +1,12 @@
"""Tests for AugeasParserNode classes"""
from typing import List
import os
import util
from typing import List
from unittest import mock
from certbot import errors
from certbot_apache._internal import assertions
from certbot_apache._internal import augeasparser
import util
def _get_augeasnode_mock(filepath):
+1 -1
View File
@@ -5,8 +5,8 @@ from unittest import mock
from certbot import errors
from certbot.compat import filesystem
from certbot.compat import os
from certbot_apache._internal import override_centos
from certbot_apache._internal import obj
from certbot_apache._internal import override_centos
import util
+4 -2
View File
@@ -86,6 +86,7 @@ class MultipleVhostsTest(util.ApacheTest):
def test_add_parser_arguments(self): # pylint: disable=no-self-use
from certbot_apache._internal.configurator import ApacheConfigurator
# Weak test..
ApacheConfigurator.add_parser_arguments(mock.MagicMock())
@@ -123,8 +124,8 @@ class MultipleVhostsTest(util.ApacheTest):
cls.add_parser_arguments(mock.MagicMock())
def test_all_configurators_defaults_defined(self):
from certbot_apache._internal.entrypoint import OVERRIDE_CLASSES
from certbot_apache._internal.configurator import ApacheConfigurator
from certbot_apache._internal.entrypoint import OVERRIDE_CLASSES
parameters = set(ApacheConfigurator.OS_DEFAULTS.__dict__.keys())
for cls in OVERRIDE_CLASSES.values():
self.assertIs(parameters.issubset(set(cls.OS_DEFAULTS.__dict__.keys())), True)
@@ -1669,9 +1670,10 @@ class InstallSslOptionsConfTest(util.ApacheTest):
file has been manually edited by the user, and will refuse to update it.
This test ensures that all necessary hashes are present.
"""
from certbot_apache._internal.constants import ALL_SSL_OPTIONS_HASHES
import pkg_resources
from certbot_apache._internal.constants import ALL_SSL_OPTIONS_HASHES
tls_configs_dir = pkg_resources.resource_filename(
"certbot_apache", os.path.join("_internal", "tls_configs"))
all_files = [os.path.join(tls_configs_dir, name) for name in os.listdir(tls_configs_dir)
+1 -1
View File
@@ -1,7 +1,7 @@
"""Test for certbot_apache._internal.http_01."""
import unittest
import errno
from typing import List
import unittest
from unittest import mock
from acme import challenges
+2
View File
@@ -128,6 +128,7 @@ class BasicParserTest(util.ParserTest):
"""
from certbot_apache._internal.parser import get_aug_path
# This makes sure that find_dir will work
self.parser.modules["mod_ssl.c"] = "/fake/path"
@@ -142,6 +143,7 @@ class BasicParserTest(util.ParserTest):
def test_add_dir_to_ifmodssl_multiple(self):
from certbot_apache._internal.parser import get_aug_path
# This makes sure that find_dir will work
self.parser.modules["mod_ssl.c"] = "/fake/path"
+1 -1
View File
@@ -1,10 +1,10 @@
"""Common utilities for certbot_apache."""
import shutil
import unittest
from unittest import mock
import augeas
import josepy as jose
from unittest import mock
from certbot.compat import os
from certbot.plugins import common
@@ -5,7 +5,8 @@ from typing import Optional
from typing import Type
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurve
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.serialization import load_pem_private_key
@@ -13,8 +14,8 @@ try:
import grp
POSIX_MODE = True
except ImportError:
import win32security
import ntsecuritycon
import win32security
POSIX_MODE = False
EVERYBODY_SID = 'S-1-1-0'
@@ -6,8 +6,8 @@ import re
import shutil
import subprocess
import time
from typing import Iterable
from typing import Generator
from typing import Iterable
from typing import Tuple
from typing import Type
@@ -18,7 +18,6 @@ from cryptography.hazmat.primitives.asymmetric.ec import SECP521R1
from cryptography.x509 import NameOID
import pytest
from certbot_integration_tests.certbot_tests.context import IntegrationTestsContext
from certbot_integration_tests.certbot_tests.assertions import assert_cert_count_for_lineage
from certbot_integration_tests.certbot_tests.assertions import assert_elliptic_key
from certbot_integration_tests.certbot_tests.assertions import assert_equals_group_owner
@@ -31,6 +30,7 @@ from certbot_integration_tests.certbot_tests.assertions import assert_saved_rene
from certbot_integration_tests.certbot_tests.assertions import assert_world_no_permissions
from certbot_integration_tests.certbot_tests.assertions import assert_world_read_permissions
from certbot_integration_tests.certbot_tests.assertions import EVERYBODY_SID
from certbot_integration_tests.certbot_tests.context import IntegrationTestsContext
from certbot_integration_tests.utils import misc
@@ -248,8 +248,9 @@ def test_renew_files_propagate_permissions(context: IntegrationTestsContext) ->
if os.name != 'nt':
os.chmod(privkey1, 0o444)
else:
import win32security # pylint: disable=import-error
import ntsecuritycon # pylint: disable=import-error
import win32security # pylint: disable=import-error
# Get the current DACL of the private key
security = win32security.GetFileSecurity(privkey1, win32security.DACL_SECURITY_INFORMATION)
dacl = security.GetSecurityDescriptorDacl()
@@ -2,7 +2,6 @@
"""Module to call certbot in test mode"""
import os
import pkg_resources
import subprocess
import sys
from typing import Dict
@@ -10,6 +9,8 @@ from typing import List
from typing import Mapping
from typing import Tuple
import pkg_resources
import certbot_integration_tests
# pylint: disable=wildcard-import,unused-wildcard-import
from certbot_integration_tests.utils.constants import *
@@ -15,20 +15,20 @@ import sys
import tempfile
import threading
import time
import warnings
from typing import Generator
from typing import Iterable
from typing import List
from typing import Optional
from typing import Tuple
import warnings
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import Encoding
from cryptography.hazmat.primitives.serialization import NoEncryption
from cryptography.hazmat.primitives.serialization import PrivateFormat
from cryptography.x509 import load_pem_x509_certificate
from cryptography.x509 import Certificate
from cryptography.x509 import load_pem_x509_certificate
from OpenSSL import crypto
import pkg_resources
import requests
@@ -6,6 +6,8 @@ to serve a mock OCSP responder during integration tests against Pebble.
import datetime
import http.server as BaseHTTPServer
import re
from typing import cast
from typing import Union
from cryptography import x509
from cryptography.hazmat.backends import default_backend
@@ -16,8 +18,6 @@ from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.x509 import ocsp
from dateutil import parser
import requests
from typing import cast
from typing import Union
from certbot_integration_tests.utils.constants import MOCK_OCSP_SERVER_PORT
from certbot_integration_tests.utils.constants import PEBBLE_MANAGEMENT_URL
@@ -3,8 +3,8 @@ import os
import re
import subprocess
import time
import unittest
from typing import Any
import unittest
import pytest
@@ -7,15 +7,14 @@ from typing import Set
from typing import Tuple
from unittest import mock
from certbot import configuration
from certbot import errors as le_errors
from certbot import util as certbot_util
from certbot_apache._internal import entrypoint
from certbot_compatibility_test import errors
from certbot_compatibility_test import util
from certbot_compatibility_test.configurators import common as configurators_common
from certbot import configuration
from certbot import errors as le_errors
from certbot import util as certbot_util
class Proxy(configurators_common.Proxy):
"""A common base for Apache test configurators"""
@@ -8,21 +8,20 @@ import tempfile
from typing import Iterable
from typing import List
from typing import Optional
from typing import Union
from typing import overload
from typing import Set
from typing import Tuple
from typing import Type
from certbot_compatibility_test import errors
from certbot_compatibility_test import interfaces
from certbot_compatibility_test import util
from typing import Union
from acme import challenges
from acme.challenges import Challenge
from certbot._internal import constants
from certbot.plugins import common
from certbot.achallenges import AnnotatedChallenge
from certbot.plugins import common
from certbot_compatibility_test import errors
from certbot_compatibility_test import interfaces
from certbot_compatibility_test import util
logger = logging.getLogger(__name__)
@@ -5,14 +5,13 @@ import subprocess
from typing import Set
from typing import Tuple
from certbot import configuration
from certbot_compatibility_test import errors
from certbot_compatibility_test import util
from certbot_compatibility_test.configurators import common as configurators_common
from certbot_nginx._internal import configurator
from certbot_nginx._internal import constants
from certbot import configuration
class Proxy(configurators_common.Proxy):
"""A common base for Nginx test configurators"""
@@ -18,12 +18,6 @@ from typing import Optional
from typing import Tuple
from typing import Type
from certbot_compatibility_test import errors
from certbot_compatibility_test import util
from certbot_compatibility_test import validator
from certbot_compatibility_test.configurators import common
from certbot_compatibility_test.configurators.apache import common as a_common
from certbot_compatibility_test.configurators.nginx import common as n_common
from OpenSSL import crypto
from urllib3.util import connection
@@ -34,6 +28,12 @@ from certbot import achallenges
from certbot import errors as le_errors
from certbot._internal.display import obj as display_obj
from certbot.tests import acme_util
from certbot_compatibility_test import errors
from certbot_compatibility_test import util
from certbot_compatibility_test import validator
from certbot_compatibility_test.configurators import common
from certbot_compatibility_test.configurators.apache import common as a_common
from certbot_compatibility_test.configurators.nginx import common as n_common
DESCRIPTION = """
Tests Certbot plugins against different server configurations. It is
@@ -6,11 +6,11 @@ import re
import shutil
import tarfile
from certbot_compatibility_test import errors
import josepy as jose
from certbot._internal import constants
from certbot.tests import util as test_util
from certbot_compatibility_test import errors
_KEY_BASE = "rsa2048_key.pem"
KEY_PATH = test_util.vector_path(_KEY_BASE)
+1 -2
View File
@@ -1,14 +1,13 @@
"""Tests for certbot_dns_google._internal.dns_google."""
import unittest
from unittest import mock
from googleapiclient import discovery
from googleapiclient.errors import Error
from googleapiclient.http import HttpMock
from httplib2 import ServerNotFoundError
from unittest import mock
from certbot import errors
from certbot.compat import os
from certbot.errors import PluginError
@@ -20,12 +20,6 @@ from typing import Tuple
from typing import Type
from typing import Union
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops
from certbot_nginx._internal import http_01
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal import obj
from certbot_nginx._internal import parser
import OpenSSL
import pkg_resources
@@ -38,6 +32,12 @@ from certbot import util
from certbot.compat import os
from certbot.display import util as display_util
from certbot.plugins import common
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops
from certbot_nginx._internal import http_01
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal import obj
from certbot_nginx._internal import parser
NAME_RANK = 0
START_WILDCARD_RANK = 1
@@ -4,9 +4,8 @@ from typing import Iterable
from typing import List
from typing import Optional
from certbot_nginx._internal.obj import VirtualHost
from certbot.display import util as display_util
from certbot_nginx._internal.obj import VirtualHost
logger = logging.getLogger(__name__)
@@ -7,15 +7,14 @@ from typing import List
from typing import Optional
from typing import TYPE_CHECKING
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal.obj import Addr
from acme import challenges
from acme.challenges import KeyAuthorizationChallengeResponse
from certbot import errors
from certbot.achallenges import KeyAuthorizationAnnotatedChallenge
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal.obj import Addr
if TYPE_CHECKING:
from certbot_nginx._internal.configurator import NginxConfigurator
@@ -18,13 +18,13 @@ from typing import Set
from typing import Tuple
from typing import Union
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal import obj
from certbot_nginx._internal.nginxparser import UnspacedList
import pyparsing
from certbot import errors
from certbot.compat import os
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal import obj
from certbot_nginx._internal.nginxparser import UnspacedList
logger = logging.getLogger(__name__)
+2 -1
View File
@@ -1064,8 +1064,9 @@ class InstallSslOptionsConfTest(util.NginxTest):
file has been manually edited by the user, and will refuse to update it.
This test ensures that all necessary hashes are present.
"""
from certbot_nginx._internal.constants import ALL_SSL_OPTIONS_HASHES
import pkg_resources
from certbot_nginx._internal.constants import ALL_SSL_OPTIONS_HASHES
all_files = [
pkg_resources.resource_filename("certbot_nginx",
os.path.join("_internal", "tls_configs", x))
+3 -3
View File
@@ -109,8 +109,8 @@ class AddrTest(unittest.TestCase):
class VirtualHostTest(unittest.TestCase):
"""Test the VirtualHost class."""
def setUp(self):
from certbot_nginx._internal.obj import VirtualHost
from certbot_nginx._internal.obj import Addr
from certbot_nginx._internal.obj import VirtualHost
raw1 = [
['listen', '69.50.225.155:9000'],
[['if', '($scheme', '!=', '"https") '],
@@ -183,9 +183,9 @@ class VirtualHostTest(unittest.TestCase):
self.assertIs(self.vhost1.has_header('Bogus-Header'), False)
def test_contains_list(self):
from certbot_nginx._internal.obj import VirtualHost
from certbot_nginx._internal.obj import Addr
from certbot_nginx._internal.configurator import _test_block_from_block
from certbot_nginx._internal.obj import Addr
from certbot_nginx._internal.obj import VirtualHost
test_block = [
['\n ', 'return', ' ', '301', ' ', 'https://$host$request_uri'],
['\n']
+4 -2
View File
@@ -26,7 +26,8 @@ class CommentHelpersTest(unittest.TestCase):
parse_raw(['not', 'even', 'a', 'comment'])))
def test_certbot_comment(self):
from certbot_nginx._internal.parser_obj import _certbot_comment, _is_certbot_comment
from certbot_nginx._internal.parser_obj import _certbot_comment
from certbot_nginx._internal.parser_obj import _is_certbot_comment
comment = _certbot_comment(None)
self.assertTrue(_is_certbot_comment(comment))
self.assertEqual(comment.dump(), COMMENT_BLOCK)
@@ -156,7 +157,8 @@ class BlockTest(unittest.TestCase):
def test_iterate_match(self):
# can match on contents while expanded
from certbot_nginx._internal.parser_obj import Block, Sentence
from certbot_nginx._internal.parser_obj import Block
from certbot_nginx._internal.parser_obj import Sentence
expected = [['thing', '1'], ['thing', '2']]
for i, elem in enumerate(self.bloc.iterate(expanded=True,
match=lambda x: isinstance(x, Sentence) and 'thing' in x.words)):
+3 -2
View File
@@ -2,8 +2,8 @@
import glob
import re
import shutil
import unittest
from typing import List
import unittest
from unittest import mock
from certbot import errors
@@ -371,7 +371,8 @@ class NginxParserTest(util.NginxTest):
["\n", "a", " ", "b", "\n"],
["c", " ", "d"],
["\n", "e", " ", "f"]])
from certbot_nginx._internal.parser import comment_directive, COMMENT_BLOCK
from certbot_nginx._internal.parser import COMMENT_BLOCK
from certbot_nginx._internal.parser import comment_directive
comment_directive(block, 1)
comment_directive(block, 0)
self.assertEqual(block.spaced, [
+1 -1
View File
@@ -2,9 +2,9 @@
import copy
import shutil
import tempfile
from unittest import mock
import josepy as jose
from unittest import mock
import pkg_resources
from certbot import util
+2 -2
View File
@@ -2,9 +2,9 @@
import datetime
import logging
import platform
from typing import cast
from typing import Any
from typing import Callable
from typing import cast
from typing import Dict
from typing import IO
from typing import List
@@ -14,11 +14,11 @@ from typing import Tuple
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric.rsa import generate_private_key
import josepy as jose
import OpenSSL
from josepy import ES256
from josepy import ES384
from josepy import ES512
from josepy import RS256
import OpenSSL
from acme import client as acme_client
from acme import crypto_util as acme_crypto_util
+1 -1
View File
@@ -1,8 +1,8 @@
"""Certbot main entry point."""
# pylint: disable=too-many-lines
import copy
from contextlib import contextmanager
import copy
import functools
import logging.handlers
import sys
+1 -1
View File
@@ -18,8 +18,8 @@ from typing import Union
import configobj
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
from cryptography.hazmat.primitives.serialization import load_pem_private_key
import parsedatetime
import pkg_resources
+1 -1
View File
@@ -8,8 +8,8 @@ import stat
import sys
from typing import Any
from typing import Dict
from typing import List
from typing import Generator
from typing import List
from typing import Optional
try:
-1
View File
@@ -24,7 +24,6 @@ from certbot import util
from certbot.compat.os import getenv
from certbot.interfaces import RenewableCert
logger = logging.getLogger(__name__)
+1 -2
View File
@@ -19,12 +19,11 @@ from typing import TypeVar
import pkg_resources
from acme import challenges
from certbot import achallenges
from certbot import configuration
from certbot import crypto_util
from certbot import interfaces
from certbot import errors
from certbot import interfaces
from certbot import reverter
from certbot._internal import constants
from certbot.compat import filesystem
+1 -1
View File
@@ -2,10 +2,10 @@
from typing import Any
from typing import Mapping
from typing import TYPE_CHECKING
from unittest import mock
import configobj
import josepy as jose
from unittest import mock
from acme import challenges
from certbot import achallenges
+1 -1
View File
@@ -9,12 +9,12 @@ import sys
import tempfile
from typing import Any
from typing import Callable
from typing import Union
from typing import cast
from typing import IO
from typing import Iterable
from typing import List
from typing import Optional
from typing import Union
import unittest
from unittest import mock
+1 -2
View File
@@ -2,9 +2,9 @@
import datetime
import json
import unittest
from unittest import mock
import josepy as jose
from unittest import mock
import pytz
from acme import messages
@@ -14,7 +14,6 @@ from certbot.compat import misc
from certbot.compat import os
import certbot.tests.util as test_util
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
+1 -1
View File
@@ -2,9 +2,9 @@
import datetime
import logging
import unittest
from unittest import mock
from josepy import b64encode
from unittest import mock
from acme import challenges
from acme import client as acme_client
+8 -4
View File
@@ -5,11 +5,12 @@ import re
import shutil
import tempfile
import unittest
import configobj
from unittest import mock
from certbot import errors, configuration
import configobj
from certbot import configuration
from certbot import errors
from certbot._internal.storage import ALL_FOUR
from certbot.compat import filesystem
from certbot.compat import os
@@ -247,9 +248,11 @@ class CertificatesTest(BaseCertManagerTest):
def test_report_human_readable(self, mock_revoked, mock_serial):
mock_revoked.return_value = None
mock_serial.return_value = 1234567890
from certbot._internal import cert_manager
import datetime
import pytz
from certbot._internal import cert_manager
expiry = pytz.UTC.fromutc(datetime.datetime.utcnow())
cert = mock.MagicMock(lineagename="nameone")
@@ -327,6 +330,7 @@ class SearchLineagesTest(BaseCertManagerTest):
mock_renewal_conf_files.return_value = ["badfile"]
mock_renewable_cert.side_effect = errors.CertStorageError
from certbot._internal import cert_manager
# pylint: disable=protected-access
self.assertEqual(cert_manager._search_lineages(self.config, lambda x: x, "check"), "check")
self.assertTrue(mock_make_or_verify_dir.called)
-1
View File
@@ -17,7 +17,6 @@ from certbot.compat import os
import certbot.tests.util as test_util
from certbot.tests.util import TempDirTestCase
PLUGINS = disco.PluginsRegistry.find_all()
+2 -3
View File
@@ -1,6 +1,6 @@
"""Tests for certbot._internal.client."""
import datetime
import contextlib
import datetime
import platform
import shutil
import tempfile
@@ -12,13 +12,12 @@ from josepy import interfaces
from certbot import errors
from certbot import util
from certbot._internal.display import obj as display_obj
from certbot._internal import account
from certbot._internal import constants
from certbot._internal.display import obj as display_obj
from certbot.compat import os
import certbot.tests.util as test_util
KEY = test_util.load_vector("rsa512_key.pem")
CSR_SAN = test_util.load_vector("csr-san_512.pem")
+2 -1
View File
@@ -12,9 +12,9 @@ import certbot.tests.util as test_util
from certbot.tests.util import TempDirTestCase
try:
import ntsecuritycon
import win32api
import win32security
import ntsecuritycon
POSIX_MODE = False
except ImportError:
POSIX_MODE = True
@@ -471,6 +471,7 @@ class CheckPermissionsTest(test_util.TempDirTestCase):
self.assertIs(filesystem.check_owner(self.probe_path), True)
import os as std_os # pylint: disable=os-module-forbidden
# See related inline comment in certbot.compat.filesystem.check_owner method
# that explains why MyPy/PyLint check disable is needed here.
uid = std_os.getuid()
+1
View File
@@ -2,6 +2,7 @@ import pytest
from certbot._internal import cli
@pytest.fixture(autouse=True)
def reset_cli_global():
cli.set_by_cli.detector = None
+2
View File
@@ -164,6 +164,7 @@ class MakeKeyTest(unittest.TestCase):
def test_rsa(self): # pylint: disable=no-self-use
# RSA Key Type Test
from certbot.crypto_util import make_key
# Do not test larger keys as it takes too long.
OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, make_key(1024))
@@ -180,6 +181,7 @@ class MakeKeyTest(unittest.TestCase):
def test_bad_key_sizes(self):
from certbot.crypto_util import make_key
# Try a bad key size for RSA and ECDSA
with self.assertRaises(errors.Error) as e:
make_key(bits=512, key_type='rsa')
+1 -2
View File
@@ -8,15 +8,14 @@ import josepy as jose
from acme import messages
from certbot import errors
from certbot._internal.display import obj as display_obj
from certbot._internal import account
from certbot._internal.display import obj as display_obj
from certbot.compat import filesystem
from certbot.compat import os
from certbot.display import ops
from certbot.display import util as display_util
import certbot.tests.util as test_util
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
-1
View File
@@ -12,7 +12,6 @@ from certbot._internal import account
from certbot._internal import constants
import certbot.tests.util as test_util
_KEY = josepy.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
+2 -2
View File
@@ -3,9 +3,9 @@ import unittest
from unittest import mock
from certbot import errors
from certbot._internal.cli import HelpfulArgumentParser
from certbot._internal.cli import _DomainsAction
from certbot._internal import constants
from certbot._internal.cli import _DomainsAction
from certbot._internal.cli import HelpfulArgumentParser
class TestScanningFlags(unittest.TestCase):
+2 -2
View File
@@ -17,7 +17,6 @@ from certbot.compat import os
from certbot.tests import util as test_util
class PreArgParseSetupTest(unittest.TestCase):
"""Tests for certbot._internal.log.pre_arg_parse_setup."""
@@ -79,7 +78,8 @@ class PostArgParseSetupTest(test_util.ConfigTestCase):
from certbot._internal.log import ColoredStreamHandler
self.stream_handler = ColoredStreamHandler(io.StringIO())
from certbot._internal.log import MemoryHandler, TempHandler
from certbot._internal.log import MemoryHandler
from certbot._internal.log import TempHandler
self.temp_handler = TempHandler()
self.temp_path = self.temp_handler.path
self.memory_handler = MemoryHandler(self.temp_handler)
+2 -3
View File
@@ -19,7 +19,8 @@ import josepy as jose
import pytz
from acme.messages import Error as acme_error
from certbot import crypto_util, configuration
from certbot import configuration
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
@@ -36,8 +37,6 @@ from certbot.compat import os
from certbot.plugins import enhancements
import certbot.tests.util as test_util
CERT_PATH = test_util.vector_path('cert_512.pem')
CERT = test_util.vector_path('cert_512.pem')
CSR = test_util.vector_path('csr_512.der')
-1
View File
@@ -17,7 +17,6 @@ import pytz
from certbot import errors
from certbot.tests import util as test_util
out = """Missing = in header key=value
ocsp: Use -help for summary.
"""
-1
View File
@@ -13,7 +13,6 @@ from certbot._internal.plugins import null
from certbot._internal.plugins import standalone
from certbot._internal.plugins import webroot
EP_SA = pkg_resources.EntryPoint(
"sa", "certbot._internal.plugins.standalone",
attrs=("Authenticator",),
-1
View File
@@ -12,7 +12,6 @@ from certbot.compat import os
from certbot.tests import util as test_util
class PluginStorageTest(test_util.ConfigTestCase):
"""Test for certbot.plugins.storage.PluginStorage"""
+1
View File
@@ -32,6 +32,7 @@ class AuthenticatorTest(unittest.TestCase):
def setUp(self):
from certbot._internal.plugins.webroot import Authenticator
# On Linux directories created by tempfile.mkdtemp inherit their permissions from their
# parent directory. So the actual permissions are inconsistent over various tests env.
# To circumvent this, a dedicated sub-workspace is created under the workspace, using
+2 -1
View File
@@ -4,7 +4,8 @@ import unittest
from unittest import mock
from acme import challenges
from certbot import errors, configuration
from certbot import configuration
from certbot import errors
from certbot._internal import storage
import certbot.tests.util as test_util
+1
View File
@@ -278,6 +278,7 @@ class TestFullCheckpointsReverter(test_util.ConfigTestCase):
def setUp(self):
super().setUp()
from certbot.reverter import Reverter
# Disable spurious errors...
logging.disable(logging.CRITICAL)
+1
View File
@@ -121,6 +121,7 @@ class LockDirUntilExit(test_util.TempDirTestCase):
registered_func = mock_register.call_args[0][0]
from certbot import util
# Despite lock_dir_until_exit has been called twice to subdir, its lock should have been
# added only once. So we expect to have two lock references: for self.tempdir and subdir
self.assertEqual(len(util._LOCKS), 2) # pylint: disable=protected-access
+1 -2
View File
@@ -41,10 +41,9 @@ import urllib.request as urllib_request
import boto3
from botocore.exceptions import ClientError
import yaml
from fabric import Config
from fabric import Connection
import yaml
# Command line parser
#-------------------------------------------------------------------------------
+4 -1
View File
@@ -5,7 +5,10 @@ Provides a simple utility for determining the Certbot version number
"""
from __future__ import print_function
from os.path import abspath, dirname, join
from os.path import abspath
from os.path import dirname
from os.path import join
import re
-1
View File
@@ -4,7 +4,6 @@
import hashlib
import os
# Relative to the root of the Certbot repo, these files are expected to exist
# and have the SHA-256 hashes contained in this dictionary. These hashes were
# taken from our v1.14.0 tag which was the last release we intended to make
+2 -2
View File
@@ -26,16 +26,16 @@ release with that name already exists.
"""
import argparse
import getpass
import glob
import os.path
import re
import subprocess
import sys
import tempfile
import getpass
from azure.devops.connection import Connection
from zipfile import ZipFile
from azure.devops.connection import Connection
import requests
# Path to the root directory of the Certbot repository containing this script
+1
View File
@@ -10,6 +10,7 @@ import re
import subprocess
import sys
def call_with_print(command):
print(command)
subprocess.check_call(command, shell=True)