proxygen-cli 3.0.2__tar.gz → 4.0.2__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-3.0.2 → proxygen_cli-4.0.2}/PKG-INFO +10 -7
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/README.md +8 -5
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_credentials.py +14 -8
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_settings.py +12 -3
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/constants.py +0 -3
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/credentials.py +4 -6
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/settings.py +2 -2
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_credentials_test.py +28 -22
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_settings_test.py +1 -1
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/validate_cli_version_test.py +1 -1
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/pyproject.toml +2 -2
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/__init__.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_docker.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_instance.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_main.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_pytest_nhsd_apim_token.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_secret.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_spec.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/auth.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/dot_proxygen.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/output.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/proxygen_api.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/spec.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/spec_server.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/lib/version.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/__init__.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_instance_test.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_main_test.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_pytest_nhsd_apim_token_test.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_secret_test.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_spec_test.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/conftest.py +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/fixtures/client.key +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/fixtures/client.pem +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/fixtures/secret.txt +0 -0
- {proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/mock_private_key.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: proxygen-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: CLI for interacting with NHSD APIM's proxygen service
|
|
5
5
|
Author: Ben Strutt
|
|
6
6
|
Author-email: ben.strutt1@nhs.net
|
|
@@ -16,7 +16,7 @@ Requires-Dist: pydantic (>=1.9.1,<2.0.0)
|
|
|
16
16
|
Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
|
|
17
17
|
Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
|
|
18
18
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
19
|
-
Requires-Dist: tabulate (>=0.9
|
|
19
|
+
Requires-Dist: tabulate (>=0.9,<0.11)
|
|
20
20
|
Requires-Dist: yaspin (>=3.2.0,<4.0.0)
|
|
21
21
|
Project-URL: Repository, https://github.com/NHSDigital/proxygen-cli
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
@@ -38,9 +38,10 @@ After installation, the `proxygen` executable is available. Typing `proxygen` di
|
|
|
38
38
|
### Settings
|
|
39
39
|
To specify the API you are developing for, use:
|
|
40
40
|
```
|
|
41
|
-
proxygen settings set api <API-NAME>
|
|
41
|
+
proxygen settings set api <API-NAME> --env <ptl/prod>
|
|
42
42
|
```
|
|
43
43
|
Your user must have the appropriate permissions for managing instances, secrets, and specifications related to the specified API. If permissions are insufficient, commands will fail. Reach out to the `platforms-api-producer-support` channel for assistance with permissions.
|
|
44
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
### Credentials
|
|
@@ -54,9 +55,10 @@ If you are setting up user access for the first time you will first need to requ
|
|
|
54
55
|
|
|
55
56
|
To setup the Proxygen CLI credentials for the first time with user access enter the following command:
|
|
56
57
|
```
|
|
57
|
-
proxygen credentials set
|
|
58
|
+
proxygen credentials set --env <ptl/prod>
|
|
58
59
|
```
|
|
59
60
|
The CLI will ask you for your username, and password. These credentials will be securely stored on your local machine in the directory ~/.proxygen/credentials.yaml. The client_id and secret used for user access will be automatically added to this file after running the command.
|
|
61
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
60
62
|
|
|
61
63
|
Your user must have permissions to manipulate instances/secrets/specs for the API you set here. If you do not have sufficient permissions commands will fail. If you believe your permissions are incorrect, contact the API platform team via the [platforms-api-producer-support](https://nhsdigital-platforms.slack.com/archives/C016JRWN6AY) channel.
|
|
62
64
|
|
|
@@ -69,16 +71,17 @@ After having set up your API using the instructions at [Getting set up with prox
|
|
|
69
71
|
|
|
70
72
|
Using this information enter the following command:
|
|
71
73
|
```
|
|
72
|
-
proxygen credentials set private_key_path <PATH_TO_PRIVATE_KEY> key_id <KEY_ID_FOR_PRIVATE_KEY> client_id <MACHINE_USER_CLIENT_ID>
|
|
74
|
+
proxygen credentials set private_key_path <PATH_TO_PRIVATE_KEY> key_id <KEY_ID_FOR_PRIVATE_KEY> client_id <MACHINE_USER_CLIENT_ID> --env <ptl/prod>
|
|
73
75
|
```
|
|
74
76
|
The CLI will ask you for your username, and password. For machine authentication, the username and password must be left blank. The credentials will be securely stored in the directory ~/.proxygen/credentials.yaml.
|
|
77
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
75
78
|
|
|
76
79
|
> **_NOTE:_** If you are switching between using user access and machine-user access bare in mind:
|
|
77
80
|
> - proxygen-cli will favour user access if username and password credentials are set
|
|
78
81
|
> - User access uses proxygen-cli-user-client as a client_id. If you switch between access modes remember to switch the client_id
|
|
79
82
|
> - The value for client_secret should remain untouched as it is not used for machine-user access
|
|
80
83
|
> - If you lose the client_secret for then proxygen-cli-user-client then reach out to the platforms-api-producer-support channel for it
|
|
81
|
-
|
|
84
|
+
> - From version 4.0.0 CLI will prompt for client_id and client_secret instead of setting automatically.
|
|
82
85
|
|
|
83
86
|
## Commands
|
|
84
87
|
Commands are documented inside the CLI itself.
|
|
@@ -100,7 +103,7 @@ Use the following command to publish an API specification:
|
|
|
100
103
|
```
|
|
101
104
|
# Production
|
|
102
105
|
proxygen spec publish <path_to_spec>
|
|
103
|
-
|
|
106
|
+
|
|
104
107
|
# UAT
|
|
105
108
|
proxygen spec publish <path_to_spec> --uat
|
|
106
109
|
```
|
|
@@ -15,9 +15,10 @@ After installation, the `proxygen` executable is available. Typing `proxygen` di
|
|
|
15
15
|
### Settings
|
|
16
16
|
To specify the API you are developing for, use:
|
|
17
17
|
```
|
|
18
|
-
proxygen settings set api <API-NAME>
|
|
18
|
+
proxygen settings set api <API-NAME> --env <ptl/prod>
|
|
19
19
|
```
|
|
20
20
|
Your user must have the appropriate permissions for managing instances, secrets, and specifications related to the specified API. If permissions are insufficient, commands will fail. Reach out to the `platforms-api-producer-support` channel for assistance with permissions.
|
|
21
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
### Credentials
|
|
@@ -31,9 +32,10 @@ If you are setting up user access for the first time you will first need to requ
|
|
|
31
32
|
|
|
32
33
|
To setup the Proxygen CLI credentials for the first time with user access enter the following command:
|
|
33
34
|
```
|
|
34
|
-
proxygen credentials set
|
|
35
|
+
proxygen credentials set --env <ptl/prod>
|
|
35
36
|
```
|
|
36
37
|
The CLI will ask you for your username, and password. These credentials will be securely stored on your local machine in the directory ~/.proxygen/credentials.yaml. The client_id and secret used for user access will be automatically added to this file after running the command.
|
|
38
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
37
39
|
|
|
38
40
|
Your user must have permissions to manipulate instances/secrets/specs for the API you set here. If you do not have sufficient permissions commands will fail. If you believe your permissions are incorrect, contact the API platform team via the [platforms-api-producer-support](https://nhsdigital-platforms.slack.com/archives/C016JRWN6AY) channel.
|
|
39
41
|
|
|
@@ -46,16 +48,17 @@ After having set up your API using the instructions at [Getting set up with prox
|
|
|
46
48
|
|
|
47
49
|
Using this information enter the following command:
|
|
48
50
|
```
|
|
49
|
-
proxygen credentials set private_key_path <PATH_TO_PRIVATE_KEY> key_id <KEY_ID_FOR_PRIVATE_KEY> client_id <MACHINE_USER_CLIENT_ID>
|
|
51
|
+
proxygen credentials set private_key_path <PATH_TO_PRIVATE_KEY> key_id <KEY_ID_FOR_PRIVATE_KEY> client_id <MACHINE_USER_CLIENT_ID> --env <ptl/prod>
|
|
50
52
|
```
|
|
51
53
|
The CLI will ask you for your username, and password. For machine authentication, the username and password must be left blank. The credentials will be securely stored in the directory ~/.proxygen/credentials.yaml.
|
|
54
|
+
Parameter --env is optional, if the environment is not provided then CLI will default to Prod.
|
|
52
55
|
|
|
53
56
|
> **_NOTE:_** If you are switching between using user access and machine-user access bare in mind:
|
|
54
57
|
> - proxygen-cli will favour user access if username and password credentials are set
|
|
55
58
|
> - User access uses proxygen-cli-user-client as a client_id. If you switch between access modes remember to switch the client_id
|
|
56
59
|
> - The value for client_secret should remain untouched as it is not used for machine-user access
|
|
57
60
|
> - If you lose the client_secret for then proxygen-cli-user-client then reach out to the platforms-api-producer-support channel for it
|
|
58
|
-
|
|
61
|
+
> - From version 4.0.0 CLI will prompt for client_id and client_secret instead of setting automatically.
|
|
59
62
|
|
|
60
63
|
## Commands
|
|
61
64
|
Commands are documented inside the CLI itself.
|
|
@@ -77,7 +80,7 @@ Use the following command to publish an API specification:
|
|
|
77
80
|
```
|
|
78
81
|
# Production
|
|
79
82
|
proxygen spec publish <path_to_spec>
|
|
80
|
-
|
|
83
|
+
|
|
81
84
|
# UAT
|
|
82
85
|
proxygen spec publish <path_to_spec> --uat
|
|
83
86
|
```
|
|
@@ -42,11 +42,11 @@ def get(key):
|
|
|
42
42
|
creds = get_credentials()
|
|
43
43
|
click.echo(getattr(creds, key))
|
|
44
44
|
|
|
45
|
-
|
|
46
45
|
@credentials.command()
|
|
47
46
|
@click.argument("custom_pairs", nargs=-1, metavar="KEY VALUE", required=False)
|
|
48
47
|
@click.option("--force", is_flag=True, help="Force re-entry of standard credentials")
|
|
49
|
-
|
|
48
|
+
@click.option("--env", type=click.Choice(["prod", "ptl"], case_sensitive=False), default="prod", help="Environment to use for authentication")
|
|
49
|
+
def set(custom_pairs, force, env):
|
|
50
50
|
"""
|
|
51
51
|
Write a value to your credentials.
|
|
52
52
|
"""
|
|
@@ -55,16 +55,22 @@ def set(custom_pairs, force):
|
|
|
55
55
|
|
|
56
56
|
current_credentials = _yaml_credentials_file_source(None)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
KEYCLOAK_URLS = {
|
|
59
|
+
"prod": "https://identity.prod.api.platform.nhs.uk/realms/api-producers",
|
|
60
|
+
"ptl": "https://identity.ptl.api.platform.nhs.uk/realms/api-producers",
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
current_credentials["base_url"] = KEYCLOAK_URLS[env.lower()]
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
context = click.get_current_context()
|
|
66
|
+
if ("private_key_path" not in context.params["custom_pairs"]):
|
|
67
|
+
client_id = click.prompt("Enter client ID", default="", show_default=False)
|
|
68
|
+
client_secret = click.prompt("Enter client secret", default="", show_default=False)
|
|
65
69
|
username = click.prompt("Enter username", default="", show_default=False)
|
|
66
70
|
password = click.prompt("Enter password", default="", show_default=False)
|
|
67
71
|
|
|
72
|
+
current_credentials["client_id"] = client_id
|
|
73
|
+
current_credentials["client_secret"] = client_secret
|
|
68
74
|
current_credentials["username"] = username
|
|
69
75
|
current_credentials["password"] = password
|
|
70
76
|
|
|
@@ -19,7 +19,6 @@ def settings():
|
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
def _get_setting(key):
|
|
24
23
|
return getattr(SETTINGS, key)
|
|
25
24
|
|
|
@@ -31,6 +30,7 @@ def list():
|
|
|
31
30
|
"""
|
|
32
31
|
output.print_spec(json.loads(SETTINGS.json(exclude_none=True)))
|
|
33
32
|
|
|
33
|
+
|
|
34
34
|
@settings.command()
|
|
35
35
|
@click.argument("key", type=CHOICE_OF_SETTINGS_KEYS)
|
|
36
36
|
def get(key):
|
|
@@ -43,14 +43,23 @@ def get(key):
|
|
|
43
43
|
@settings.command()
|
|
44
44
|
@click.argument("key", type=CHOICE_OF_SETTINGS_KEYS)
|
|
45
45
|
@click.argument("value")
|
|
46
|
-
|
|
46
|
+
@click.option("--env", type=click.Choice(["prod", "ptl"], case_sensitive=False), default="prod", help="Environment to use for authentication")
|
|
47
|
+
def set(key, value, env):
|
|
47
48
|
"""
|
|
48
49
|
Write a value to your settings.
|
|
49
50
|
"""
|
|
50
51
|
_get_setting(key)
|
|
51
52
|
|
|
52
53
|
current_settings = _yaml_settings_file_source(None)
|
|
54
|
+
|
|
55
|
+
PROXYGEN_URLS = {
|
|
56
|
+
"prod": "https://proxygen.prod.api.platform.nhs.uk",
|
|
57
|
+
"ptl": "https://proxygen.ptl.api.platform.nhs.uk",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
current_settings["endpoint_url"] = PROXYGEN_URLS[env.lower()]
|
|
53
61
|
current_settings[key] = value
|
|
62
|
+
|
|
54
63
|
try:
|
|
55
64
|
new_settings = json.loads(Settings(**current_settings).json(exclude_none=True))
|
|
56
65
|
except pydantic.ValidationError as e:
|
|
@@ -71,4 +80,4 @@ def rm(key):
|
|
|
71
80
|
current_settings = _yaml_settings_file_source(None)
|
|
72
81
|
current_settings.pop(key, None)
|
|
73
82
|
with settings_file().open("w") as f:
|
|
74
|
-
yaml.safe_dump(current_settings, f)
|
|
83
|
+
yaml.safe_dump(current_settings, f)
|
|
@@ -31,13 +31,11 @@ def create_yaml_credentials_file():
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class Credentials(BaseSettings):
|
|
34
|
-
base_url: AnyHttpUrl
|
|
35
|
-
"https://identity.prod.api.platform.nhs.uk/realms/api-producers"
|
|
36
|
-
)
|
|
34
|
+
base_url: AnyHttpUrl
|
|
37
35
|
private_key_path: Optional[str] = None
|
|
38
36
|
key_id: Optional[str] = None
|
|
39
|
-
client_id: str =
|
|
40
|
-
client_secret: Optional[str] =
|
|
37
|
+
client_id: Optional[str] = None
|
|
38
|
+
client_secret: Optional[str] = None
|
|
41
39
|
username: Optional[str] = None
|
|
42
40
|
password: Optional[str] = None
|
|
43
41
|
|
|
@@ -137,4 +135,4 @@ def initialise_credentials():
|
|
|
137
135
|
def get_credentials():
|
|
138
136
|
initialise_credentials()
|
|
139
137
|
global _CREDENTIALS
|
|
140
|
-
return _CREDENTIALS
|
|
138
|
+
return _CREDENTIALS
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Literal
|
|
1
|
+
from typing import Literal, Optional
|
|
2
2
|
from pydantic import BaseSettings, AnyUrl
|
|
3
3
|
|
|
4
4
|
import yaml
|
|
@@ -13,7 +13,7 @@ def _yaml_settings_file_source(_):
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class Settings(BaseSettings):
|
|
16
|
-
endpoint_url: AnyUrl =
|
|
16
|
+
endpoint_url: Optional[AnyUrl] = None
|
|
17
17
|
spec_output_format: Literal["json", "yaml"] = "yaml"
|
|
18
18
|
api: str = None
|
|
19
19
|
|
|
@@ -10,10 +10,14 @@ import proxygen_cli.cli.command_credentials as cmd_credentials
|
|
|
10
10
|
from proxygen_cli.lib.credentials import Credentials
|
|
11
11
|
CLIENT_ID = os.environ["PROXYGEN_CLIENT_ID"]
|
|
12
12
|
CLIENT_SECRET = os.environ["PROXYGEN_CLIENT_SECRET"]
|
|
13
|
+
# added below urls to resolve sonar cloud issues.
|
|
14
|
+
KEYCLOAK_URL = "https://identity.prod.api.platform.nhs.uk/realms/api-producers"
|
|
15
|
+
MOCK_KEYCLOAK_URL = "https://mock-keycloak-url.nhs.uk"
|
|
16
|
+
BASE_URL_LABEL = "base_url: "
|
|
13
17
|
|
|
14
18
|
def get_test_credentials(**kwargs):
|
|
15
19
|
base_credentials = {
|
|
16
|
-
"base_url":
|
|
20
|
+
"base_url": MOCK_KEYCLOAK_URL,
|
|
17
21
|
"client_id": "mock-api-client",
|
|
18
22
|
"client_secret": "1a2f4g5",
|
|
19
23
|
"password": "mock-password",
|
|
@@ -31,7 +35,7 @@ def get_test_credentials(**kwargs):
|
|
|
31
35
|
#get mock values for credentials.yaml file
|
|
32
36
|
def get_test_proxygen_client_credentials(**kwargs):
|
|
33
37
|
client_credentials = {
|
|
34
|
-
"base_url":
|
|
38
|
+
"base_url": MOCK_KEYCLOAK_URL,
|
|
35
39
|
"client_id": CLIENT_ID,
|
|
36
40
|
"client_secret": CLIENT_SECRET,
|
|
37
41
|
"password": "mock-password",
|
|
@@ -52,11 +56,12 @@ def test_set_proxygen_user_credential(patch_config, credentials_file):
|
|
|
52
56
|
|
|
53
57
|
with patch_config(credentials=mock_credentials):
|
|
54
58
|
runner = CliRunner()
|
|
55
|
-
|
|
59
|
+
input_data = "\n".join([CLIENT_ID, CLIENT_SECRET, "new-username", "mock-password"])
|
|
60
|
+
runner.invoke(cmd_credentials.set,[],input=input_data,)
|
|
56
61
|
|
|
57
62
|
expected_credentials = "\n".join(
|
|
58
63
|
[
|
|
59
|
-
|
|
64
|
+
BASE_URL_LABEL + KEYCLOAK_URL,
|
|
60
65
|
"client_id: "+CLIENT_ID,
|
|
61
66
|
"client_secret: "+CLIENT_SECRET,
|
|
62
67
|
"password: mock-password",
|
|
@@ -84,12 +89,12 @@ def test_update_proxygen_user_credentials(patch_config, credentials_file):
|
|
|
84
89
|
|
|
85
90
|
with patch_config(credentials=mock_credentials):
|
|
86
91
|
runner = CliRunner()
|
|
87
|
-
|
|
88
|
-
runner.invoke(cmd_credentials.set,
|
|
92
|
+
input_data = "\n".join([CLIENT_ID, CLIENT_SECRET, "new-username123", "new-password123"])
|
|
93
|
+
runner.invoke(cmd_credentials.set,[],input=input_data,)
|
|
89
94
|
|
|
90
95
|
expected_credentials = "\n".join(
|
|
91
96
|
[
|
|
92
|
-
|
|
97
|
+
BASE_URL_LABEL + KEYCLOAK_URL,
|
|
93
98
|
"client_id: "+CLIENT_ID,
|
|
94
99
|
"client_secret: "+CLIENT_SECRET,
|
|
95
100
|
"password: new-password123",
|
|
@@ -117,16 +122,16 @@ def test_update_proxygen_client_credentials(patch_config, credentials_file):
|
|
|
117
122
|
|
|
118
123
|
with patch_config(credentials=mock_credentials):
|
|
119
124
|
runner = CliRunner()
|
|
120
|
-
|
|
121
|
-
runner.invoke(cmd_credentials.set,
|
|
125
|
+
input_data = "\n".join(["new-clientid123", "new-clientsecret123", "new-user", "new-password"])
|
|
126
|
+
runner.invoke(cmd_credentials.set,[],input=input_data,)
|
|
122
127
|
|
|
123
128
|
expected_credentials = "\n".join(
|
|
124
129
|
[
|
|
125
|
-
|
|
130
|
+
BASE_URL_LABEL + KEYCLOAK_URL,
|
|
126
131
|
"client_id: new-clientid123",
|
|
127
132
|
"client_secret: new-clientsecret123",
|
|
128
|
-
"password:
|
|
129
|
-
"username:
|
|
133
|
+
"password: new-password",
|
|
134
|
+
"username: new-user",
|
|
130
135
|
]
|
|
131
136
|
)
|
|
132
137
|
|
|
@@ -207,13 +212,14 @@ def test_set_credential(patch_config, credentials_file):
|
|
|
207
212
|
|
|
208
213
|
with patch_config(credentials=mock_credentials):
|
|
209
214
|
runner = CliRunner()
|
|
210
|
-
|
|
215
|
+
input_data = "\n".join(["mock-api-client", "mock-api-clientsecret", "new-username", "mock-password"])
|
|
216
|
+
runner.invoke(cmd_credentials.set,[],input=input_data,)
|
|
211
217
|
|
|
212
218
|
expected_credentials = "\n".join(
|
|
213
219
|
[
|
|
214
|
-
|
|
220
|
+
BASE_URL_LABEL + KEYCLOAK_URL,
|
|
215
221
|
"client_id: mock-api-client",
|
|
216
|
-
"client_secret:
|
|
222
|
+
"client_secret: mock-api-clientsecret",
|
|
217
223
|
"password: mock-password",
|
|
218
224
|
"username: new-username",
|
|
219
225
|
]
|
|
@@ -235,13 +241,14 @@ def test_update_credentials(patch_config, credentials_file):
|
|
|
235
241
|
|
|
236
242
|
with patch_config(credentials=mock_credentials):
|
|
237
243
|
runner = CliRunner()
|
|
238
|
-
|
|
244
|
+
input_data = "\n".join(["mock-api-client", "mock-api-clientsecret", "new-username123", "mock-password"])
|
|
245
|
+
runner.invoke(cmd_credentials.set,[],input=input_data,)
|
|
239
246
|
|
|
240
247
|
expected_credentials = "\n".join(
|
|
241
248
|
[
|
|
242
|
-
|
|
249
|
+
BASE_URL_LABEL + KEYCLOAK_URL,
|
|
243
250
|
"client_id: mock-api-client",
|
|
244
|
-
"client_secret:
|
|
251
|
+
"client_secret: mock-api-clientsecret",
|
|
245
252
|
"password: mock-password",
|
|
246
253
|
"username: new-username123", # Updated value
|
|
247
254
|
]
|
|
@@ -260,10 +267,9 @@ def test_add_key_id(patch_config, credentials_file):
|
|
|
260
267
|
|
|
261
268
|
expected_credentials = "\n".join(
|
|
262
269
|
[
|
|
263
|
-
|
|
270
|
+
BASE_URL_LABEL + MOCK_KEYCLOAK_URL,
|
|
264
271
|
"client_id: mock-api-client",
|
|
265
272
|
"client_secret: 1a2f4g5",
|
|
266
|
-
"key_id: test_kid",
|
|
267
273
|
"password: mock-password",
|
|
268
274
|
"username: mock-user",
|
|
269
275
|
]
|
|
@@ -279,7 +285,7 @@ def test_set_invalid_setting(patch_config):
|
|
|
279
285
|
runner = CliRunner()
|
|
280
286
|
result = runner.invoke(cmd_credentials.set, ["invalid", "new-username"])
|
|
281
287
|
|
|
282
|
-
assert "
|
|
288
|
+
assert "Enter client ID:Aborted!" in result.output.strip()
|
|
283
289
|
|
|
284
290
|
|
|
285
291
|
def test_set_invalid_private_key_path(patch_config):
|
|
@@ -302,7 +308,7 @@ def test_remove_setting(patch_config, credentials_file):
|
|
|
302
308
|
|
|
303
309
|
expected_credentials = "\n".join(
|
|
304
310
|
[
|
|
305
|
-
|
|
311
|
+
BASE_URL_LABEL + MOCK_KEYCLOAK_URL,
|
|
306
312
|
"client_id: mock-api-client",
|
|
307
313
|
"client_secret: 1a2f4g5",
|
|
308
314
|
"password: mock-password",
|
|
@@ -73,7 +73,7 @@ def test_set_setting(patch_config, settings_file):
|
|
|
73
73
|
expected_settings = "\n".join(
|
|
74
74
|
[
|
|
75
75
|
"api: new_api_name",
|
|
76
|
-
"endpoint_url: https://
|
|
76
|
+
"endpoint_url: https://proxygen.prod.api.platform.nhs.uk",
|
|
77
77
|
"spec_output_format: json",
|
|
78
78
|
]
|
|
79
79
|
)
|
|
@@ -13,7 +13,7 @@ def test_validate_cli_version_success(patch_request):
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def test_validate_cli_version_failure(patch_request):
|
|
16
|
-
required_version = "
|
|
16
|
+
required_version = "5.0.0"
|
|
17
17
|
|
|
18
18
|
mocked_response = {"proxygen_cli": {"min_version": required_version}}
|
|
19
19
|
with patch_request(200, mocked_response), pytest.raises(RuntimeError) as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "proxygen-cli"
|
|
3
|
-
version = "
|
|
3
|
+
version = "4.0.2"
|
|
4
4
|
description = "CLI for interacting with NHSD APIM's proxygen service"
|
|
5
5
|
authors = ["Ben Strutt <ben.strutt1@nhs.net>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -20,7 +20,7 @@ lxml = "^6.0.1"
|
|
|
20
20
|
cryptography = ">= 44.0.1, < 47.0.0" # Not directly imported, but needed by pyjwt for the RS512 algorithm
|
|
21
21
|
pyyaml = "^6.0.3"
|
|
22
22
|
yaspin = "^3.2.0"
|
|
23
|
-
tabulate = "
|
|
23
|
+
tabulate = ">=0.9,<0.11"
|
|
24
24
|
packaging = "^24.2"
|
|
25
25
|
|
|
26
26
|
[tool.poetry.group.dev.dependencies]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/cli/command_pytest_nhsd_apim_token.py
RENAMED
|
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
|
{proxygen_cli-3.0.2 → proxygen_cli-4.0.2}/proxygen_cli/test/command_pytest_nhsd_apim_token_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|