Skip to content

Commit

Permalink
feat: adds responsible role population in docx template
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Apr 25, 2024
1 parent c2daaf0 commit 456e236
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_ssp_control_dict() -> Iterator[FedrampControlDict]:
},
control_origination=[const.FEDRAMP_SP_CORPORATE, const.FEDRAMP_INHERITED],
implementation_status=const.FEDRAMP_PARTIAL,
responsible_roles=['Admin, Customer']
responsible_roles=['Admin', 'Customer']
),
'CM-6': FedrampSSPData(
control_implementation_description={
Expand Down
9 changes: 9 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,12 @@ def verify_parameters(summary_table: Table, parameters: Dict[str, str], partial_
assert value in row.text
else:
assert value == row.text


def verify_responsible_roles(responsible_roles: _Cell, ssp_data: FedrampSSPData) -> None:
"""Verify the responsible roles are populated correctly."""
if not ssp_data.responsible_roles:
assert responsible_roles.text == 'Responsible Role:'
else:
expected_roles = ', '.join(ssp_data.responsible_roles)
assert responsible_roles.text == 'Responsible Role: ' + expected_roles
2 changes: 2 additions & 0 deletions tests/trestle_fedramp/core/docx_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
verify_implementation_status_checkboxes,
verify_parameters,
verify_responses,
verify_responsible_roles
)

from trestle.common.err import TrestleError
Expand All @@ -50,6 +51,7 @@ def test_fedramp_docx_populate(docx_document: DocxDocument, test_ssp_control_dic
verify_implementation_status_checkboxes(table.cell(*control_summaries._implementation_status_cell), data)
# Check that the parameters are in the cell text (partial match)
verify_parameters(table, data.parameters, partial_match=True)
verify_responsible_roles(table.cell(*control_summaries._responsible_role_cell), data)
if control_implementation_description.is_control_implementation_table(row_header):
control_id = fedramp_docx.get_control_id(row_header)
data = test_ssp_control_dict.get(control_id, FedrampSSPData({}, {}, None, None, None))
Expand Down
5 changes: 5 additions & 0 deletions trestle_fedramp/core/docx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self) -> None:
const.FEDRAMP_NOT_APPLICABLE: 5
}
self._parameter_start_row = 2
self._responsible_role_cell: Tuple[int, int] = (1, 0)

@staticmethod
def is_control_summary_table(row_header: str) -> bool:
Expand Down Expand Up @@ -211,6 +212,10 @@ def populate_table(self, table: Table, control_id: str, ssp_data: FedrampSSPData
self._set_implementation_status(implementation_status_cell, ssp_data.implementation_status)
if ssp_data.parameters:
self._set_parameter_values(table, ssp_data.parameters)
if ssp_data.responsible_roles:
responsible_role_cell: _Cell = table.cell(*self._responsible_role_cell)
responsible_role_str = ', '.join(ssp_data.responsible_roles)
responsible_role_cell.text = f'{responsible_role_cell.text} {responsible_role_str}'
except Exception as e:
raise TrestleError(f'Error populating control summary for {control_id}: {e}')

Expand Down

0 comments on commit 456e236

Please sign in to comment.