dinemic-cli 0.0.21__tar.gz → 0.2.0__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.
- {dinemic_cli-0.0.21/src/dinemic_cli.egg-info → dinemic_cli-0.2.0}/PKG-INFO +1 -1
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/client.py +3 -0
- dinemic_cli-0.2.0/src/dinemic_cli/commands/access_gate.py +60 -0
- dinemic_cli-0.2.0/src/dinemic_cli/commands/access_group.py +51 -0
- dinemic_cli-0.2.0/src/dinemic_cli/commands/access_policy.py +52 -0
- dinemic_cli-0.2.0/src/dinemic_cli/commands/access_user.py +55 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/loadbalancer_route.py +29 -2
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/main.py +8 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0/src/dinemic_cli.egg-info}/PKG-INFO +1 -1
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/SOURCES.txt +4 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/scm_file_list.json +4 -0
- dinemic_cli-0.2.0/src/dinemic_cli.egg-info/scm_version.json +8 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/api_samples.py +28 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/cli_runner.py +4 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/command_matrix.py +218 -2
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/support.py +11 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_envvars.py +28 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_option_contract.py +5 -0
- dinemic_cli-0.0.21/src/dinemic_cli.egg-info/scm_version.json +0 -8
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/.gitlab-ci.yml +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/CONTRIBUTING +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/LICENSE +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/legal/CLA-ENTITY.md +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/legal/CLA.md +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/pyproject.toml +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/pytest.ini +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/setup.cfg +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/__init__.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/__main__.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/__init__.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/auth.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/caa.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/cert.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/cert_peer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/dns_entry.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/dns_value.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/dns_zone.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/endpoint.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/healthcheck.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/loadbalancer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/loadbalancer_backend.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/loadbalancer_host.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/network.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/node.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/peer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/peer_config.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/project.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/commands/quota.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli/output.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/dependency_links.txt +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/entry_points.txt +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/requires.txt +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/dinemic_cli.egg-info/top_level.txt +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/requirements.txt +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/01-cli-fixes.patch +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/02-tests-after-fixes.patch +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/cert_peer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/conftest.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/dns_entry.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/dns_value.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/dns_zone.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/endpoint.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/healthcheck.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/loadbalancer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/loadbalancer_backend.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/loadbalancer_host.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/loadbalancer_route.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/network.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/network_node.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/node.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/peer.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/project.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_auth.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_columns.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_commands.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_confirmations.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_error_handling.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_lifecycle.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_network_node.py +0 -0
- {dinemic_cli-0.0.21 → dinemic_cli-0.2.0}/src/tests/test_smoke.py +0 -0
|
@@ -68,6 +68,9 @@ class Client:
|
|
|
68
68
|
def post(self, path, data: dict):
|
|
69
69
|
return self.request("POST", path, json=data)
|
|
70
70
|
|
|
71
|
+
def patch(self, path, data: dict):
|
|
72
|
+
return self.request("PATCH", path, json=data)
|
|
73
|
+
|
|
71
74
|
def post_login(self, path, data: dict):
|
|
72
75
|
return self.request("POST", path, unauthorized=True, json=data)
|
|
73
76
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2026 cloudover.io ltd.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0 OR LicenseRef-CloudOver-Commercial
|
|
4
|
+
#
|
|
5
|
+
# This file is dual-licensed. You may use it under the terms of the
|
|
6
|
+
# GNU Affero General Public License v3 or later, or under a commercial
|
|
7
|
+
# license provided by cloudover.io ltd.
|
|
8
|
+
#
|
|
9
|
+
# Contributions:
|
|
10
|
+
# By contributing to this file, you agree that your contribution is
|
|
11
|
+
# provided under the same dual-licensing model, and you grant
|
|
12
|
+
# cloudover.io ltd. the right to use, modify, sublicense, and distribute
|
|
13
|
+
# your contribution under the commercial license in addition to AGPL-3.0.
|
|
14
|
+
|
|
15
|
+
import typer
|
|
16
|
+
|
|
17
|
+
from dinemic_cli.output import render, created
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(no_args_is_help=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.command("list")
|
|
23
|
+
def list_access_gates(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
project: str = typer.Option(None, "--project", "-p", help="Project ID", envvar="DINEMIC_PROJECT")
|
|
26
|
+
):
|
|
27
|
+
data = ctx.obj["client"].get("/access-gate/", project=project)
|
|
28
|
+
render(data, ctx.obj["output"], columns=["id", "name", "project", "provider_type", "provider_issuer", "token_ttl"])
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@app.command("create")
|
|
32
|
+
def create_access_gate(
|
|
33
|
+
ctx: typer.Context,
|
|
34
|
+
project: str = typer.Option(..., "--project", "-p", help="Project ID", envvar="DINEMIC_PROJECT"),
|
|
35
|
+
name: str = typer.Option(..., "--name", "-n", help="Name"),
|
|
36
|
+
provider_type: str = typer.Option("local", "--provider", help="Users: local (kept by the gate) or oidc (OpenID Connect provider)"),
|
|
37
|
+
token_ttl: int = typer.Option(86400, "--token-ttl", help="Login lifetime in seconds"),
|
|
38
|
+
provider_issuer: str = typer.Option("", "--issuer", help="OIDC issuer URL"),
|
|
39
|
+
provider_client_id: str = typer.Option("", "--client-id", help="OIDC client ID"),
|
|
40
|
+
provider_client_secret: str = typer.Option("", "--client-secret", help="OIDC client secret (cannot be changed later)"),
|
|
41
|
+
provider_scopes: list[str] = typer.Option([], "--scope", help="OIDC scope, repeat for more"),
|
|
42
|
+
provider_groups_claim: str = typer.Option("groups", "--groups-claim", help="OIDC claim with the user's groups"),
|
|
43
|
+
):
|
|
44
|
+
data = ctx.obj["client"].post("/access-gate/", {"project": project, "name": name, "provider_type": provider_type, "token_ttl": token_ttl,
|
|
45
|
+
"provider_issuer": provider_issuer, "provider_client_id": provider_client_id,
|
|
46
|
+
"provider_client_secret": provider_client_secret, "provider_scopes": provider_scopes,
|
|
47
|
+
"provider_groups_claim": provider_groups_claim})
|
|
48
|
+
created(data, ctx, f"Created access gate {data['name']} ({data['id']})")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@app.command("delete")
|
|
52
|
+
def delete_access_gate(
|
|
53
|
+
ctx: typer.Context,
|
|
54
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
55
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Don't ask for confirmation"),
|
|
56
|
+
):
|
|
57
|
+
if not yes:
|
|
58
|
+
typer.confirm(f"Remove access gate {gate_id} and all its users and groups?", abort=True)
|
|
59
|
+
ctx.obj["client"].delete(f"/access-gate/{gate_id}/")
|
|
60
|
+
typer.secho("Removed.", fg="green")
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2026 cloudover.io ltd.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0 OR LicenseRef-CloudOver-Commercial
|
|
4
|
+
#
|
|
5
|
+
# This file is dual-licensed. You may use it under the terms of the
|
|
6
|
+
# GNU Affero General Public License v3 or later, or under a commercial
|
|
7
|
+
# license provided by cloudover.io ltd.
|
|
8
|
+
#
|
|
9
|
+
# Contributions:
|
|
10
|
+
# By contributing to this file, you agree that your contribution is
|
|
11
|
+
# provided under the same dual-licensing model, and you grant
|
|
12
|
+
# cloudover.io ltd. the right to use, modify, sublicense, and distribute
|
|
13
|
+
# your contribution under the commercial license in addition to AGPL-3.0.
|
|
14
|
+
|
|
15
|
+
import typer
|
|
16
|
+
|
|
17
|
+
from dinemic_cli.output import render, created
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(no_args_is_help=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.command("list")
|
|
23
|
+
def list_access_groups(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE")
|
|
26
|
+
):
|
|
27
|
+
data = ctx.obj["client"].get(f"/access-gate/{gate_id}/group/", gate=gate_id)
|
|
28
|
+
render(data, ctx.obj["output"], columns=["id", "name", "gate"])
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@app.command("create")
|
|
32
|
+
def create_access_group(
|
|
33
|
+
ctx: typer.Context,
|
|
34
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
35
|
+
name: str = typer.Option(..., "--name", "-n", help="Name (for OIDC gates: as in the provider's groups claim)"),
|
|
36
|
+
):
|
|
37
|
+
data = ctx.obj["client"].post(f"/access-gate/{gate_id}/group/", {"gate": gate_id, "name": name})
|
|
38
|
+
created(data, ctx, f"Created group {data['name']} ({data['id']}) in access gate {gate_id}")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@app.command("delete")
|
|
42
|
+
def delete_access_group(
|
|
43
|
+
ctx: typer.Context,
|
|
44
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
45
|
+
group_id: str = typer.Option(..., "--group", "-G", help="Group ID"),
|
|
46
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Don't ask for confirmation"),
|
|
47
|
+
):
|
|
48
|
+
if not yes:
|
|
49
|
+
typer.confirm(f"Remove group {group_id}? Its users and access policies lose it", abort=True)
|
|
50
|
+
ctx.obj["client"].delete(f"/access-gate/{gate_id}/group/{group_id}/")
|
|
51
|
+
typer.secho("Removed.", fg="green")
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2026 cloudover.io ltd.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0 OR LicenseRef-CloudOver-Commercial
|
|
4
|
+
#
|
|
5
|
+
# This file is dual-licensed. You may use it under the terms of the
|
|
6
|
+
# GNU Affero General Public License v3 or later, or under a commercial
|
|
7
|
+
# license provided by cloudover.io ltd.
|
|
8
|
+
#
|
|
9
|
+
# Contributions:
|
|
10
|
+
# By contributing to this file, you agree that your contribution is
|
|
11
|
+
# provided under the same dual-licensing model, and you grant
|
|
12
|
+
# cloudover.io ltd. the right to use, modify, sublicense, and distribute
|
|
13
|
+
# your contribution under the commercial license in addition to AGPL-3.0.
|
|
14
|
+
|
|
15
|
+
import typer
|
|
16
|
+
|
|
17
|
+
from dinemic_cli.output import render, created
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(no_args_is_help=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.command("list")
|
|
23
|
+
def list_access_policies(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE")
|
|
26
|
+
):
|
|
27
|
+
data = ctx.obj["client"].get(f"/access-gate/{gate_id}/policy/", gate=gate_id)
|
|
28
|
+
render(data, ctx.obj["output"], columns=["id", "name", "groups", "gate"])
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@app.command("create")
|
|
32
|
+
def create_access_policy(
|
|
33
|
+
ctx: typer.Context,
|
|
34
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
35
|
+
name: str = typer.Option(..., "--name", "-n", help="Name, shown on the login page"),
|
|
36
|
+
groups: list[str] = typer.Option([], "--group", help="Group ID whose users get through, repeat for more"),
|
|
37
|
+
):
|
|
38
|
+
data = ctx.obj["client"].post(f"/access-gate/{gate_id}/policy/", {"gate": gate_id, "name": name, "groups": groups})
|
|
39
|
+
created(data, ctx, f"Created access policy {data['name']} ({data['id']}) in access gate {gate_id}")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@app.command("delete")
|
|
43
|
+
def delete_access_policy(
|
|
44
|
+
ctx: typer.Context,
|
|
45
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
46
|
+
policy_id: str = typer.Option(..., "--access-policy", "-a", help="Access policy ID"),
|
|
47
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Don't ask for confirmation"),
|
|
48
|
+
):
|
|
49
|
+
if not yes:
|
|
50
|
+
typer.confirm(f"Remove access policy {policy_id}? Detach it from load balancer routes first", abort=True)
|
|
51
|
+
ctx.obj["client"].delete(f"/access-gate/{gate_id}/policy/{policy_id}/")
|
|
52
|
+
typer.secho("Removed.", fg="green")
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2026 cloudover.io ltd.
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0 OR LicenseRef-CloudOver-Commercial
|
|
4
|
+
#
|
|
5
|
+
# This file is dual-licensed. You may use it under the terms of the
|
|
6
|
+
# GNU Affero General Public License v3 or later, or under a commercial
|
|
7
|
+
# license provided by cloudover.io ltd.
|
|
8
|
+
#
|
|
9
|
+
# Contributions:
|
|
10
|
+
# By contributing to this file, you agree that your contribution is
|
|
11
|
+
# provided under the same dual-licensing model, and you grant
|
|
12
|
+
# cloudover.io ltd. the right to use, modify, sublicense, and distribute
|
|
13
|
+
# your contribution under the commercial license in addition to AGPL-3.0.
|
|
14
|
+
|
|
15
|
+
import typer
|
|
16
|
+
|
|
17
|
+
from dinemic_cli.output import render, created
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(no_args_is_help=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@app.command("list")
|
|
23
|
+
def list_access_users(
|
|
24
|
+
ctx: typer.Context,
|
|
25
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE")
|
|
26
|
+
):
|
|
27
|
+
data = ctx.obj["client"].get(f"/access-gate/{gate_id}/user/", gate=gate_id)
|
|
28
|
+
render(data, ctx.obj["output"], columns=["id", "username", "is_active", "groups", "gate"])
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@app.command("create")
|
|
32
|
+
def create_access_user(
|
|
33
|
+
ctx: typer.Context,
|
|
34
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
35
|
+
username: str = typer.Option(..., "--username", "-u", help="Username"),
|
|
36
|
+
password: str = typer.Option(..., prompt=True, hide_input=True, help="Password, at least 10 characters"),
|
|
37
|
+
is_active: bool = typer.Option(True, "--active/--inactive", help="Inactive users cannot log in"),
|
|
38
|
+
groups: list[str] = typer.Option([], "--group", help="Group ID, repeat for more"),
|
|
39
|
+
):
|
|
40
|
+
data = ctx.obj["client"].post(f"/access-gate/{gate_id}/user/", {"gate": gate_id, "username": username, "password": password,
|
|
41
|
+
"is_active": is_active, "groups": groups})
|
|
42
|
+
created(data, ctx, f"Created user {data['username']} ({data['id']}) in access gate {gate_id}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@app.command("delete")
|
|
46
|
+
def delete_access_user(
|
|
47
|
+
ctx: typer.Context,
|
|
48
|
+
gate_id: str = typer.Option(..., "--gate", "-g", help="Access gate ID", envvar="DINEMIC_GATE"),
|
|
49
|
+
user_id: str = typer.Option(..., "--user", "-U", help="User ID"),
|
|
50
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Don't ask for confirmation"),
|
|
51
|
+
):
|
|
52
|
+
if not yes:
|
|
53
|
+
typer.confirm(f"Remove user {user_id}? A login already made stays valid until it expires", abort=True)
|
|
54
|
+
ctx.obj["client"].delete(f"/access-gate/{gate_id}/user/{user_id}/")
|
|
55
|
+
typer.secho("Removed.", fg="green")
|
|
@@ -26,7 +26,7 @@ def list_routes(
|
|
|
26
26
|
host_id: str = typer.Option(..., "--host", "-H", help="Host ID", envvar="DINEMIC_HOST")
|
|
27
27
|
):
|
|
28
28
|
data = ctx.obj["client"].get(f"/loadbalancer/{loadbalancer_id}/host/{host_id}/route/")
|
|
29
|
-
render(data, ctx.obj["output"], columns=["id", "path", "host", "healthcheck", "priority"])
|
|
29
|
+
render(data, ctx.obj["output"], columns=["id", "path", "host", "healthcheck", "priority", "access_policy"])
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
@app.command("create")
|
|
@@ -37,11 +37,38 @@ def create_route(
|
|
|
37
37
|
path: str = typer.Option(..., "--path", "-p", help="Path"),
|
|
38
38
|
priority: int = typer.Option(..., "--priority", "-P", help="Priority"),
|
|
39
39
|
healthcheck_id: str = typer.Option(..., "--healthcheck", "-k", help="Health check ID"),
|
|
40
|
+
policy_id: str = typer.Option(None, "--access-policy", "-a", help="Access policy ID: only logged-in users of its groups get through"),
|
|
40
41
|
):
|
|
41
|
-
data = ctx.obj["client"].post(f"/loadbalancer/{loadbalancer_id}/host/{host_id}/route/", {"path": path, "priority": priority, "healthcheck": healthcheck_id})
|
|
42
|
+
data = ctx.obj["client"].post(f"/loadbalancer/{loadbalancer_id}/host/{host_id}/route/", {"path": path, "priority": priority, "healthcheck": healthcheck_id, "access_policy": policy_id})
|
|
42
43
|
created(data, ctx, f"Created route {data['id']} (for host {host_id} in loadbalancer {loadbalancer_id})")
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
@app.command("attach-policy", help="Let through only logged-in users of the access policy's groups.")
|
|
47
|
+
def attach_policy(
|
|
48
|
+
ctx: typer.Context,
|
|
49
|
+
loadbalancer_id: str = typer.Option(..., "--loadbalancer", "-l", help="Loadbalancer ID", envvar="DINEMIC_LB"),
|
|
50
|
+
host_id: str = typer.Option(..., "--host", "-H", help="Host ID", envvar="DINEMIC_HOST"),
|
|
51
|
+
route_id: str = typer.Option(..., "--route", "-r", help="Route ID", envvar="DINEMIC_ROUTE"),
|
|
52
|
+
policy_id: str = typer.Option(..., "--access-policy", "-a", help="Access policy ID"),
|
|
53
|
+
):
|
|
54
|
+
ctx.obj["client"].patch(f"/loadbalancer/{loadbalancer_id}/host/{host_id}/route/{route_id}/", {"access_policy": policy_id})
|
|
55
|
+
typer.secho(f"Attached access policy {policy_id} to route {route_id}", fg="green")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@app.command("detach-policy", help="Remove the access policy: anyone can open the route again.")
|
|
59
|
+
def detach_policy(
|
|
60
|
+
ctx: typer.Context,
|
|
61
|
+
loadbalancer_id: str = typer.Option(..., "--loadbalancer", "-l", help="Loadbalancer ID", envvar="DINEMIC_LB"),
|
|
62
|
+
host_id: str = typer.Option(..., "--host", "-H", help="Host ID", envvar="DINEMIC_HOST"),
|
|
63
|
+
route_id: str = typer.Option(..., "--route", "-r", help="Route ID", envvar="DINEMIC_ROUTE"),
|
|
64
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Don't ask for confirmation"),
|
|
65
|
+
):
|
|
66
|
+
if not yes:
|
|
67
|
+
typer.confirm(f"Detach the access policy from route {route_id}? Anyone will be able to open it", abort=True)
|
|
68
|
+
ctx.obj["client"].patch(f"/loadbalancer/{loadbalancer_id}/host/{host_id}/route/{route_id}/", {"access_policy": None})
|
|
69
|
+
typer.secho("Detached.", fg="green")
|
|
70
|
+
|
|
71
|
+
|
|
45
72
|
@app.command("delete")
|
|
46
73
|
def delete_route(
|
|
47
74
|
ctx: typer.Context,
|
|
@@ -4,6 +4,10 @@ import typer
|
|
|
4
4
|
|
|
5
5
|
from dinemic_cli.client import Client, get_token
|
|
6
6
|
from dinemic_cli.commands import (
|
|
7
|
+
access_gate,
|
|
8
|
+
access_group,
|
|
9
|
+
access_policy,
|
|
10
|
+
access_user,
|
|
7
11
|
auth,
|
|
8
12
|
caa,
|
|
9
13
|
cert,
|
|
@@ -26,6 +30,10 @@ from dinemic_cli.commands import (
|
|
|
26
30
|
)
|
|
27
31
|
|
|
28
32
|
app = typer.Typer(no_args_is_help=True, help="Dinemic CLI")
|
|
33
|
+
app.add_typer(access_gate.app, name="access-gate", help="Access gates (logins in front of load balancer routes)")
|
|
34
|
+
app.add_typer(access_group.app, name="access-group", help="Groups of access gates")
|
|
35
|
+
app.add_typer(access_policy.app, name="access-policy", help="Access policies of access gates")
|
|
36
|
+
app.add_typer(access_user.app, name="access-user", help="Users of access gates")
|
|
29
37
|
app.add_typer(auth.app, name="auth", help="Login and tokens")
|
|
30
38
|
app.add_typer(caa.app, name="caa", help="CAA")
|
|
31
39
|
app.add_typer(cert.app, name="cert", help="Certificates")
|
|
@@ -20,6 +20,10 @@ src/dinemic_cli.egg-info/scm_file_list.json
|
|
|
20
20
|
src/dinemic_cli.egg-info/scm_version.json
|
|
21
21
|
src/dinemic_cli.egg-info/top_level.txt
|
|
22
22
|
src/dinemic_cli/commands/__init__.py
|
|
23
|
+
src/dinemic_cli/commands/access_gate.py
|
|
24
|
+
src/dinemic_cli/commands/access_group.py
|
|
25
|
+
src/dinemic_cli/commands/access_policy.py
|
|
26
|
+
src/dinemic_cli/commands/access_user.py
|
|
23
27
|
src/dinemic_cli/commands/auth.py
|
|
24
28
|
src/dinemic_cli/commands/caa.py
|
|
25
29
|
src/dinemic_cli/commands/cert.py
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"src/dinemic_cli/__main__.py",
|
|
12
12
|
"src/dinemic_cli/client.py",
|
|
13
13
|
"src/dinemic_cli/commands/__init__.py",
|
|
14
|
+
"src/dinemic_cli/commands/access_gate.py",
|
|
15
|
+
"src/dinemic_cli/commands/access_group.py",
|
|
16
|
+
"src/dinemic_cli/commands/access_policy.py",
|
|
17
|
+
"src/dinemic_cli/commands/access_user.py",
|
|
14
18
|
"src/dinemic_cli/commands/auth.py",
|
|
15
19
|
"src/dinemic_cli/commands/caa.py",
|
|
16
20
|
"src/dinemic_cli/commands/cert.py",
|
|
@@ -38,6 +38,10 @@ CERT_ID = "crt-0000000001"
|
|
|
38
38
|
CERT_PEER_ID = "cpr-0000000001"
|
|
39
39
|
CAA_ID = "caa-0000000001"
|
|
40
40
|
NETWORK_NODE_ID = "nnd-0000000001"
|
|
41
|
+
ACCESS_POLICY_ID = "apo-0000000001"
|
|
42
|
+
ACCESS_GATE_ID = "agt-0000000001"
|
|
43
|
+
ACCESS_GROUP_ID = "agr-0000000001"
|
|
44
|
+
ACCESS_USER_ID = "aus-0000000001"
|
|
41
45
|
|
|
42
46
|
SAMPLES: dict[str, list[dict[str, Any]]] = {
|
|
43
47
|
r"^/project/$": [
|
|
@@ -135,6 +139,7 @@ SAMPLES: dict[str, list[dict[str, Any]]] = {
|
|
|
135
139
|
"host": HOST_ID,
|
|
136
140
|
"healthcheck": HEALTHCHECK_ID,
|
|
137
141
|
"priority": 10,
|
|
142
|
+
"access_policy": None,
|
|
138
143
|
}
|
|
139
144
|
],
|
|
140
145
|
r"^/loadbalancer/[^/]+/host/[^/]+/route/[^/]+/backend/$": [
|
|
@@ -179,6 +184,29 @@ SAMPLES: dict[str, list[dict[str, Any]]] = {
|
|
|
179
184
|
"lb_recipients": [PEER_ID],
|
|
180
185
|
}
|
|
181
186
|
],
|
|
187
|
+
r"^/access-gate/$": [
|
|
188
|
+
{
|
|
189
|
+
"id": ACCESS_GATE_ID,
|
|
190
|
+
"name": "staff",
|
|
191
|
+
"project": PROJECT_ID,
|
|
192
|
+
"token_ttl": 86400,
|
|
193
|
+
"provider_type": "local",
|
|
194
|
+
"provider_issuer": "",
|
|
195
|
+
"provider_client_id": "",
|
|
196
|
+
"provider_scopes": [],
|
|
197
|
+
"provider_groups_claim": "groups",
|
|
198
|
+
"signing_public_key": "REPLACE-WITH-A-TEST-KEY-NOT-A-REAL-ONE=",
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
r"^/access-gate/[^/]+/group/$": [
|
|
202
|
+
{"id": ACCESS_GROUP_ID, "name": "admins", "gate": ACCESS_GATE_ID}
|
|
203
|
+
],
|
|
204
|
+
r"^/access-gate/[^/]+/user/$": [
|
|
205
|
+
{"id": ACCESS_USER_ID, "gate": ACCESS_GATE_ID, "username": "alice", "is_active": True, "groups": [ACCESS_GROUP_ID]}
|
|
206
|
+
],
|
|
207
|
+
r"^/access-gate/[^/]+/policy/$": [
|
|
208
|
+
{"id": ACCESS_POLICY_ID, "name": "internal", "gate": ACCESS_GATE_ID, "groups": [ACCESS_GROUP_ID]}
|
|
209
|
+
],
|
|
182
210
|
}
|
|
183
211
|
|
|
184
212
|
_COMPILED = [(re.compile(pattern), rows) for pattern, rows in SAMPLES.items()]
|
|
@@ -24,6 +24,10 @@ API_TOKEN = os.environ.get("DINEMIC_API_TOKEN")
|
|
|
24
24
|
#: How ``main.py`` mounts the sub-apps: command module -> path in the CLI.
|
|
25
25
|
#: THE ONLY place to edit if you rename the groups in main.py.
|
|
26
26
|
CLI_PATH = {
|
|
27
|
+
"access_gate": ["access-gate"],
|
|
28
|
+
"access_group": ["access-group"],
|
|
29
|
+
"access_policy": ["access-policy"],
|
|
30
|
+
"access_user": ["access-user"],
|
|
27
31
|
"auth": ["auth"],
|
|
28
32
|
"caa": ["caa"],
|
|
29
33
|
"cert": ["cert"],
|
|
@@ -367,7 +367,7 @@ CASES: list[Case] = [
|
|
|
367
367
|
method="GET",
|
|
368
368
|
path=f"/loadbalancer/{s.LB_ID}/host/{s.HOST_ID}/route/",
|
|
369
369
|
kind="list",
|
|
370
|
-
columns=["id", "path", "host", "healthcheck", "priority"],
|
|
370
|
+
columns=["id", "path", "host", "healthcheck", "priority", "access_policy"],
|
|
371
371
|
),
|
|
372
372
|
Case(
|
|
373
373
|
id="lb-route-create",
|
|
@@ -388,7 +388,48 @@ CASES: list[Case] = [
|
|
|
388
388
|
method="POST",
|
|
389
389
|
path=f"/loadbalancer/{s.LB_ID}/host/{s.HOST_ID}/route/",
|
|
390
390
|
kind="create",
|
|
391
|
-
payload={"path": "/", "priority": 10, "healthcheck": s.HEALTHCHECK_ID},
|
|
391
|
+
payload={"path": "/", "priority": 10, "healthcheck": s.HEALTHCHECK_ID, "access_policy": None},
|
|
392
|
+
),
|
|
393
|
+
Case(
|
|
394
|
+
id="lb-route-create-protected",
|
|
395
|
+
module="loadbalancer_route",
|
|
396
|
+
args=(
|
|
397
|
+
"create",
|
|
398
|
+
"-l",
|
|
399
|
+
s.LB_ID,
|
|
400
|
+
"-H",
|
|
401
|
+
s.HOST_ID,
|
|
402
|
+
"-p",
|
|
403
|
+
"/admin/",
|
|
404
|
+
"-P",
|
|
405
|
+
"1",
|
|
406
|
+
"-k",
|
|
407
|
+
s.HEALTHCHECK_ID,
|
|
408
|
+
"-a",
|
|
409
|
+
s.ACCESS_POLICY_ID,
|
|
410
|
+
),
|
|
411
|
+
method="POST",
|
|
412
|
+
path=f"/loadbalancer/{s.LB_ID}/host/{s.HOST_ID}/route/",
|
|
413
|
+
kind="create",
|
|
414
|
+
payload={"path": "/admin/", "priority": 1, "healthcheck": s.HEALTHCHECK_ID, "access_policy": s.ACCESS_POLICY_ID},
|
|
415
|
+
),
|
|
416
|
+
Case(
|
|
417
|
+
id="lb-route-attach-policy",
|
|
418
|
+
module="loadbalancer_route",
|
|
419
|
+
args=("attach-policy", "-l", s.LB_ID, "-H", s.HOST_ID, "-r", s.ROUTE_ID, "-a", s.ACCESS_POLICY_ID),
|
|
420
|
+
method="PATCH",
|
|
421
|
+
path=f"/loadbalancer/{s.LB_ID}/host/{s.HOST_ID}/route/{s.ROUTE_ID}/",
|
|
422
|
+
kind="other",
|
|
423
|
+
payload={"access_policy": s.ACCESS_POLICY_ID},
|
|
424
|
+
),
|
|
425
|
+
Case(
|
|
426
|
+
id="lb-route-detach-policy",
|
|
427
|
+
module="loadbalancer_route",
|
|
428
|
+
args=("detach-policy", "-l", s.LB_ID, "-H", s.HOST_ID, "-r", s.ROUTE_ID, "-y"),
|
|
429
|
+
method="PATCH",
|
|
430
|
+
path=f"/loadbalancer/{s.LB_ID}/host/{s.HOST_ID}/route/{s.ROUTE_ID}/",
|
|
431
|
+
kind="other",
|
|
432
|
+
payload={"access_policy": None},
|
|
392
433
|
),
|
|
393
434
|
Case(
|
|
394
435
|
id="lb-route-delete",
|
|
@@ -604,6 +645,181 @@ CASES: list[Case] = [
|
|
|
604
645
|
path=f"/certificate-peer/{s.CERT_PEER_ID}/",
|
|
605
646
|
kind="delete",
|
|
606
647
|
),
|
|
648
|
+
# -------------------------------------------------------------- access gate
|
|
649
|
+
Case(
|
|
650
|
+
id="access-gate-list",
|
|
651
|
+
module="access_gate",
|
|
652
|
+
args=("list", "-p", s.PROJECT_ID),
|
|
653
|
+
method="GET",
|
|
654
|
+
path="/access-gate/",
|
|
655
|
+
kind="list",
|
|
656
|
+
params={"project": s.PROJECT_ID},
|
|
657
|
+
columns=["id", "name", "project", "provider_type", "provider_issuer", "token_ttl"],
|
|
658
|
+
),
|
|
659
|
+
Case(
|
|
660
|
+
id="access-gate-create",
|
|
661
|
+
module="access_gate",
|
|
662
|
+
args=("create", "-p", s.PROJECT_ID, "-n", "staff"),
|
|
663
|
+
method="POST",
|
|
664
|
+
path="/access-gate/",
|
|
665
|
+
kind="create",
|
|
666
|
+
payload={
|
|
667
|
+
"project": s.PROJECT_ID,
|
|
668
|
+
"name": "staff",
|
|
669
|
+
"provider_type": "local",
|
|
670
|
+
"token_ttl": 86400,
|
|
671
|
+
"provider_issuer": "",
|
|
672
|
+
"provider_client_id": "",
|
|
673
|
+
"provider_client_secret": "",
|
|
674
|
+
"provider_scopes": [],
|
|
675
|
+
"provider_groups_claim": "groups",
|
|
676
|
+
},
|
|
677
|
+
),
|
|
678
|
+
Case(
|
|
679
|
+
id="access-gate-create-oidc",
|
|
680
|
+
module="access_gate",
|
|
681
|
+
args=(
|
|
682
|
+
"create",
|
|
683
|
+
"-p",
|
|
684
|
+
s.PROJECT_ID,
|
|
685
|
+
"-n",
|
|
686
|
+
"sso",
|
|
687
|
+
"--provider",
|
|
688
|
+
"oidc",
|
|
689
|
+
"--token-ttl",
|
|
690
|
+
"3600",
|
|
691
|
+
"--issuer",
|
|
692
|
+
"https://id.example.com",
|
|
693
|
+
"--client-id",
|
|
694
|
+
"dinemic",
|
|
695
|
+
"--client-secret",
|
|
696
|
+
"s3cret",
|
|
697
|
+
"--scope",
|
|
698
|
+
"openid",
|
|
699
|
+
"--scope",
|
|
700
|
+
"email",
|
|
701
|
+
"--groups-claim",
|
|
702
|
+
"roles",
|
|
703
|
+
),
|
|
704
|
+
method="POST",
|
|
705
|
+
path="/access-gate/",
|
|
706
|
+
kind="create",
|
|
707
|
+
payload={
|
|
708
|
+
"project": s.PROJECT_ID,
|
|
709
|
+
"name": "sso",
|
|
710
|
+
"provider_type": "oidc",
|
|
711
|
+
"token_ttl": 3600,
|
|
712
|
+
"provider_issuer": "https://id.example.com",
|
|
713
|
+
"provider_client_id": "dinemic",
|
|
714
|
+
"provider_client_secret": "s3cret",
|
|
715
|
+
"provider_scopes": ["openid", "email"],
|
|
716
|
+
"provider_groups_claim": "roles",
|
|
717
|
+
},
|
|
718
|
+
),
|
|
719
|
+
Case(
|
|
720
|
+
id="access-gate-delete",
|
|
721
|
+
module="access_gate",
|
|
722
|
+
args=("delete", "-g", s.ACCESS_GATE_ID, "-y"),
|
|
723
|
+
method="DELETE",
|
|
724
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/",
|
|
725
|
+
kind="delete",
|
|
726
|
+
),
|
|
727
|
+
Case(
|
|
728
|
+
id="access-group-list",
|
|
729
|
+
module="access_group",
|
|
730
|
+
args=("list", "-g", s.ACCESS_GATE_ID),
|
|
731
|
+
method="GET",
|
|
732
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/group/",
|
|
733
|
+
kind="list",
|
|
734
|
+
params={"gate": s.ACCESS_GATE_ID},
|
|
735
|
+
columns=["id", "name", "gate"],
|
|
736
|
+
),
|
|
737
|
+
Case(
|
|
738
|
+
id="access-group-create",
|
|
739
|
+
module="access_group",
|
|
740
|
+
args=("create", "-g", s.ACCESS_GATE_ID, "-n", "admins"),
|
|
741
|
+
method="POST",
|
|
742
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/group/",
|
|
743
|
+
kind="create",
|
|
744
|
+
payload={"gate": s.ACCESS_GATE_ID, "name": "admins"},
|
|
745
|
+
),
|
|
746
|
+
Case(
|
|
747
|
+
id="access-group-delete",
|
|
748
|
+
module="access_group",
|
|
749
|
+
args=("delete", "-g", s.ACCESS_GATE_ID, "-G", s.ACCESS_GROUP_ID, "-y"),
|
|
750
|
+
method="DELETE",
|
|
751
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/group/{s.ACCESS_GROUP_ID}/",
|
|
752
|
+
kind="delete",
|
|
753
|
+
),
|
|
754
|
+
Case(
|
|
755
|
+
id="access-user-list",
|
|
756
|
+
module="access_user",
|
|
757
|
+
args=("list", "-g", s.ACCESS_GATE_ID),
|
|
758
|
+
method="GET",
|
|
759
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/user/",
|
|
760
|
+
kind="list",
|
|
761
|
+
params={"gate": s.ACCESS_GATE_ID},
|
|
762
|
+
columns=["id", "username", "is_active", "groups", "gate"],
|
|
763
|
+
),
|
|
764
|
+
Case(
|
|
765
|
+
id="access-user-create",
|
|
766
|
+
module="access_user",
|
|
767
|
+
args=("create", "-g", s.ACCESS_GATE_ID, "-u", "alice", "--password", "correct-horse-battery", "--group", s.ACCESS_GROUP_ID),
|
|
768
|
+
method="POST",
|
|
769
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/user/",
|
|
770
|
+
kind="create",
|
|
771
|
+
payload={
|
|
772
|
+
"gate": s.ACCESS_GATE_ID,
|
|
773
|
+
"username": "alice",
|
|
774
|
+
"password": "correct-horse-battery",
|
|
775
|
+
"is_active": True,
|
|
776
|
+
"groups": [s.ACCESS_GROUP_ID],
|
|
777
|
+
},
|
|
778
|
+
),
|
|
779
|
+
Case(
|
|
780
|
+
id="access-user-create-inactive",
|
|
781
|
+
module="access_user",
|
|
782
|
+
args=("create", "-g", s.ACCESS_GATE_ID, "-u", "bob", "--password", "correct-horse-battery", "--inactive"),
|
|
783
|
+
method="POST",
|
|
784
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/user/",
|
|
785
|
+
kind="create",
|
|
786
|
+
payload={"gate": s.ACCESS_GATE_ID, "username": "bob", "password": "correct-horse-battery", "is_active": False, "groups": []},
|
|
787
|
+
),
|
|
788
|
+
Case(
|
|
789
|
+
id="access-user-delete",
|
|
790
|
+
module="access_user",
|
|
791
|
+
args=("delete", "-g", s.ACCESS_GATE_ID, "-U", s.ACCESS_USER_ID, "-y"),
|
|
792
|
+
method="DELETE",
|
|
793
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/user/{s.ACCESS_USER_ID}/",
|
|
794
|
+
kind="delete",
|
|
795
|
+
),
|
|
796
|
+
Case(
|
|
797
|
+
id="access-policy-list",
|
|
798
|
+
module="access_policy",
|
|
799
|
+
args=("list", "-g", s.ACCESS_GATE_ID),
|
|
800
|
+
method="GET",
|
|
801
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/policy/",
|
|
802
|
+
kind="list",
|
|
803
|
+
params={"gate": s.ACCESS_GATE_ID},
|
|
804
|
+
columns=["id", "name", "groups", "gate"],
|
|
805
|
+
),
|
|
806
|
+
Case(
|
|
807
|
+
id="access-policy-create",
|
|
808
|
+
module="access_policy",
|
|
809
|
+
args=("create", "-g", s.ACCESS_GATE_ID, "-n", "internal", "--group", s.ACCESS_GROUP_ID),
|
|
810
|
+
method="POST",
|
|
811
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/policy/",
|
|
812
|
+
kind="create",
|
|
813
|
+
payload={"gate": s.ACCESS_GATE_ID, "name": "internal", "groups": [s.ACCESS_GROUP_ID]},
|
|
814
|
+
),
|
|
815
|
+
Case(
|
|
816
|
+
id="access-policy-delete",
|
|
817
|
+
module="access_policy",
|
|
818
|
+
args=("delete", "-g", s.ACCESS_GATE_ID, "-a", s.ACCESS_POLICY_ID, "-y"),
|
|
819
|
+
method="DELETE",
|
|
820
|
+
path=f"/access-gate/{s.ACCESS_GATE_ID}/policy/{s.ACCESS_POLICY_ID}/",
|
|
821
|
+
kind="delete",
|
|
822
|
+
),
|
|
607
823
|
]
|
|
608
824
|
|
|
609
825
|
BY_ID = {case.id: case for case in CASES}
|
|
@@ -24,6 +24,10 @@ from typer.testing import CliRunner
|
|
|
24
24
|
#: Every command module. Add a new file under ``commands/`` -> list it here,
|
|
25
25
|
#: otherwise the contract tests (test_option_contract.py) will not see it.
|
|
26
26
|
COMMAND_MODULES = [
|
|
27
|
+
"access_gate",
|
|
28
|
+
"access_group",
|
|
29
|
+
"access_policy",
|
|
30
|
+
"access_user",
|
|
27
31
|
"auth",
|
|
28
32
|
"caa",
|
|
29
33
|
"cert",
|
|
@@ -156,6 +160,13 @@ class FakeClient:
|
|
|
156
160
|
# the backend answers with the read serializer: id plus what we sent
|
|
157
161
|
return {"id": "new-id", **payload}
|
|
158
162
|
|
|
163
|
+
def patch(self, path: str, payload: dict[str, Any]) -> Any:
|
|
164
|
+
self._record("PATCH", path, payload, {})
|
|
165
|
+
self._maybe_raise("PATCH", path)
|
|
166
|
+
if ("PATCH", path) in self._responses:
|
|
167
|
+
return self._responses[("PATCH", path)]
|
|
168
|
+
return {"id": path.rstrip("/").rsplit("/", 1)[-1], **payload}
|
|
169
|
+
|
|
159
170
|
def post_login(self, path: str, payload: dict[str, Any]) -> Any:
|
|
160
171
|
self._record("POST_LOGIN", path, payload, {})
|
|
161
172
|
self._maybe_raise("POST_LOGIN", path)
|
|
@@ -22,6 +22,34 @@ ENV_CASES = [
|
|
|
22
22
|
("healthcheck-list", "healthcheck", ["list"], "DINEMIC_PROJECT", s.PROJECT_ID, "/healthcheck/", {"project": s.PROJECT_ID}),
|
|
23
23
|
("lb-list", "loadbalancer", ["list"], "DINEMIC_PROJECT", s.PROJECT_ID, "/loadbalancer/", {"project": s.PROJECT_ID}),
|
|
24
24
|
("entry-list", "dns_entry", ["list"], "DINEMIC_ZONE", s.ZONE_ID, f"/zone/{s.ZONE_ID}/entry/", {}),
|
|
25
|
+
("access-gate-list", "access_gate", ["list"], "DINEMIC_PROJECT", s.PROJECT_ID, "/access-gate/", {"project": s.PROJECT_ID}),
|
|
26
|
+
(
|
|
27
|
+
"access-group-list",
|
|
28
|
+
"access_group",
|
|
29
|
+
["list"],
|
|
30
|
+
"DINEMIC_GATE",
|
|
31
|
+
s.ACCESS_GATE_ID,
|
|
32
|
+
f"/access-gate/{s.ACCESS_GATE_ID}/group/",
|
|
33
|
+
{"gate": s.ACCESS_GATE_ID},
|
|
34
|
+
),
|
|
35
|
+
(
|
|
36
|
+
"access-user-list",
|
|
37
|
+
"access_user",
|
|
38
|
+
["list"],
|
|
39
|
+
"DINEMIC_GATE",
|
|
40
|
+
s.ACCESS_GATE_ID,
|
|
41
|
+
f"/access-gate/{s.ACCESS_GATE_ID}/user/",
|
|
42
|
+
{"gate": s.ACCESS_GATE_ID},
|
|
43
|
+
),
|
|
44
|
+
(
|
|
45
|
+
"access-policy-list",
|
|
46
|
+
"access_policy",
|
|
47
|
+
["list"],
|
|
48
|
+
"DINEMIC_GATE",
|
|
49
|
+
s.ACCESS_GATE_ID,
|
|
50
|
+
f"/access-gate/{s.ACCESS_GATE_ID}/policy/",
|
|
51
|
+
{"gate": s.ACCESS_GATE_ID},
|
|
52
|
+
),
|
|
25
53
|
(
|
|
26
54
|
"value-list",
|
|
27
55
|
"dns_value",
|
|
@@ -277,14 +277,18 @@ def test_options_have_help_text():
|
|
|
277
277
|
#: Short flags that already carry more than one meaning. New collisions fail.
|
|
278
278
|
KNOWN_SHORT_FLAG_COLLISIONS = {
|
|
279
279
|
"-D": {"debug"},
|
|
280
|
+
"-G": {"group_id"},
|
|
280
281
|
"-H": {"healthcheck_id", "host", "host_id"},
|
|
281
282
|
"-L": {"log_level"},
|
|
282
283
|
"-N": {"node"},
|
|
283
284
|
"-P": {"path", "port", "priority"},
|
|
285
|
+
"-U": {"user_id"},
|
|
286
|
+
"-a": {"policy_id"},
|
|
284
287
|
"-b": {"backend_id"},
|
|
285
288
|
"-c": {"caa", "cert_peer_id", "config"},
|
|
286
289
|
"-d": {"directory_url", "domain", "domain_id", "period"},
|
|
287
290
|
"-e": {"endpoint_id"},
|
|
291
|
+
"-g": {"gate_id"},
|
|
288
292
|
"-i": {"initial_delay", "ip_address"},
|
|
289
293
|
"-k": {"healthcheck_id"},
|
|
290
294
|
"-l": {"loadbalancer_id"},
|
|
@@ -294,6 +298,7 @@ KNOWN_SHORT_FLAG_COLLISIONS = {
|
|
|
294
298
|
"-r": {"record", "record_id", "route_id"},
|
|
295
299
|
"-s": {"scheme"},
|
|
296
300
|
"-t": {"type_"},
|
|
301
|
+
"-u": {"username"},
|
|
297
302
|
"-v": {"value", "value_id"},
|
|
298
303
|
"-w": {"weight"},
|
|
299
304
|
"-y": {"yes"},
|
|
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
|
|
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
|