testzeus-cli 0.0.25__tar.gz → 0.0.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- testzeus_cli-0.0.25/README.md → testzeus_cli-0.0.26/PKG-INFO +81 -0
- testzeus_cli-0.0.25/PKG-INFO → testzeus_cli-0.0.26/README.md +51 -30
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/pyproject.toml +4 -4
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/cli.py +6 -0
- testzeus_cli-0.0.26/testzeus_cli/commands/agent_harness.py +259 -0
- testzeus_cli-0.0.26/testzeus_cli/commands/connected_environments.py +447 -0
- testzeus_cli-0.0.26/testzeus_cli/commands/test_report_runs.py +164 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/LICENSE +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/__init__.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/auth.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/__init__.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/daemon.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/device_pool.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/environments.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/extensions.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/knowledge_bases.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/notification_channels.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/tags.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_data.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_report_schedules.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_run_groups.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_runs.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_suite_runs.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_suite_schedules.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/test_suites.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/tests.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/tests_ai_generator.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/tests_authoring.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/commands/user_integrations.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/config.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/__init__.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/auth.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/client.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/files.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/formatters.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/links.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/profile.py +0 -0
- {testzeus_cli-0.0.25 → testzeus_cli-0.0.26}/testzeus_cli/utils/validators.py +0 -0
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: testzeus-cli
|
|
3
|
+
Version: 0.0.26
|
|
4
|
+
Summary: Command-line interface for TestZeus testing platform
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Author: Shriyansh Agnihotri
|
|
7
|
+
Author-email: shriyansh@testzeus.com
|
|
8
|
+
Requires-Python: >=3.11,<3.14
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Provides-Extra: daemon
|
|
15
|
+
Requires-Dist: Pygments (==2.20.0)
|
|
16
|
+
Requires-Dist: aiohttp (>=3.14.1,<4.0.0)
|
|
17
|
+
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
18
|
+
Requires-Dist: cryptography (>=48.0.1,<49.0.0)
|
|
19
|
+
Requires-Dist: ipdb (>=0.13.13,<0.14.0)
|
|
20
|
+
Requires-Dist: keyring (>=24.0.0,<25.0.0)
|
|
21
|
+
Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
|
|
22
|
+
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
23
|
+
Requires-Dist: pyyaml (>=6.0,<7.0)
|
|
24
|
+
Requires-Dist: rich (>=13.3.1,<14.0.0)
|
|
25
|
+
Requires-Dist: testzeus-sdk (>=0.0.24,<0.1.0)
|
|
26
|
+
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
27
|
+
Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
1
30
|
# TestZeus CLI
|
|
2
31
|
|
|
3
32
|
A powerful command-line interface for the TestZeus testing platform.
|
|
@@ -937,6 +966,57 @@ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
|
|
|
937
966
|
|
|
938
967
|
See `testzeus_cli/commands/tests_authoring.py` for implementation.
|
|
939
968
|
|
|
969
|
+
## Agent Harness
|
|
970
|
+
|
|
971
|
+
Adversarial testing of AI agents (Salesforce Agentforce). List agents, list or
|
|
972
|
+
generate adversarial pathways, run simulations, and monitor / cancel them. Sits
|
|
973
|
+
on the `client.agent_harness` SDK manager.
|
|
974
|
+
|
|
975
|
+
### List Agents
|
|
976
|
+
|
|
977
|
+
```bash
|
|
978
|
+
testzeus agent-harness list-agents
|
|
979
|
+
testzeus agent-harness list-agents --status active --search billing
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
### Get Agent Details
|
|
983
|
+
|
|
984
|
+
```bash
|
|
985
|
+
testzeus agent-harness get-agent <agent_id>
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
### Pathways
|
|
989
|
+
|
|
990
|
+
```bash
|
|
991
|
+
# List adversarial pathways for an agent
|
|
992
|
+
testzeus agent-harness list-pathways <agent_id>
|
|
993
|
+
|
|
994
|
+
# Start an AI pathway-generation job for a Salesforce agent profile
|
|
995
|
+
testzeus agent-harness generate-pathways <agent_profile> --prompt "probe for PII leaks" --num 5
|
|
996
|
+
|
|
997
|
+
# Soft-delete a pathway
|
|
998
|
+
testzeus agent-harness delete-pathway <pathway_id>
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
### Run Simulations
|
|
1002
|
+
|
|
1003
|
+
```bash
|
|
1004
|
+
# Start a run over one or more pathways
|
|
1005
|
+
testzeus agent-harness run <agent_id> --pathway <pathway_id> --pathway <pathway_id>
|
|
1006
|
+
|
|
1007
|
+
# Run and wait for it to finish (polls status)
|
|
1008
|
+
testzeus agent-harness run <agent_id> --pathway <pathway_id> --wait --timeout 1800
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
### Monitor and Cancel
|
|
1012
|
+
|
|
1013
|
+
```bash
|
|
1014
|
+
testzeus agent-harness status <group_id>
|
|
1015
|
+
testzeus agent-harness cancel <group_id>
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
See `testzeus_cli/commands/agent_harness.py` for implementation.
|
|
1019
|
+
|
|
940
1020
|
## Configuration
|
|
941
1021
|
|
|
942
1022
|
The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
|
|
@@ -1090,3 +1170,4 @@ The TestZeus CLI uses GitHub Actions for automated releases to PyPI. To create a
|
|
|
1090
1170
|
- Commit and create a git tag
|
|
1091
1171
|
- Push changes and tags to GitHub
|
|
1092
1172
|
3. The tag push will automatically trigger the GitHub Actions publish workflow
|
|
1173
|
+
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: testzeus-cli
|
|
3
|
-
Version: 0.0.25
|
|
4
|
-
Summary: Command-line interface for TestZeus testing platform
|
|
5
|
-
License-File: LICENSE
|
|
6
|
-
Author: Shriyansh Agnihotri
|
|
7
|
-
Author-email: shriyansh@testzeus.com
|
|
8
|
-
Requires-Python: >=3.11,<3.14
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Provides-Extra: daemon
|
|
15
|
-
Requires-Dist: Pygments (==2.20.0)
|
|
16
|
-
Requires-Dist: aiohttp (==3.13.4)
|
|
17
|
-
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
18
|
-
Requires-Dist: cryptography (==46.0.7)
|
|
19
|
-
Requires-Dist: ipdb (>=0.13.13,<0.14.0)
|
|
20
|
-
Requires-Dist: keyring (>=24.0.0,<25.0.0)
|
|
21
|
-
Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
|
|
22
|
-
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
23
|
-
Requires-Dist: pyyaml (>=6.0,<7.0)
|
|
24
|
-
Requires-Dist: rich (>=13.3.1,<14.0.0)
|
|
25
|
-
Requires-Dist: testzeus-sdk (>=0.0.19,<0.1.0)
|
|
26
|
-
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
27
|
-
Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
|
|
28
|
-
Description-Content-Type: text/markdown
|
|
29
|
-
|
|
30
1
|
# TestZeus CLI
|
|
31
2
|
|
|
32
3
|
A powerful command-line interface for the TestZeus testing platform.
|
|
@@ -966,6 +937,57 @@ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
|
|
|
966
937
|
|
|
967
938
|
See `testzeus_cli/commands/tests_authoring.py` for implementation.
|
|
968
939
|
|
|
940
|
+
## Agent Harness
|
|
941
|
+
|
|
942
|
+
Adversarial testing of AI agents (Salesforce Agentforce). List agents, list or
|
|
943
|
+
generate adversarial pathways, run simulations, and monitor / cancel them. Sits
|
|
944
|
+
on the `client.agent_harness` SDK manager.
|
|
945
|
+
|
|
946
|
+
### List Agents
|
|
947
|
+
|
|
948
|
+
```bash
|
|
949
|
+
testzeus agent-harness list-agents
|
|
950
|
+
testzeus agent-harness list-agents --status active --search billing
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### Get Agent Details
|
|
954
|
+
|
|
955
|
+
```bash
|
|
956
|
+
testzeus agent-harness get-agent <agent_id>
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
### Pathways
|
|
960
|
+
|
|
961
|
+
```bash
|
|
962
|
+
# List adversarial pathways for an agent
|
|
963
|
+
testzeus agent-harness list-pathways <agent_id>
|
|
964
|
+
|
|
965
|
+
# Start an AI pathway-generation job for a Salesforce agent profile
|
|
966
|
+
testzeus agent-harness generate-pathways <agent_profile> --prompt "probe for PII leaks" --num 5
|
|
967
|
+
|
|
968
|
+
# Soft-delete a pathway
|
|
969
|
+
testzeus agent-harness delete-pathway <pathway_id>
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
### Run Simulations
|
|
973
|
+
|
|
974
|
+
```bash
|
|
975
|
+
# Start a run over one or more pathways
|
|
976
|
+
testzeus agent-harness run <agent_id> --pathway <pathway_id> --pathway <pathway_id>
|
|
977
|
+
|
|
978
|
+
# Run and wait for it to finish (polls status)
|
|
979
|
+
testzeus agent-harness run <agent_id> --pathway <pathway_id> --wait --timeout 1800
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
### Monitor and Cancel
|
|
983
|
+
|
|
984
|
+
```bash
|
|
985
|
+
testzeus agent-harness status <group_id>
|
|
986
|
+
testzeus agent-harness cancel <group_id>
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
See `testzeus_cli/commands/agent_harness.py` for implementation.
|
|
990
|
+
|
|
969
991
|
## Configuration
|
|
970
992
|
|
|
971
993
|
The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
|
|
@@ -1119,4 +1141,3 @@ The TestZeus CLI uses GitHub Actions for automated releases to PyPI. To create a
|
|
|
1119
1141
|
- Commit and create a git tag
|
|
1120
1142
|
- Push changes and tags to GitHub
|
|
1121
1143
|
3. The tag push will automatically trigger the GitHub Actions publish workflow
|
|
1122
|
-
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "testzeus-cli"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.26"
|
|
8
8
|
description = "Command-line interface for TestZeus testing platform"
|
|
9
9
|
authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
|
|
10
10
|
readme = "README.md"
|
|
@@ -22,12 +22,12 @@ pydantic = "^2.0.0"
|
|
|
22
22
|
pyyaml = "^6.0"
|
|
23
23
|
keyring = "^24.0.0"
|
|
24
24
|
ipdb = "^0.13.13"
|
|
25
|
-
testzeus-sdk = ">=0.0.
|
|
25
|
+
testzeus-sdk = ">=0.0.24,<0.1.0"
|
|
26
26
|
pocketbase = "^0.15.0"
|
|
27
27
|
toml = "^0.10.2"
|
|
28
|
-
aiohttp = "3.
|
|
28
|
+
aiohttp = "^3.14.1"
|
|
29
29
|
Pygments = "2.20.0"
|
|
30
|
-
cryptography = "
|
|
30
|
+
cryptography = "^48.0.1"
|
|
31
31
|
|
|
32
32
|
[tool.poetry.extras]
|
|
33
33
|
daemon = [
|
|
@@ -27,7 +27,9 @@ from testzeus_cli.commands.test_data import test_data_group
|
|
|
27
27
|
from testzeus_cli.commands.tags import tags_group
|
|
28
28
|
from testzeus_cli.commands.device_pool import device_pool_group
|
|
29
29
|
from testzeus_cli.commands.environments import environments_group
|
|
30
|
+
from testzeus_cli.commands.connected_environments import connected_environments_group
|
|
30
31
|
from testzeus_cli.commands.test_report_schedules import test_report_schedules_group
|
|
32
|
+
from testzeus_cli.commands.test_report_runs import test_report_runs_group
|
|
31
33
|
from testzeus_cli.commands.notification_channels import notification_channels_group
|
|
32
34
|
from testzeus_cli.commands.extensions import extensions_group
|
|
33
35
|
from testzeus_cli.commands.tests_ai_generator import tests_ai_generator_group
|
|
@@ -35,6 +37,7 @@ from testzeus_cli.commands.hypermind_code_blocks import hypermind_code_blocks_gr
|
|
|
35
37
|
from testzeus_cli.commands.user_integrations import user_integrations_group
|
|
36
38
|
from testzeus_cli.commands.tests_authoring import tests_authoring_group
|
|
37
39
|
from testzeus_cli.commands.knowledge_bases import knowledge_bases_group
|
|
40
|
+
from testzeus_cli.commands.agent_harness import agent_harness_group
|
|
38
41
|
|
|
39
42
|
# Daemon dependencies (fastapi/uvicorn/sse-starlette) are optional extras.
|
|
40
43
|
# Keep CLI core commands (e.g. session-exchange) functional when extras are absent.
|
|
@@ -92,7 +95,9 @@ cli.add_command(test_data_group)
|
|
|
92
95
|
cli.add_command(tags_group)
|
|
93
96
|
cli.add_command(device_pool_group)
|
|
94
97
|
cli.add_command(environments_group)
|
|
98
|
+
cli.add_command(connected_environments_group)
|
|
95
99
|
cli.add_command(test_report_schedules_group)
|
|
100
|
+
cli.add_command(test_report_runs_group)
|
|
96
101
|
cli.add_command(notification_channels_group)
|
|
97
102
|
cli.add_command(extensions_group)
|
|
98
103
|
cli.add_command(tests_ai_generator_group)
|
|
@@ -100,6 +105,7 @@ cli.add_command(hypermind_code_blocks_group)
|
|
|
100
105
|
cli.add_command(user_integrations_group)
|
|
101
106
|
cli.add_command(tests_authoring_group)
|
|
102
107
|
cli.add_command(knowledge_bases_group)
|
|
108
|
+
cli.add_command(agent_harness_group)
|
|
103
109
|
if daemon_command is not None:
|
|
104
110
|
cli.add_command(daemon_command)
|
|
105
111
|
# New command groups can be added here when implemented
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Harness commands for TestZeus CLI.
|
|
3
|
+
|
|
4
|
+
Adversarial testing of AI agents (Salesforce Agentforce): list agents, list or
|
|
5
|
+
generate adversarial pathways, run simulations, and monitor / cancel them.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
import click
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from testzeus_sdk import TestZeusClient
|
|
12
|
+
from testzeus_cli.config import get_client_config
|
|
13
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
14
|
+
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
15
|
+
from testzeus_cli.utils.validators import validate_id
|
|
16
|
+
from testzeus_cli.utils.links import print_platform_link
|
|
17
|
+
|
|
18
|
+
console = Console()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _client(ctx):
|
|
22
|
+
"""Build the config + client tuple used by every command."""
|
|
23
|
+
config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
24
|
+
return TestZeusClient(**config), token, tenant_id, user_id
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def _auth(client, token):
|
|
28
|
+
if token:
|
|
29
|
+
initialize_client_with_token(client, token)
|
|
30
|
+
else:
|
|
31
|
+
await client.ensure_authenticated()
|
|
32
|
+
if not hasattr(client, "agent_harness"):
|
|
33
|
+
raise click.ClickException("Agent Harness needs a newer testzeus-sdk. Upgrade with: pip install -U testzeus-sdk")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@click.group(name="agent-harness")
|
|
37
|
+
def agent_harness_group():
|
|
38
|
+
"""Adversarial testing of AI agents (Agent Harness)"""
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@agent_harness_group.command(name="list-agents")
|
|
43
|
+
@click.option("--page", default=1, help="Page number")
|
|
44
|
+
@click.option("--per-page", default=50, help="Results per page")
|
|
45
|
+
@click.option("--status", help="Filter by status")
|
|
46
|
+
@click.option("--search", help="Search term")
|
|
47
|
+
@click.pass_context
|
|
48
|
+
def list_agents(ctx, page, per_page, status, search):
|
|
49
|
+
"""List available agents"""
|
|
50
|
+
|
|
51
|
+
async def _run():
|
|
52
|
+
client, token, _, _ = _client(ctx)
|
|
53
|
+
async with client:
|
|
54
|
+
await _auth(client, token)
|
|
55
|
+
return await client.agent_harness.list_agents(page=page, per_page=per_page, status=status, search=search)
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
print_platform_link(ctx, "agent-harness")
|
|
59
|
+
format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
|
|
60
|
+
except Exception as e:
|
|
61
|
+
print_message(f"[red]Error listing agents: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
62
|
+
raise click.Abort()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@agent_harness_group.command(name="list-pathways")
|
|
66
|
+
@click.argument("agent_id")
|
|
67
|
+
@click.option("--page", default=1, help="Page number")
|
|
68
|
+
@click.option("--per-page", default=50, help="Results per page")
|
|
69
|
+
@click.pass_context
|
|
70
|
+
def list_pathways(ctx, agent_id, page, per_page):
|
|
71
|
+
"""List adversarial pathways for an agent"""
|
|
72
|
+
|
|
73
|
+
# NOTE: unlike the generic `list` commands (which take --filters/-f + --sort),
|
|
74
|
+
# pathways are always scoped to a single agent, so this takes an agent_id
|
|
75
|
+
# argument instead. The SDK builds the agent_id filter via the shared filter
|
|
76
|
+
# builder; add --filters/--sort here if the manager grows to support them.
|
|
77
|
+
async def _run():
|
|
78
|
+
client, token, _, _ = _client(ctx)
|
|
79
|
+
async with client:
|
|
80
|
+
await _auth(client, token)
|
|
81
|
+
agent = validate_id(agent_id, "agent")
|
|
82
|
+
res = await client.agent_harness.list_pathways(agent_id=agent, page=page, per_page=per_page)
|
|
83
|
+
# get_list returns AdversaryPathways models; unwrap to dicts for output.
|
|
84
|
+
res["items"] = [p.data for p in res.get("items", [])]
|
|
85
|
+
return res
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
print_platform_link(ctx, "agent-harness")
|
|
89
|
+
format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
|
|
90
|
+
except Exception as e:
|
|
91
|
+
print_message(f"[red]Error listing pathways: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
92
|
+
raise click.Abort()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@agent_harness_group.command(name="generate-pathways")
|
|
96
|
+
@click.argument("agent_profile")
|
|
97
|
+
@click.option("--prompt", required=True, help="Directional prompt for pathway generation")
|
|
98
|
+
@click.option("--name", help="Generation job name (auto-generated if omitted)")
|
|
99
|
+
@click.option("--agent-name", help="Agent display name")
|
|
100
|
+
@click.option("--num", type=int, help="Number of pathways to generate")
|
|
101
|
+
@click.option("--allow-destructive", is_flag=True, default=False, help="Allow destructive scenarios")
|
|
102
|
+
@click.pass_context
|
|
103
|
+
def generate_pathways(ctx, agent_profile, prompt, name, agent_name, num, allow_destructive):
|
|
104
|
+
"""Start an AI pathway-generation job for a Salesforce agent profile"""
|
|
105
|
+
|
|
106
|
+
async def _run():
|
|
107
|
+
client, token, _, _ = _client(ctx)
|
|
108
|
+
async with client:
|
|
109
|
+
await _auth(client, token)
|
|
110
|
+
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
111
|
+
return await client.agent_harness.generate_pathways(
|
|
112
|
+
agent_profile=agent_profile,
|
|
113
|
+
directional_prompt=prompt,
|
|
114
|
+
name=name,
|
|
115
|
+
agent_name=agent_name,
|
|
116
|
+
num_pathways=num,
|
|
117
|
+
allow_destructive=allow_destructive,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
result = asyncio.run(_run())
|
|
122
|
+
print_message("[green]Pathway generation started[/green]", ctx.obj["FORMAT"])
|
|
123
|
+
print_platform_link(ctx, "agent-harness")
|
|
124
|
+
format_output(result.data, ctx.obj["FORMAT"])
|
|
125
|
+
except Exception as e:
|
|
126
|
+
print_message(f"[red]Error generating pathways: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
127
|
+
raise click.Abort()
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@agent_harness_group.command(name="run")
|
|
131
|
+
@click.argument("agent_id")
|
|
132
|
+
@click.option("--pathway", "pathways", multiple=True, required=True, help="Pathway ID to run (repeatable)")
|
|
133
|
+
@click.option("--name", help="Run name (auto-generated if omitted)")
|
|
134
|
+
@click.option("--agent-name", help="Agent display name")
|
|
135
|
+
@click.option("--run-as-profile", help="Salesforce profile to run as (RBAC)")
|
|
136
|
+
@click.option("--wait", is_flag=True, default=False, help="Wait and poll until the run finishes")
|
|
137
|
+
@click.option("--timeout", default=1800.0, help="Max seconds to wait when --wait is set")
|
|
138
|
+
@click.pass_context
|
|
139
|
+
def run(ctx, agent_id, pathways, name, agent_name, run_as_profile, wait, timeout):
|
|
140
|
+
"""Run adversarial simulations for the given pathways"""
|
|
141
|
+
|
|
142
|
+
async def _run():
|
|
143
|
+
client, token, _, _ = _client(ctx)
|
|
144
|
+
async with client:
|
|
145
|
+
await _auth(client, token)
|
|
146
|
+
agent = validate_id(agent_id, "agent")
|
|
147
|
+
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
148
|
+
if wait:
|
|
149
|
+
return await client.agent_harness.run_and_wait(
|
|
150
|
+
agent,
|
|
151
|
+
list(pathways),
|
|
152
|
+
name=name,
|
|
153
|
+
agent_name=agent_name,
|
|
154
|
+
run_as_profile=run_as_profile,
|
|
155
|
+
timeout=timeout,
|
|
156
|
+
)
|
|
157
|
+
return await client.agent_harness.run(
|
|
158
|
+
agent,
|
|
159
|
+
list(pathways),
|
|
160
|
+
name=name,
|
|
161
|
+
agent_name=agent_name,
|
|
162
|
+
run_as_profile=run_as_profile,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
result = asyncio.run(_run())
|
|
167
|
+
if not wait:
|
|
168
|
+
# run() returns an AdversaryPathwaysGroup model; run_and_wait returns a status dict.
|
|
169
|
+
group_id = result.id
|
|
170
|
+
print_message(
|
|
171
|
+
f"[green]Run started (group {group_id}). Poll with: testzeus agent-harness status {group_id}[/green]",
|
|
172
|
+
ctx.obj["FORMAT"],
|
|
173
|
+
)
|
|
174
|
+
print_platform_link(ctx, "agent-harness")
|
|
175
|
+
format_output(result.data, ctx.obj["FORMAT"])
|
|
176
|
+
else:
|
|
177
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
178
|
+
except Exception as e:
|
|
179
|
+
print_message(f"[red]Error running simulations: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
180
|
+
raise click.Abort()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@agent_harness_group.command(name="status")
|
|
184
|
+
@click.argument("group_id")
|
|
185
|
+
@click.pass_context
|
|
186
|
+
def status(ctx, group_id):
|
|
187
|
+
"""Get the status/results of a simulation run group"""
|
|
188
|
+
|
|
189
|
+
async def _run():
|
|
190
|
+
client, token, _, _ = _client(ctx)
|
|
191
|
+
async with client:
|
|
192
|
+
await _auth(client, token)
|
|
193
|
+
return await client.agent_harness.get_status(validate_id(group_id, "group"))
|
|
194
|
+
|
|
195
|
+
try:
|
|
196
|
+
format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
|
|
197
|
+
except Exception as e:
|
|
198
|
+
print_message(f"[red]Error getting status: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
199
|
+
raise click.Abort()
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@agent_harness_group.command(name="cancel")
|
|
203
|
+
@click.argument("group_id")
|
|
204
|
+
@click.pass_context
|
|
205
|
+
def cancel(ctx, group_id):
|
|
206
|
+
"""Cancel a running simulation group"""
|
|
207
|
+
|
|
208
|
+
async def _run():
|
|
209
|
+
client, token, _, _ = _client(ctx)
|
|
210
|
+
async with client:
|
|
211
|
+
await _auth(client, token)
|
|
212
|
+
return await client.agent_harness.cancel(validate_id(group_id, "group"))
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
asyncio.run(_run())
|
|
216
|
+
print_message(f"[green]Cancelled simulation group {group_id}[/green]", ctx.obj["FORMAT"])
|
|
217
|
+
except Exception as e:
|
|
218
|
+
print_message(f"[red]Error cancelling group: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
219
|
+
raise click.Abort()
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@agent_harness_group.command(name="get-agent")
|
|
223
|
+
@click.argument("agent_id")
|
|
224
|
+
@click.pass_context
|
|
225
|
+
def get_agent(ctx, agent_id):
|
|
226
|
+
"""Get full detail for a single agent"""
|
|
227
|
+
|
|
228
|
+
async def _run():
|
|
229
|
+
client, token, _, _ = _client(ctx)
|
|
230
|
+
async with client:
|
|
231
|
+
await _auth(client, token)
|
|
232
|
+
return await client.agent_harness.get_agent(validate_id(agent_id, "agent"))
|
|
233
|
+
|
|
234
|
+
try:
|
|
235
|
+
print_platform_link(ctx, "agent-harness")
|
|
236
|
+
format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
|
|
237
|
+
except Exception as e:
|
|
238
|
+
print_message(f"[red]Error getting agent: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
239
|
+
raise click.Abort()
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@agent_harness_group.command(name="delete-pathway")
|
|
243
|
+
@click.argument("pathway_id")
|
|
244
|
+
@click.pass_context
|
|
245
|
+
def delete_pathway(ctx, pathway_id):
|
|
246
|
+
"""Soft-delete an adversarial pathway"""
|
|
247
|
+
|
|
248
|
+
async def _run():
|
|
249
|
+
client, token, _, _ = _client(ctx)
|
|
250
|
+
async with client:
|
|
251
|
+
await _auth(client, token)
|
|
252
|
+
return await client.agent_harness.delete_pathway(validate_id(pathway_id, "pathway"))
|
|
253
|
+
|
|
254
|
+
try:
|
|
255
|
+
asyncio.run(_run())
|
|
256
|
+
print_message(f"[green]Deleted pathway {pathway_id}[/green]", ctx.obj["FORMAT"])
|
|
257
|
+
except Exception as e:
|
|
258
|
+
print_message(f"[red]Error deleting pathway: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
259
|
+
raise click.Abort()
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Connected environment management commands for TestZeus CLI.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import click
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from testzeus_sdk import TestZeusClient
|
|
9
|
+
from testzeus_cli.config import get_client_config
|
|
10
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
11
|
+
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
12
|
+
from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
|
|
13
|
+
|
|
14
|
+
console = Console()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group()
|
|
18
|
+
def connected_environments_group():
|
|
19
|
+
"""Manage connected environments in TestZeus"""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@connected_environments_group.command(name="create")
|
|
24
|
+
@click.option("--name", required=True, help="Connected environment name")
|
|
25
|
+
@click.option("--connection", help="Connection ID or name to link with")
|
|
26
|
+
@click.option("--tags", help="Comma-separated list of tags")
|
|
27
|
+
@click.option(
|
|
28
|
+
"--metadata",
|
|
29
|
+
"-m",
|
|
30
|
+
multiple=True,
|
|
31
|
+
help="Metadata entries (format: key=value)",
|
|
32
|
+
)
|
|
33
|
+
@click.option(
|
|
34
|
+
"--skip-process",
|
|
35
|
+
is_flag=True,
|
|
36
|
+
default=False,
|
|
37
|
+
help="Skip processing on create",
|
|
38
|
+
)
|
|
39
|
+
@click.pass_context
|
|
40
|
+
def create(ctx, name, connection, tags, metadata, skip_process):
|
|
41
|
+
"""Create a new connected environment"""
|
|
42
|
+
|
|
43
|
+
async def _run():
|
|
44
|
+
config, token, stored_tenant_id, stored_user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
45
|
+
client = TestZeusClient(**config)
|
|
46
|
+
|
|
47
|
+
async with client:
|
|
48
|
+
if token:
|
|
49
|
+
initialize_client_with_token(client, token)
|
|
50
|
+
else:
|
|
51
|
+
await client.ensure_authenticated()
|
|
52
|
+
|
|
53
|
+
params = {
|
|
54
|
+
"name": name,
|
|
55
|
+
"tenant": stored_tenant_id,
|
|
56
|
+
"modified_by": stored_user_id,
|
|
57
|
+
"skip_process": skip_process,
|
|
58
|
+
"metadata": parse_key_value_pairs(metadata) if metadata else {},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if connection:
|
|
62
|
+
params["connection"] = connection
|
|
63
|
+
|
|
64
|
+
if tags:
|
|
65
|
+
params["tags"] = tags.split(",")
|
|
66
|
+
|
|
67
|
+
conn_env = await client.connected_environments.create(params)
|
|
68
|
+
return conn_env.data
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
result = asyncio.run(_run())
|
|
72
|
+
print_message(
|
|
73
|
+
f"[green]Connected environment created successfully with ID: " f"{result['id']}[/green]",
|
|
74
|
+
ctx.obj["FORMAT"],
|
|
75
|
+
)
|
|
76
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print_message(
|
|
79
|
+
f"[red]Error creating connected environment: {str(e)}[/red]",
|
|
80
|
+
ctx.obj["FORMAT"],
|
|
81
|
+
)
|
|
82
|
+
raise click.Abort()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@connected_environments_group.command(name="list")
|
|
86
|
+
@click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
|
|
87
|
+
@click.option("--sort", help="Sort by field")
|
|
88
|
+
@click.option("--expand", help="Expand related entities")
|
|
89
|
+
@click.pass_context
|
|
90
|
+
def list(ctx, filters, sort, expand):
|
|
91
|
+
"""List all connected environments"""
|
|
92
|
+
|
|
93
|
+
async def _run():
|
|
94
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
95
|
+
client = TestZeusClient(**config)
|
|
96
|
+
filter_dict = parse_key_value_pairs(filters) if filters else {}
|
|
97
|
+
async with client:
|
|
98
|
+
if token:
|
|
99
|
+
initialize_client_with_token(client, token)
|
|
100
|
+
else:
|
|
101
|
+
await client.ensure_authenticated()
|
|
102
|
+
result = await client.connected_environments.get_list(expand=expand, sort=sort, filters=filter_dict)
|
|
103
|
+
return result
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
result = asyncio.run(_run())
|
|
107
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
108
|
+
except Exception as e:
|
|
109
|
+
print_message(
|
|
110
|
+
f"[red]Error listing connected environments: {str(e)}[/red]",
|
|
111
|
+
ctx.obj["FORMAT"],
|
|
112
|
+
)
|
|
113
|
+
raise click.Abort()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@connected_environments_group.command(name="get")
|
|
117
|
+
@click.argument("conn_env_id")
|
|
118
|
+
@click.option("--expand", help="Expand related entities")
|
|
119
|
+
@click.pass_context
|
|
120
|
+
def get(ctx, conn_env_id, expand):
|
|
121
|
+
"""Get a connected environment by ID"""
|
|
122
|
+
|
|
123
|
+
async def _run():
|
|
124
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
125
|
+
client = TestZeusClient(**config)
|
|
126
|
+
async with client:
|
|
127
|
+
if token:
|
|
128
|
+
initialize_client_with_token(client, token)
|
|
129
|
+
else:
|
|
130
|
+
await client.ensure_authenticated()
|
|
131
|
+
conn_env = await client.connected_environments.get_one(conn_env_id, expand=expand)
|
|
132
|
+
return conn_env.data
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
result = asyncio.run(_run())
|
|
136
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
137
|
+
except Exception as e:
|
|
138
|
+
print_message(
|
|
139
|
+
f"[red]Error getting connected environment: {str(e)}[/red]",
|
|
140
|
+
ctx.obj["FORMAT"],
|
|
141
|
+
)
|
|
142
|
+
raise click.Abort()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@connected_environments_group.command(name="update")
|
|
146
|
+
@click.argument("conn_env_id")
|
|
147
|
+
@click.option("--name", help="New connected environment name")
|
|
148
|
+
@click.option("--connection", help="Connection ID or name to link with")
|
|
149
|
+
@click.option("--tags", help="Comma-separated list of tags")
|
|
150
|
+
@click.option(
|
|
151
|
+
"--metadata",
|
|
152
|
+
"-m",
|
|
153
|
+
multiple=True,
|
|
154
|
+
help="Metadata entries (format: key=value)",
|
|
155
|
+
)
|
|
156
|
+
@click.option(
|
|
157
|
+
"--skip-process/--no-skip-process",
|
|
158
|
+
default=None,
|
|
159
|
+
help="Toggle processing skip",
|
|
160
|
+
)
|
|
161
|
+
@click.pass_context
|
|
162
|
+
def update(ctx, conn_env_id, name, connection, tags, metadata, skip_process):
|
|
163
|
+
"""Update a connected environment"""
|
|
164
|
+
|
|
165
|
+
async def _run():
|
|
166
|
+
config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
167
|
+
client = TestZeusClient(**config)
|
|
168
|
+
async with client:
|
|
169
|
+
if token:
|
|
170
|
+
initialize_client_with_token(client, token)
|
|
171
|
+
else:
|
|
172
|
+
await client.ensure_authenticated()
|
|
173
|
+
|
|
174
|
+
# Validate tenant ownership before updating
|
|
175
|
+
conn_env = await client.connected_environments.get_one(conn_env_id)
|
|
176
|
+
validate_tenant_ownership(conn_env.data, tenant_id, "connected environment")
|
|
177
|
+
|
|
178
|
+
updates = {"tenant": tenant_id, "modified_by": user_id}
|
|
179
|
+
has_updates = False
|
|
180
|
+
|
|
181
|
+
if name:
|
|
182
|
+
updates["name"] = name
|
|
183
|
+
has_updates = True
|
|
184
|
+
|
|
185
|
+
if connection:
|
|
186
|
+
updates["connection"] = connection
|
|
187
|
+
has_updates = True
|
|
188
|
+
|
|
189
|
+
if tags and tags != "none":
|
|
190
|
+
updates["tags"] = tags.split(",")
|
|
191
|
+
has_updates = True
|
|
192
|
+
|
|
193
|
+
if tags == "none":
|
|
194
|
+
updates["tags"] = None
|
|
195
|
+
has_updates = True
|
|
196
|
+
|
|
197
|
+
if metadata:
|
|
198
|
+
updates["metadata"] = parse_key_value_pairs(metadata)
|
|
199
|
+
has_updates = True
|
|
200
|
+
|
|
201
|
+
if skip_process is not None:
|
|
202
|
+
updates["skip_process"] = skip_process
|
|
203
|
+
has_updates = True
|
|
204
|
+
|
|
205
|
+
if has_updates:
|
|
206
|
+
updated = await client.connected_environments.update(conn_env_id, updates)
|
|
207
|
+
return updated.data
|
|
208
|
+
else:
|
|
209
|
+
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
210
|
+
return None
|
|
211
|
+
|
|
212
|
+
try:
|
|
213
|
+
result = asyncio.run(_run())
|
|
214
|
+
print_message(
|
|
215
|
+
"[green]Connected environment updated successfully[/green]",
|
|
216
|
+
ctx.obj["FORMAT"],
|
|
217
|
+
)
|
|
218
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
219
|
+
except Exception as e:
|
|
220
|
+
print_message(
|
|
221
|
+
f"[red]Error updating connected environment: {str(e)}[/red]",
|
|
222
|
+
ctx.obj["FORMAT"],
|
|
223
|
+
)
|
|
224
|
+
raise click.Abort()
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@connected_environments_group.command(name="delete")
|
|
228
|
+
@click.argument("conn_env_id")
|
|
229
|
+
@click.pass_context
|
|
230
|
+
def delete(ctx, conn_env_id):
|
|
231
|
+
"""Delete a connected environment"""
|
|
232
|
+
|
|
233
|
+
async def _run():
|
|
234
|
+
config, token, stored_tenant_id, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
235
|
+
client = TestZeusClient(**config)
|
|
236
|
+
async with client:
|
|
237
|
+
if token:
|
|
238
|
+
initialize_client_with_token(client, token)
|
|
239
|
+
else:
|
|
240
|
+
await client.ensure_authenticated()
|
|
241
|
+
|
|
242
|
+
# Validate tenant ownership before deleting
|
|
243
|
+
conn_env = await client.connected_environments.get_one(conn_env_id)
|
|
244
|
+
validate_tenant_ownership(conn_env.data, stored_tenant_id, "connected environment")
|
|
245
|
+
|
|
246
|
+
await client.connected_environments.delete(conn_env_id)
|
|
247
|
+
return {"id": conn_env_id}
|
|
248
|
+
|
|
249
|
+
try:
|
|
250
|
+
result = asyncio.run(_run())
|
|
251
|
+
print_message(
|
|
252
|
+
f"[green]Connected environment {result['id']} deleted successfully[/green]",
|
|
253
|
+
ctx.obj["FORMAT"],
|
|
254
|
+
)
|
|
255
|
+
except Exception as e:
|
|
256
|
+
print_message(
|
|
257
|
+
f"[red]Error deleting connected environment: {str(e)}[/red]",
|
|
258
|
+
ctx.obj["FORMAT"],
|
|
259
|
+
)
|
|
260
|
+
raise click.Abort()
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
@connected_environments_group.command(name="add-code-file", help="Add a code file to a connected environment")
|
|
264
|
+
@click.argument("conn_env_id")
|
|
265
|
+
@click.argument("file_path", type=click.Path(exists=True))
|
|
266
|
+
@click.pass_context
|
|
267
|
+
def add_code_file(ctx, conn_env_id, file_path):
|
|
268
|
+
"""Add a code file to a connected environment"""
|
|
269
|
+
|
|
270
|
+
async def _run():
|
|
271
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
272
|
+
client = TestZeusClient(**config)
|
|
273
|
+
async with client:
|
|
274
|
+
if token:
|
|
275
|
+
initialize_client_with_token(client, token)
|
|
276
|
+
else:
|
|
277
|
+
await client.ensure_authenticated()
|
|
278
|
+
conn_env = await client.connected_environments.add_code_file(conn_env_id, file_path)
|
|
279
|
+
return conn_env.data
|
|
280
|
+
|
|
281
|
+
try:
|
|
282
|
+
result = asyncio.run(_run())
|
|
283
|
+
print_message(
|
|
284
|
+
f"[green]Code file added to connected environment {conn_env_id}[/green]",
|
|
285
|
+
ctx.obj["FORMAT"],
|
|
286
|
+
)
|
|
287
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
288
|
+
except Exception as e:
|
|
289
|
+
print_message(f"[red]Error adding code file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
290
|
+
raise click.Abort()
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
@connected_environments_group.command(name="remove-code-file", help="Remove a code file from a connected environment")
|
|
294
|
+
@click.argument("conn_env_id")
|
|
295
|
+
@click.argument("file_name")
|
|
296
|
+
@click.pass_context
|
|
297
|
+
def remove_code_file(ctx, conn_env_id, file_name):
|
|
298
|
+
"""Remove a code file from a connected environment"""
|
|
299
|
+
|
|
300
|
+
async def _run():
|
|
301
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
302
|
+
client = TestZeusClient(**config)
|
|
303
|
+
async with client:
|
|
304
|
+
if token:
|
|
305
|
+
initialize_client_with_token(client, token)
|
|
306
|
+
else:
|
|
307
|
+
await client.ensure_authenticated()
|
|
308
|
+
conn_env = await client.connected_environments.remove_code_file(conn_env_id, file_name)
|
|
309
|
+
return conn_env.data
|
|
310
|
+
|
|
311
|
+
try:
|
|
312
|
+
result = asyncio.run(_run())
|
|
313
|
+
print_message(
|
|
314
|
+
f"[green]Code file removed from connected environment {conn_env_id}[/green]",
|
|
315
|
+
ctx.obj["FORMAT"],
|
|
316
|
+
)
|
|
317
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
318
|
+
except Exception as e:
|
|
319
|
+
print_message(f"[red]Error removing code file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
320
|
+
raise click.Abort()
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@connected_environments_group.command(
|
|
324
|
+
name="delete-all-code-files",
|
|
325
|
+
help="Remove all code files from a connected environment",
|
|
326
|
+
)
|
|
327
|
+
@click.argument("conn_env_id")
|
|
328
|
+
@click.pass_context
|
|
329
|
+
def delete_all_code_files(ctx, conn_env_id):
|
|
330
|
+
"""Remove all code files from a connected environment"""
|
|
331
|
+
|
|
332
|
+
async def _run():
|
|
333
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
334
|
+
client = TestZeusClient(**config)
|
|
335
|
+
async with client:
|
|
336
|
+
if token:
|
|
337
|
+
initialize_client_with_token(client, token)
|
|
338
|
+
else:
|
|
339
|
+
await client.ensure_authenticated()
|
|
340
|
+
conn_env = await client.connected_environments.remove_all_code_files(conn_env_id)
|
|
341
|
+
return conn_env.data
|
|
342
|
+
|
|
343
|
+
try:
|
|
344
|
+
result = asyncio.run(_run())
|
|
345
|
+
print_message(
|
|
346
|
+
f"[green]All code files removed from connected environment " f"{conn_env_id}[/green]",
|
|
347
|
+
ctx.obj["FORMAT"],
|
|
348
|
+
)
|
|
349
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
350
|
+
except Exception as e:
|
|
351
|
+
print_message(f"[red]Error removing code files: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
352
|
+
raise click.Abort()
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@connected_environments_group.command(name="add-metadata-file", help="Add a metadata file to a connected environment")
|
|
356
|
+
@click.argument("conn_env_id")
|
|
357
|
+
@click.argument("file_path", type=click.Path(exists=True))
|
|
358
|
+
@click.pass_context
|
|
359
|
+
def add_metadata_file(ctx, conn_env_id, file_path):
|
|
360
|
+
"""Add a metadata file to a connected environment"""
|
|
361
|
+
|
|
362
|
+
async def _run():
|
|
363
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
364
|
+
client = TestZeusClient(**config)
|
|
365
|
+
async with client:
|
|
366
|
+
if token:
|
|
367
|
+
initialize_client_with_token(client, token)
|
|
368
|
+
else:
|
|
369
|
+
await client.ensure_authenticated()
|
|
370
|
+
conn_env = await client.connected_environments.add_metadata_file(conn_env_id, file_path)
|
|
371
|
+
return conn_env.data
|
|
372
|
+
|
|
373
|
+
try:
|
|
374
|
+
result = asyncio.run(_run())
|
|
375
|
+
print_message(
|
|
376
|
+
f"[green]Metadata file added to connected environment {conn_env_id}[/green]",
|
|
377
|
+
ctx.obj["FORMAT"],
|
|
378
|
+
)
|
|
379
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
380
|
+
except Exception as e:
|
|
381
|
+
print_message(f"[red]Error adding metadata file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
382
|
+
raise click.Abort()
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
@connected_environments_group.command(
|
|
386
|
+
name="remove-metadata-file",
|
|
387
|
+
help="Remove a metadata file from a connected environment",
|
|
388
|
+
)
|
|
389
|
+
@click.argument("conn_env_id")
|
|
390
|
+
@click.argument("file_name")
|
|
391
|
+
@click.pass_context
|
|
392
|
+
def remove_metadata_file(ctx, conn_env_id, file_name):
|
|
393
|
+
"""Remove a metadata file from a connected environment"""
|
|
394
|
+
|
|
395
|
+
async def _run():
|
|
396
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
397
|
+
client = TestZeusClient(**config)
|
|
398
|
+
async with client:
|
|
399
|
+
if token:
|
|
400
|
+
initialize_client_with_token(client, token)
|
|
401
|
+
else:
|
|
402
|
+
await client.ensure_authenticated()
|
|
403
|
+
conn_env = await client.connected_environments.remove_metadata_file(conn_env_id, file_name)
|
|
404
|
+
return conn_env.data
|
|
405
|
+
|
|
406
|
+
try:
|
|
407
|
+
result = asyncio.run(_run())
|
|
408
|
+
print_message(
|
|
409
|
+
f"[green]Metadata file removed from connected environment " f"{conn_env_id}[/green]",
|
|
410
|
+
ctx.obj["FORMAT"],
|
|
411
|
+
)
|
|
412
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
413
|
+
except Exception as e:
|
|
414
|
+
print_message(f"[red]Error removing metadata file: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
415
|
+
raise click.Abort()
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
@connected_environments_group.command(
|
|
419
|
+
name="delete-all-metadata-files",
|
|
420
|
+
help="Remove all metadata files from a connected environment",
|
|
421
|
+
)
|
|
422
|
+
@click.argument("conn_env_id")
|
|
423
|
+
@click.pass_context
|
|
424
|
+
def delete_all_metadata_files(ctx, conn_env_id):
|
|
425
|
+
"""Remove all metadata files from a connected environment"""
|
|
426
|
+
|
|
427
|
+
async def _run():
|
|
428
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
429
|
+
client = TestZeusClient(**config)
|
|
430
|
+
async with client:
|
|
431
|
+
if token:
|
|
432
|
+
initialize_client_with_token(client, token)
|
|
433
|
+
else:
|
|
434
|
+
await client.ensure_authenticated()
|
|
435
|
+
conn_env = await client.connected_environments.remove_all_metadata_files(conn_env_id)
|
|
436
|
+
return conn_env.data
|
|
437
|
+
|
|
438
|
+
try:
|
|
439
|
+
result = asyncio.run(_run())
|
|
440
|
+
print_message(
|
|
441
|
+
f"[green]All metadata files removed from connected environment " f"{conn_env_id}[/green]",
|
|
442
|
+
ctx.obj["FORMAT"],
|
|
443
|
+
)
|
|
444
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
445
|
+
except Exception as e:
|
|
446
|
+
print_message(f"[red]Error removing metadata files: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
447
|
+
raise click.Abort()
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test report run management commands for TestZeus CLI.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import click
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from testzeus_sdk import TestZeusClient
|
|
9
|
+
from testzeus_cli.config import get_client_config
|
|
10
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
11
|
+
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
12
|
+
from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
|
|
13
|
+
|
|
14
|
+
console = Console()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group()
|
|
18
|
+
def test_report_runs_group():
|
|
19
|
+
"""Manage test report runs in TestZeus"""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@test_report_runs_group.command(name="list")
|
|
24
|
+
@click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
|
|
25
|
+
@click.option("--sort", help="Sort by field")
|
|
26
|
+
@click.option("--expand", help="Expand related entities")
|
|
27
|
+
@click.pass_context
|
|
28
|
+
def list(ctx, filters, sort, expand):
|
|
29
|
+
"""List all test report runs"""
|
|
30
|
+
|
|
31
|
+
async def _run():
|
|
32
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
33
|
+
client = TestZeusClient(**config)
|
|
34
|
+
filter_dict = parse_key_value_pairs(filters) if filters else {}
|
|
35
|
+
async with client:
|
|
36
|
+
if token:
|
|
37
|
+
initialize_client_with_token(client, token)
|
|
38
|
+
else:
|
|
39
|
+
await client.ensure_authenticated()
|
|
40
|
+
result = await client.test_report_runs.get_list(expand=expand, sort=sort, filters=filter_dict)
|
|
41
|
+
return result
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
result = asyncio.run(_run())
|
|
45
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
46
|
+
except Exception as e:
|
|
47
|
+
print_message(f"[red]Error listing test report runs: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
48
|
+
raise click.Abort()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@test_report_runs_group.command(name="get")
|
|
52
|
+
@click.argument("report_run_id")
|
|
53
|
+
@click.option("--expand", help="Expand related entities")
|
|
54
|
+
@click.pass_context
|
|
55
|
+
def get(ctx, report_run_id, expand):
|
|
56
|
+
"""Get a test report run by ID"""
|
|
57
|
+
|
|
58
|
+
async def _run():
|
|
59
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
60
|
+
client = TestZeusClient(**config)
|
|
61
|
+
async with client:
|
|
62
|
+
if token:
|
|
63
|
+
initialize_client_with_token(client, token)
|
|
64
|
+
else:
|
|
65
|
+
await client.ensure_authenticated()
|
|
66
|
+
report_run = await client.test_report_runs.get_one(report_run_id, expand=expand)
|
|
67
|
+
return report_run.data
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
result = asyncio.run(_run())
|
|
71
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
72
|
+
except Exception as e:
|
|
73
|
+
print_message(f"[red]Error getting test report run: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
74
|
+
raise click.Abort()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@test_report_runs_group.command(name="delete")
|
|
78
|
+
@click.argument("report_run_id")
|
|
79
|
+
@click.pass_context
|
|
80
|
+
def delete(ctx, report_run_id):
|
|
81
|
+
"""Delete a test report run"""
|
|
82
|
+
|
|
83
|
+
async def _run():
|
|
84
|
+
config, token, stored_tenant_id, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
85
|
+
client = TestZeusClient(**config)
|
|
86
|
+
async with client:
|
|
87
|
+
if token:
|
|
88
|
+
initialize_client_with_token(client, token)
|
|
89
|
+
else:
|
|
90
|
+
await client.ensure_authenticated()
|
|
91
|
+
|
|
92
|
+
# Validate tenant ownership before deleting
|
|
93
|
+
report_run = await client.test_report_runs.get_one(report_run_id)
|
|
94
|
+
validate_tenant_ownership(report_run.data, stored_tenant_id, "test report run")
|
|
95
|
+
|
|
96
|
+
await client.test_report_runs.delete(report_run_id)
|
|
97
|
+
return {"id": report_run_id}
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
result = asyncio.run(_run())
|
|
101
|
+
print_message(f"[green]Test report run {result['id']} deleted successfully[/green]", ctx.obj["FORMAT"])
|
|
102
|
+
except Exception as e:
|
|
103
|
+
print_message(f"[red]Error deleting test report run: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
104
|
+
raise click.Abort()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@test_report_runs_group.command(name="download")
|
|
108
|
+
@click.argument("report_run_id")
|
|
109
|
+
@click.option("--output-dir", default="downloads", help="Output directory for downloaded report (default: downloads)")
|
|
110
|
+
@click.option(
|
|
111
|
+
"--format",
|
|
112
|
+
"report_format",
|
|
113
|
+
type=click.Choice(["ctrf", "pdf", "csv", "zip"]),
|
|
114
|
+
default="pdf",
|
|
115
|
+
help="Report format (default: pdf)",
|
|
116
|
+
)
|
|
117
|
+
@click.pass_context
|
|
118
|
+
def download(ctx, report_run_id, output_dir, report_format):
|
|
119
|
+
"""Download the report for a test report run"""
|
|
120
|
+
|
|
121
|
+
async def _run():
|
|
122
|
+
config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
|
|
123
|
+
client = TestZeusClient(**config)
|
|
124
|
+
async with client:
|
|
125
|
+
if token:
|
|
126
|
+
initialize_client_with_token(client, token)
|
|
127
|
+
else:
|
|
128
|
+
await client.ensure_authenticated()
|
|
129
|
+
|
|
130
|
+
if ctx.obj.get("VERBOSE"):
|
|
131
|
+
console.print(f"[blue]Downloading {report_format} report for test report run: {report_run_id}[/blue]")
|
|
132
|
+
|
|
133
|
+
downloaded_file = await client.test_report_runs.download_report(report_run_id, output_dir=output_dir, format=report_format)
|
|
134
|
+
|
|
135
|
+
if downloaded_file:
|
|
136
|
+
return {
|
|
137
|
+
"report_run_id": report_run_id,
|
|
138
|
+
"format": report_format,
|
|
139
|
+
"output_dir": output_dir,
|
|
140
|
+
"file_path": str(downloaded_file),
|
|
141
|
+
"success": True,
|
|
142
|
+
}
|
|
143
|
+
else:
|
|
144
|
+
return {
|
|
145
|
+
"report_run_id": report_run_id,
|
|
146
|
+
"format": report_format,
|
|
147
|
+
"output_dir": output_dir,
|
|
148
|
+
"file_path": None,
|
|
149
|
+
"success": False,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try:
|
|
153
|
+
result = asyncio.run(_run())
|
|
154
|
+
if result["success"]:
|
|
155
|
+
print_message(f"[green]Report downloaded successfully to: {result['file_path']}[/green]", ctx.obj["FORMAT"])
|
|
156
|
+
else:
|
|
157
|
+
print_message(
|
|
158
|
+
f"[yellow]Report download failed (run may not be completed): {result['report_run_id']}[/yellow]",
|
|
159
|
+
ctx.obj["FORMAT"],
|
|
160
|
+
)
|
|
161
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
162
|
+
except Exception as e:
|
|
163
|
+
print_message(f"[red]Error downloading report: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
164
|
+
raise click.Abort()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|