proxygen-cli 2.0.16__tar.gz → 2.0.17__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.
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/PKG-INFO +1 -1
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_main.py +2 -5
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_spec.py +40 -16
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_spec_test.py +29 -3
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/pyproject.toml +1 -1
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/README.md +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/__init__.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_credentials.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_docker.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_instance.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_secret.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/cli/command_settings.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/auth.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/constants.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/credentials.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/dot_proxygen.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/output.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/proxygen_api.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/settings.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/spec.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/spec_server.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/lib/version.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/__init__.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_credentials_test.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_instance_test.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_main_test.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_secret_test.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/command_settings_test.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/conftest.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/fixtures/client.key +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/fixtures/client.pem +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/fixtures/secret.txt +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/mock_private_key.py +0 -0
- {proxygen_cli-2.0.16 → proxygen_cli-2.0.17}/proxygen_cli/test/validate_cli_version_test.py +0 -0
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from typing import get_args
|
|
3
|
-
from urllib import parse
|
|
4
1
|
import click
|
|
5
2
|
from proxygen_cli.lib.settings import SETTINGS
|
|
6
3
|
|
|
7
|
-
from proxygen_cli.lib import
|
|
4
|
+
from proxygen_cli.lib import proxygen_api, output
|
|
8
5
|
from proxygen_cli.cli import (
|
|
9
6
|
command_credentials,
|
|
10
7
|
command_settings,
|
|
@@ -23,7 +20,7 @@ def main():
|
|
|
23
20
|
main.add_command(command_settings.settings)
|
|
24
21
|
main.add_command(command_credentials.credentials)
|
|
25
22
|
main.add_command(command_instance.instance)
|
|
26
|
-
main.add_command(command_spec.
|
|
23
|
+
main.add_command(command_spec.spec)
|
|
27
24
|
main.add_command(command_secret.secret)
|
|
28
25
|
main.add_command(command_docker.docker)
|
|
29
26
|
|
|
@@ -3,34 +3,58 @@ from typing import get_args
|
|
|
3
3
|
import click
|
|
4
4
|
from yaspin import yaspin
|
|
5
5
|
|
|
6
|
-
from proxygen_cli.lib import output, proxygen_api, spec,
|
|
6
|
+
from proxygen_cli.lib import output, proxygen_api, spec as lib_spec, \
|
|
7
|
+
spec_server
|
|
7
8
|
from proxygen_cli.lib.constants import LITERAL_ENVS
|
|
8
9
|
from proxygen_cli.lib.settings import SETTINGS
|
|
9
10
|
|
|
10
11
|
CHOICE_OF_ENVS = click.Choice(get_args(LITERAL_ENVS))
|
|
11
12
|
PUBLISH_SPEC_POP_KEYS = ["x-nhsd-apim"] # Don't publish deployment information
|
|
12
13
|
|
|
14
|
+
HELP_NO_CONFIRM = "Do not prompt for confirmation."
|
|
15
|
+
HELP_UAT = "Target the UAT instance of API catalogue."
|
|
16
|
+
|
|
17
|
+
UAT_KWARGS = {
|
|
18
|
+
'default': False,
|
|
19
|
+
'help': HELP_UAT,
|
|
20
|
+
'is_flag': True
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
NO_CONFIRM_KWARGS = {
|
|
24
|
+
'is_flag': True,
|
|
25
|
+
'show_default': True,
|
|
26
|
+
'help': HELP_NO_CONFIRM,
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
|
|
14
30
|
@click.group()
|
|
15
31
|
@click.option(
|
|
16
|
-
"--api",
|
|
32
|
+
"--api",
|
|
33
|
+
default=SETTINGS.api,
|
|
34
|
+
help="Override the default API",
|
|
35
|
+
show_default=True
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"--uat",
|
|
39
|
+
**UAT_KWARGS
|
|
17
40
|
)
|
|
18
41
|
@click.pass_context
|
|
19
|
-
def
|
|
42
|
+
def spec(ctx, api, uat):
|
|
43
|
+
"""Publish/update/delete specifications on the API catalogue."""
|
|
20
44
|
ctx.ensure_object(dict)
|
|
21
45
|
ctx.obj["api"] = api
|
|
46
|
+
ctx.obj['uat'] = uat
|
|
22
47
|
|
|
23
48
|
|
|
24
|
-
@
|
|
49
|
+
@spec.command()
|
|
25
50
|
@click.argument("spec_file")
|
|
26
51
|
@click.option(
|
|
27
52
|
"--no-confirm",
|
|
28
|
-
|
|
29
|
-
show_default=True,
|
|
30
|
-
help="Do not prompt for confirmation.",
|
|
53
|
+
**NO_CONFIRM_KWARGS
|
|
31
54
|
)
|
|
32
55
|
@click.option(
|
|
33
|
-
"--uat",
|
|
56
|
+
"--uat",
|
|
57
|
+
**UAT_KWARGS
|
|
34
58
|
)
|
|
35
59
|
@click.pass_context
|
|
36
60
|
def publish(ctx, spec_file, no_confirm, uat):
|
|
@@ -39,7 +63,7 @@ def publish(ctx, spec_file, no_confirm, uat):
|
|
|
39
63
|
"""
|
|
40
64
|
|
|
41
65
|
api = ctx.obj["api"]
|
|
42
|
-
paas_open_api =
|
|
66
|
+
paas_open_api = lib_spec.resolve(spec_file, pop_keys=PUBLISH_SPEC_POP_KEYS)
|
|
43
67
|
|
|
44
68
|
if not no_confirm:
|
|
45
69
|
output.print_spec(paas_open_api)
|
|
@@ -69,9 +93,10 @@ def serve(spec_file):
|
|
|
69
93
|
spec_server.serve(spec_file, pop_keys=PUBLISH_SPEC_POP_KEYS)
|
|
70
94
|
|
|
71
95
|
|
|
72
|
-
@
|
|
96
|
+
@spec.command()
|
|
73
97
|
@click.option(
|
|
74
|
-
"--uat",
|
|
98
|
+
"--uat",
|
|
99
|
+
**UAT_KWARGS
|
|
75
100
|
)
|
|
76
101
|
@click.pass_context
|
|
77
102
|
def get(ctx, uat):
|
|
@@ -83,15 +108,14 @@ def get(ctx, uat):
|
|
|
83
108
|
output.print_spec(result)
|
|
84
109
|
|
|
85
110
|
|
|
86
|
-
@
|
|
111
|
+
@spec.command()
|
|
87
112
|
@click.option(
|
|
88
113
|
"--no-confirm",
|
|
89
|
-
|
|
90
|
-
show_default=True,
|
|
91
|
-
help="Do not prompt for confirmation.",
|
|
114
|
+
**NO_CONFIRM_KWARGS
|
|
92
115
|
)
|
|
93
116
|
@click.option(
|
|
94
|
-
"--uat",
|
|
117
|
+
"--uat",
|
|
118
|
+
**UAT_KWARGS
|
|
95
119
|
)
|
|
96
120
|
@click.pass_context
|
|
97
121
|
def delete(ctx, no_confirm, uat):
|
|
@@ -3,9 +3,11 @@ Tests around the spec CLI command.
|
|
|
3
3
|
"""
|
|
4
4
|
from urllib.parse import urlparse
|
|
5
5
|
from click.testing import CliRunner
|
|
6
|
+
import pytest
|
|
6
7
|
|
|
7
8
|
from proxygen_cli.cli.command_spec import get as spec_get, \
|
|
8
|
-
delete as spec_delete, publish as spec_publish
|
|
9
|
+
delete as spec_delete, publish as spec_publish, spec as spec_base, \
|
|
10
|
+
serve as spec_serve
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
def test_publish_spec_std(patch_request, patch_access_token,
|
|
@@ -15,7 +17,7 @@ def test_publish_spec_std(patch_request, patch_access_token,
|
|
|
15
17
|
"""
|
|
16
18
|
|
|
17
19
|
runner = CliRunner()
|
|
18
|
-
with patch_access_token(), patch_request(200, "TEST") as patched_request
|
|
20
|
+
with patch_access_token(), patch_request(200, "TEST") as patched_request, \
|
|
19
21
|
patch_spec_resolver(), patch_click_confirm():
|
|
20
22
|
|
|
21
23
|
runner.invoke(spec_publish, ["NoFile"], obj={"api": "mock-api"})
|
|
@@ -32,7 +34,7 @@ def test_publish_spec_uat(patch_request, patch_access_token,
|
|
|
32
34
|
"""
|
|
33
35
|
|
|
34
36
|
runner = CliRunner()
|
|
35
|
-
with patch_access_token(), patch_request(200, "TEST") as patched_request
|
|
37
|
+
with patch_access_token(), patch_request(200, "TEST") as patched_request, \
|
|
36
38
|
patch_spec_resolver(), patch_click_confirm():
|
|
37
39
|
|
|
38
40
|
runner.invoke(
|
|
@@ -110,6 +112,30 @@ def test_delete_spec_uat(patch_request, patch_access_token,
|
|
|
110
112
|
assert path == "/apis/mock-api/spec/uat"
|
|
111
113
|
|
|
112
114
|
|
|
115
|
+
@pytest.mark.parametrize("cmd, uat_expected", [
|
|
116
|
+
(spec_get, True),
|
|
117
|
+
(spec_delete, True),
|
|
118
|
+
(spec_publish, True),
|
|
119
|
+
(spec_serve, False),
|
|
120
|
+
(spec_base, True)
|
|
121
|
+
])
|
|
122
|
+
def test_uat_option_in_expected_command_help(cmd, uat_expected):
|
|
123
|
+
"""
|
|
124
|
+
Ensure the --uat option is only available for the appropriate spec
|
|
125
|
+
commands.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
runner = CliRunner()
|
|
129
|
+
result = runner.invoke(cmd, ["--help"])
|
|
130
|
+
|
|
131
|
+
if uat_expected:
|
|
132
|
+
assert "--uat" in result.output, \
|
|
133
|
+
f"--uat option was expected but not found for command {cmd}"
|
|
134
|
+
else:
|
|
135
|
+
assert "--uat" not in result.output, \
|
|
136
|
+
f"--uat option was not expected but found for command {cmd}"
|
|
137
|
+
|
|
138
|
+
|
|
113
139
|
def _extract_request_path(mocked_request, method='GET'):
|
|
114
140
|
"""
|
|
115
141
|
Extract the path from the first mocked call to .get() in the provided
|
|
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
|