Skip to content

Commit

Permalink
feat: Added Cloud Browser Isolation Endpoints and Tests (#89)
Browse files Browse the repository at this point in the history
* feat: Added Cloud Browser Isolation Endpoints and Tests

* feat: Added Cloud Browser Isolation Endpoints and Tests

* feat: Added Cloud Browser Isolation Endpoints and Tests

* feat: Added Cloud Browser Isolation Endpoints and Tests
  • Loading branch information
willguibr authored May 14, 2024
1 parent 0d09cf3 commit 2185263
Show file tree
Hide file tree
Showing 34 changed files with 2,946 additions and 774 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zia-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- ZIA_ZSCLOUD
- ZIA_ZS0
- ZIA_ZS1
- ZIA_ZS2
# - ZIA_ZS2
- ZIA_ZS3
environment: ${{ matrix.environment }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions docsrc/zs/zpa/idp.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IDP Controller API
-------------------
idp
---------------

The following methods allow for interaction with the ZPA IDP Controller API endpoints.

Expand Down
14 changes: 14 additions & 0 deletions docsrc/zs/zpa/isolation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
isolation
----------

The following methods allow for interaction with the ZPA
Cloud Browser Isolation Controller API endpoints.

Methods are accessible via ``zpa.isolation``

.. _zpa-isolation:

.. automodule:: zscaler.zpa.isolation
:members:
:undoc-members:
:show-inheritance:
14 changes: 0 additions & 14 deletions docsrc/zs/zpa/isolation_profile.rst

This file was deleted.

116 changes: 115 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pydash = "*"
flake8 = "*"
pytz = "*"
black = "^24.4.1"
cryptography = "^3.4"

[tool.poetry.dev-dependencies]
black = "*"
Expand Down
94 changes: 94 additions & 0 deletions tests/integration/zpa/test_app_protection_custom_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2023, Zscaler Inc.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import pytest

from tests.integration.zpa.conftest import MockZPAClient
from tests.test_utils import generate_random_string


@pytest.fixture
def fs():
yield


class TestAppProtectionCustomControl:
"""
Integration Tests for the App Protection Custom Control
"""

def test_app_protection_custom_control(self, fs):
client = MockZPAClient(fs)
errors = [] # Initialize an empty list to collect errors

control_name = "tests-" + generate_random_string()
control_id = None # Define control_id here to ensure it's accessible throughout

try:
# Create a new custom control
created_control = client.inspection.add_custom_control(
name=control_name,
description=control_name,
action="PASS",
default_action="PASS",
paranoia_level="1",
severity="CRITICAL",
type="RESPONSE",
rules=[
{
"names": ["test"],
"type": "RESPONSE_HEADERS",
"conditions": [
{"lhs": "SIZE", "op": "GE", "rhs": "1000"},
],
},
{
"type": "RESPONSE_BODY",
"conditions": [{"lhs": "SIZE", "op": "GE", "rhs": "1000"}],
},
],
)
if created_control and "id" in created_control:
control_id = created_control.id
assert control_id is not None # Asserting that a non-null ID is returned
else:
errors.append("Custom control creation failed or returned unexpected data")

# Assuming control_id is valid and the banner was created successfully
if control_id:
# Update the custom control
updated_name = control_name + " Updated"
client.inspection.update_custom_control(control_id, name=updated_name)
updated_control = client.inspection.get_custom_control(control_id)
assert updated_control.name == updated_name # Verify update by checking the updated attribute

# List custom controls and ensure the updated banner is in the list
controls_list = client.inspection.list_custom_controls()
assert any(control.id == control_id for control in controls_list)

except Exception as exc:
errors.append(exc)

finally:
# Cleanup resources
if control_id:
try:
client.inspection.delete_custom_control(control_id=control_id)
except Exception as exc:
errors.append(f"Deleting custom control failed: {exc}")

# Assert that no errors occurred during the test
assert not errors, f"Errors occurred during the custom control lifecycle test: {errors}"
Loading

0 comments on commit 2185263

Please sign in to comment.