Skip to content

Commit

Permalink
fix: Fixed privileged remote access add_portal method return response (
Browse files Browse the repository at this point in the history
…#86)

Fixed privileged remote access add_portal method return response
  • Loading branch information
willguibr authored May 9, 2024
1 parent 44aeae1 commit a8391f6
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 39 deletions.
5 changes: 3 additions & 2 deletions .github/set-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ fi
NEW_VERSION=$(echo "$1" | sed -e 's/-beta\./.b/' | sed -e 's/-alpha\./.a/')

# Set version in pyproject.toml
grep -E '^version = ".+"$' "$ROOT/pyproject.toml" >/dev/null
sed -i.bak -E "s/^version = \".+\"$/version = \"$NEW_VERSION\"/" "$ROOT/pyproject.toml" && rm "$ROOT/pyproject.toml.bak"
echo "Updating pyproject.toml"
grep -E '^version = ".+"$' "$ROOT/pyproject.toml" || exit 1
sed -i.bak -E "s/^version = \".+\"$/version = \"$1\"/" "$ROOT/pyproject.toml" && rm "$ROOT/pyproject.toml.bak"

# Set version in __init__.py
grep -E '^__version__ = ".+"$' "$ROOT/zscaler/__init__.py" >/dev/null
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/zpa/test_access_policy_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_access_policy_rules(self, fs):
name=connector_group_name,
description=connector_group_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/zpa/test_application_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_application_segment(self, fs):
name=app_connector_group_name,
description=app_connector_group_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/zpa/test_pra_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_pra_approval(self, fs):
name=app_connector_group_name,
description=app_connector_group_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_provisioning_key_operations(self, fs):
name=connector_group_name,
description=connector_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_provisioning_key_operations(self, fs):
name=svc_edge_group_name,
description=svc_edge_group_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/zpa/test_server_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_server_group(self, fs):
name=connector_group_name,
description=connector_group_description,
enabled=True,
latitude = "37.33874",
longitude = "-121.8852525",
latitude="37.33874",
longitude="-121.8852525",
location="San Jose, CA, USA",
upgrade_day="SUNDAY",
upgrade_time_in_secs="66600",
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/zpa/test_service_edge_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ def test_service_edge_group(self, fs):
client = MockZPAClient(fs)
errors = [] # Initialize an empty list to collect errors

group_name = "tests-" + generate_random_string(),
group_description = "tests-" + generate_random_string(),
group_enabled = True,
latitude = "37.33874",
longitude = "-121.8852525",
location = "San Jose, CA, USA",
upgrade_day = "SUNDAY",
upgrade_time_in_secs = "66600",
override_version_profile = True,
version_profile_name = "Default",
version_profile_id = "0",
is_public = "TRUE",
group_id = None
group_name = ("tests-" + generate_random_string(),)
group_description = ("tests-" + generate_random_string(),)
group_enabled = (True,)
latitude = ("37.33874",)
longitude = ("-121.8852525",)
location = ("San Jose, CA, USA",)
upgrade_day = ("SUNDAY",)
upgrade_time_in_secs = ("66600",)
override_version_profile = (True,)
version_profile_name = ("Default",)
version_profile_id = ("0",)
is_public = ("TRUE",)
group_id = None

try:
# Create a new service edge group
Expand Down
4 changes: 2 additions & 2 deletions zscaler/zpa/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_rule(self, policy_type: str, rule_id: str) -> Box:
| ``credential``
| ``capabilities``
| ``siem``
rule_id (str): The unique identifier for the policy rule.
Returns:
Expand Down Expand Up @@ -255,7 +255,7 @@ def delete_rule(self, policy_type: str, rule_id: str) -> int:
| ``credential``
| ``capabilities``
| ``siem``
rule_id (str):
The unique identifier for the policy rule.
Expand Down
15 changes: 5 additions & 10 deletions zscaler/zpa/privileged_remote_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ def add_portal(
for key, value in kwargs.items():
payload[snake_to_camel(key)] = value

response = self.rest.post("/praPortal", json=payload)
response = self.rest.post("praPortal", json=payload)
if isinstance(response, Response):
# this is only true when the creation failed (status code is not 2xx)
status_code = response.status_code
if status_code > 299:
return None
return self.get_portal(response.get("id"))
# Handle error response
raise Exception(f"API call failed with status {status_code}: {response.json()}")
return response

def update_portal(self, portal_id: str, **kwargs) -> Box:
"""
Expand Down Expand Up @@ -475,12 +476,6 @@ def get_credential(self, credential_id: str) -> Box:
"""
return self.rest.get(f"credential/{credential_id}")
# response = self.rest.get("/credential/%s" % (credential_id))
# if isinstance(response, Response):
# status_code = response.status_code
# if status_code != 200:
# return None
# return response

def add_credential(
self,
Expand Down

0 comments on commit a8391f6

Please sign in to comment.