Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcrawford45 committed Nov 3, 2023
1 parent 7d43192 commit 7d4908b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lemur/certificates/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,8 @@ def query_common_name(common_name, args):

def get_ekus(csr: str):
"""Given a csr PEM, return the """
csr = x509.load_pem_x509_csr(csr.encode(), default_backend())
return csr.extensions.get_extension_for_class(x509.ExtendedKeyUsage)
csr_obj = x509.load_pem_x509_csr(csr.encode(), default_backend())
return csr_obj.extensions.get_extension_for_class(x509.ExtendedKeyUsage)


def create_csr(**csr_config):
Expand Down
10 changes: 6 additions & 4 deletions lemur/plugins/lemur_entrust/tests/test_entrust.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_process_options(mock_current_app, authority):
assert expected == plugin.process_options(options, client_id)



@patch("lemur.plugins.lemur_entrust.plugin.current_app")
@patch("cryptography.x509.load_pem_x509_csr")
def test_process_options_infer_eku(mock_load_pem, mock_current_app, authority):
Expand Down Expand Up @@ -102,14 +101,17 @@ def test_process_options_infer_eku(mock_load_pem, mock_current_app, authority):
both_eku_ext = x509.ExtendedKeyUsage([client_auth_oid, server_auth_oid])

mock_csr = Mock(spec=CertificateSigningRequest)
mock_csr.extensions = Extensions([Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=both_eku_ext)])
mock_csr.extensions = Extensions(
[Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=both_eku_ext)])
mock_load_pem.return_value = mock_csr
assert plugin.process_options(options, client_id, csr)['eku'] == 'SERVER_AND_CLIENT_AUTH'

mock_csr.extensions = Extensions([Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=client_eku_ext)])
mock_csr.extensions = Extensions(
[Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=client_eku_ext)])
assert plugin.process_options(options, client_id, csr)['eku'] == 'CLIENT_AUTH'

mock_csr.extensions = Extensions([Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=server_eku_ext)])
mock_csr.extensions = Extensions(
[Extension(oid=x509.oid.ExtensionOID.EXTENDED_KEY_USAGE, critical=False, value=server_eku_ext)])
assert plugin.process_options(options, client_id, csr)['eku'] == 'SERVER_AUTH'


Expand Down

0 comments on commit 7d4908b

Please sign in to comment.