Skip to content

Commit

Permalink
Move Testing of Debug Logging to Alter
Browse files Browse the repository at this point in the history
Move Testing of debug logging to Alter in Group, DataSet and Resource Admins

Signed-off-by: Elijah Swift <elijah.swift@ibm.com>
  • Loading branch information
ElijahSwiftIBM committed Oct 26, 2023
1 parent 58e391b commit 1b1a1bd
Show file tree
Hide file tree
Showing 47 changed files with 1,996 additions and 773 deletions.
22 changes: 17 additions & 5 deletions pyracf/data_set/data_set_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List, Union

from pyracf.common.add_operation_error import AddOperationError
from pyracf.common.alter_operation_error import AlterOperationError
from pyracf.common.security_admin import SecurityAdmin
from pyracf.common.security_request_error import SecurityRequestError
Expand Down Expand Up @@ -99,15 +100,26 @@ def get_my_access(self, data_set: str) -> Union[str, bytes, None]:
def add(
self,
data_set: str,
traits: dict,
traits: dict = {},
volume: Union[str, None] = None,
generic: bool = False,
) -> Union[dict, bytes]:
"""Create a new data set profile."""
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)
try:
self.extract(data_set, volume=volume, generic=generic)
except SecurityRequestError as exception:
if not exception.scan_for_error("dataSet", "ICH35003I"):
raise exception
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)
raise AddOperationError(data_set, "DATASET")

def alter(
self,
Expand Down
24 changes: 18 additions & 6 deletions pyracf/group/group_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List, Union

from pyracf.common.add_operation_error import AddOperationError
from pyracf.common.alter_operation_error import AlterOperationError
from pyracf.common.security_admin import SecurityAdmin
from pyracf.common.security_request_error import SecurityRequestError
Expand Down Expand Up @@ -121,12 +122,23 @@ def set_ovm_gid(self, group: str, gid: int) -> Union[dict, bytes]:
# ============================================================================
def add(self, group: str, traits: dict = {}) -> Union[dict, bytes]:
"""Create a new group."""
self._build_segment_dictionaries(traits)
group_request = GroupRequest(group, "set")
self._build_xml_segments(group_request)
return self._make_request(group_request)

def alter(self, group: str, traits: dict = {}) -> Union[dict, bytes]:
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
group_request = GroupRequest(group, "set")
self._build_xml_segments(group_request)
return self._make_request(group_request)
try:
self.extract(group)
except SecurityRequestError as exception:
if not exception.scan_for_error("group", "ICH51003I"):
raise exception
self._build_segment_dictionaries(traits)
group_request = GroupRequest(group, "set")
self._build_xml_segments(group_request)
return self._make_request(group_request)
raise AddOperationError(group, "GROUP")

def alter(self, group: str, traits: dict) -> Union[dict, bytes]:
"""Alter an existing group."""
try:
self.extract(group)
Expand Down
24 changes: 17 additions & 7 deletions pyracf/resource/resource_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List, Union

from pyracf.common.add_operation_error import AddOperationError
from pyracf.common.alter_operation_error import AlterOperationError
from pyracf.common.security_admin import SecurityAdmin
from pyracf.common.security_request_error import SecurityRequestError
Expand Down Expand Up @@ -222,14 +223,23 @@ def add(
self, resource: str, class_name: str, traits: dict = {}
) -> Union[dict, bytes]:
"""Create a new general resource profile."""
self._build_segment_dictionaries(traits)
profile_request = ResourceRequest(resource, class_name, "set")
self._build_xml_segments(profile_request)
return self._make_request(profile_request)
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
profile_request = ResourceRequest(resource, class_name, "set")
self._build_xml_segments(profile_request)
return self._make_request(profile_request)
try:
self.extract(resource, class_name)
except SecurityRequestError as exception:
if not exception.scan_for_error("resource", "ICH13003I"):
raise exception
self._build_segment_dictionaries(traits)
profile_request = ResourceRequest(resource, class_name, "set")
self._build_xml_segments(profile_request)
return self._make_request(profile_request)
raise AddOperationError(resource, class_name)

def alter(
self, resource: str, class_name: str, traits: dict = {}
) -> Union[dict, bytes]:
def alter(self, resource: str, class_name: str, traits: dict) -> Union[dict, bytes]:
"""Alter an existing general resource profile."""
try:
self.extract(resource, class_name)
Expand Down
2 changes: 1 addition & 1 deletion pyracf/user/user_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def add(self, userid: str, traits: dict = {}) -> Union[dict, bytes]:
return self._make_request(user_request)
raise AddOperationError(userid, "USER")

def alter(self, userid: str, traits: dict = {}) -> Union[dict, bytes]:
def alter(self, userid: str, traits: dict) -> Union[dict, bytes]:
"""Alter an existing user."""
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
Expand Down
101 changes: 0 additions & 101 deletions tests/data_set/data_set_log_samples/add_data_set_error.log

This file was deleted.

93 changes: 0 additions & 93 deletions tests/data_set/data_set_log_samples/add_data_set_success.log

This file was deleted.

Loading

0 comments on commit 1b1a1bd

Please sign in to comment.