Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: SAPCC: extra config to distinguish soon expiring certs #198

Draft
wants to merge 1 commit into
base: stable/xena-m3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions manila/share/drivers/netapp/dataontap/client/client_cmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,24 @@
cfg.ListOpt(
"cifs_cert_pem_paths",
default=[
"/etc/ssl/certs/SAPNetCA_G2.pem",
"/etc/ssl/certs/SAP_Global_Root_CA.pem",
"/etc/ssl/certs/SAP_Global_Sub_CA_02.pem",
"/etc/ssl/certs/ca-certificates.crt",
# "/etc/ssl/certs/SAPNetCA_G2.pem",
# "/etc/ssl/certs/SAP_Global_Root_CA.pem",
# "/etc/ssl/certs/SAP_Global_Sub_CA_02.pem",
# "/etc/ssl/certs/DigiCert_Global_Root_CA.pem",
# "/etc/ssl/certs/DigiCert_Global_Root_G2.pem",
],
help="Path to the x509 certificate used for secure ldap "
"connections."),
cfg.ListOpt(
"cifs_cert_pem_paths_expiring_soon",
default=[
"/etc/ssl/certs/SAP_Global_Sub_CA_04.pem",
"/etc/ssl/certs/SAP_Global_Sub_CA_05.pem",
"/etc/ssl/certs/DigiCert_Global_Root_CA.pem",
"/etc/ssl/certs/DigiCert_Global_Root_G2.pem",
],
help="Path to the x509 certificate used for secure ldap "
"connections.")
"connections, that are soon expiring. You may keep certs here in "
"the last 60 days of validity"),
]

CONF.register_opts(client_cmode_opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from unittest import mock

import ddt
from oslo_config import cfg
from oslo_log import log
import six

Expand All @@ -31,6 +32,7 @@
from manila import test
from manila.tests.share.drivers.netapp.dataontap.client import fakes as fake

CONF = cfg.CONF

@ddt.ddt
class NetAppClientCmodeTestCase(test.TestCase):
Expand Down Expand Up @@ -2663,12 +2665,17 @@ def __call__(self, *args, **kwargs):
mock.call('export-rule-create', export_rule_create_args),
mock.call('export-rule-create', export_rule_create_args2)])

def test_configure_certificates(self):
@ddt.data(
(CONF.cifs_cert_pem_paths, 60), # fail if expiring in 60 days
(CONF.cifs_cert_pem_paths_expiring_soon, -30) # fail if exp 30 days ago
)
@ddt.unpack
def test_configure_certificates(self, cert_pem_paths, expiry_threshold):
from cryptography import x509
import datetime
import os

for cert_pem_path in self.client._cert_pem_paths:
for cert_pem_path in cert_pem_paths:
self.assertTrue(os.path.exists(cert_pem_path),
f'{cert_pem_path} not found')

Expand All @@ -2689,7 +2696,7 @@ def test_configure_certificates(self):
until_expiry = cert_will_expire_at - datetime.datetime.utcnow()

self.assertTrue(
until_expiry > datetime.timedelta(days=60),
until_expiry > datetime.timedelta(days=expiry_threshold),
f'cert {cert_pem_path} will expire in {until_expiry} '
f'at {cert_will_expire_at}')

Expand Down