Skip to content

Commit

Permalink
Merge pull request #1200 from MylesJP/master
Browse files Browse the repository at this point in the history
Add cinder tests for audit middleware
  • Loading branch information
ajkavanagh authored Apr 29, 2024
2 parents 2e0beac + f090ca6 commit 0271cc2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions zaza/openstack/charm_tests/cinder/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,46 @@ def verify(stdin, stdout, stderr):
'lsblk -sn -o SIZE /dev/vdb',
privkey=privkey, verify=verify)

def test_300_apipaste_includes_audit_section(self):
"""Test api-paste.ini renders audit section when enabled."""
service_name = 'cinder'
api_paste_ini_path = f"/etc/{service_name}/api-paste.ini"
expected_content = [
"[filter:audit]",
"paste.filter_factory = keystonemiddleware.audit:filter_factory",
f"audit_map_file = /etc/{service_name}/api_audit_map.conf",
f"service_name = {service_name}"
]

set_default = {'audit-middleware': False}
set_alternate = {'audit-middleware': True}

with self.config_change(set_default, set_alternate):
try:
api_paste_content = zaza.model.file_contents(
self.lead_unit,
api_paste_ini_path,
)
except Exception as e:
self.fail("Error fetching api-paste.ini: {}".format(str(e)))
for line in expected_content:
self.assertIn(line, api_paste_content)

def test_301_apipaste_excludes_audit_section(self):
"""Test api_paste.ini does not render audit section when disabled."""
service_name = 'cinder'
section_heading = '[filter:audit]'
api_paste_ini_path = f"/etc/{service_name}/api-paste.ini"

try:
api_paste_content = zaza.model.file_contents(
self.lead_unit,
api_paste_ini_path
)
except Exception as e:
self.fail("Error fetching api-paste.ini: {}".format(str(e)))
self.assertNotIn(section_heading, api_paste_content)

@property
def services(self):
"""Return a list services for the selected OpenStack release."""
Expand Down

0 comments on commit 0271cc2

Please sign in to comment.