proxygen-cli 2.1.7__tar.gz → 2.1.9__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.1.7 → proxygen_cli-2.1.9}/PKG-INFO +6 -6
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/README.md +5 -5
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_credentials.py +4 -8
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_main.py +2 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/credentials.py +9 -1
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_credentials_test.py +116 -1
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/pyproject.toml +1 -1
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/__init__.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_docker.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_instance.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_pytest_nhsd_apim_token.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_secret.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_settings.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/cli/command_spec.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/auth.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/constants.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/dot_proxygen.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/output.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/proxygen_api.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/settings.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/spec.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/spec_server.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/lib/version.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/__init__.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_instance_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_main_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_pytest_nhsd_apim_token_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_secret_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_settings_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/command_spec_test.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/conftest.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/fixtures/client.key +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/fixtures/client.pem +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/fixtures/secret.txt +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/mock_private_key.py +0 -0
- {proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/proxygen_cli/test/validate_cli_version_test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: proxygen-cli
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.9
|
|
4
4
|
Summary: CLI for interacting with NHSD APIM's proxygen service
|
|
5
5
|
Home-page: https://github.com/NHSDigital/proxygen-cli
|
|
6
6
|
Author: Ben Strutt
|
|
@@ -38,15 +38,15 @@ After installation, the `proxygen` executable is available. Typing `proxygen` di
|
|
|
38
38
|
|
|
39
39
|
### Credentials
|
|
40
40
|
|
|
41
|
-
The CLI
|
|
41
|
+
The Proxygen CLI client credentials `client_id`, `client_secret` are setup as part of proxygen CLI package.
|
|
42
42
|
|
|
43
|
-
All users should
|
|
44
|
-
You can setup the credentials in `proxygen-cli` using:
|
|
43
|
+
All users should have individual credentials. `proxygen-cli` needs to know about them. You can setup your user credentials in proxygen-cli using:
|
|
45
44
|
```
|
|
46
45
|
proxygen credentials set
|
|
47
46
|
```
|
|
48
|
-
This command prompts you to enter your `
|
|
49
|
-
|
|
47
|
+
This command prompts you to enter your `username`, and `password`.
|
|
48
|
+
|
|
49
|
+
To update any credentials `client_id`/ `client_secret`/ `username`/ `password` in the future, use:
|
|
50
50
|
```
|
|
51
51
|
proxygen credentials set <KEY> <VALUE>
|
|
52
52
|
```
|
|
@@ -13,15 +13,15 @@ After installation, the `proxygen` executable is available. Typing `proxygen` di
|
|
|
13
13
|
|
|
14
14
|
### Credentials
|
|
15
15
|
|
|
16
|
-
The CLI
|
|
16
|
+
The Proxygen CLI client credentials `client_id`, `client_secret` are setup as part of proxygen CLI package.
|
|
17
17
|
|
|
18
|
-
All users should
|
|
19
|
-
You can setup the credentials in `proxygen-cli` using:
|
|
18
|
+
All users should have individual credentials. `proxygen-cli` needs to know about them. You can setup your user credentials in proxygen-cli using:
|
|
20
19
|
```
|
|
21
20
|
proxygen credentials set
|
|
22
21
|
```
|
|
23
|
-
This command prompts you to enter your `
|
|
24
|
-
|
|
22
|
+
This command prompts you to enter your `username`, and `password`.
|
|
23
|
+
|
|
24
|
+
To update any credentials `client_id`/ `client_secret`/ `username`/ `password` in the future, use:
|
|
25
25
|
```
|
|
26
26
|
proxygen credentials set <KEY> <VALUE>
|
|
27
27
|
```
|
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
import click
|
|
3
3
|
import yaml
|
|
4
4
|
import pydantic
|
|
5
|
+
import os
|
|
5
6
|
|
|
6
7
|
from proxygen_cli.lib import output
|
|
7
8
|
from proxygen_cli.lib.credentials import (
|
|
@@ -10,7 +11,6 @@ from proxygen_cli.lib.dot_proxygen import credentials_file
|
|
|
10
11
|
|
|
11
12
|
CHOICE_OF_CREDENTIAL_KEYS = click.Choice(Credentials.__fields__.keys())
|
|
12
13
|
|
|
13
|
-
|
|
14
14
|
@click.group()
|
|
15
15
|
def credentials():
|
|
16
16
|
"""Get/set credentials."""
|
|
@@ -55,20 +55,16 @@ def set(custom_pairs, force):
|
|
|
55
55
|
|
|
56
56
|
current_credentials = _yaml_credentials_file_source(None)
|
|
57
57
|
|
|
58
|
-
# Check if
|
|
58
|
+
# Check if user credentials are set
|
|
59
59
|
base_credentials_set = all(
|
|
60
60
|
current_credentials.get(field) is not None
|
|
61
|
-
for field in ["
|
|
61
|
+
for field in ["username", "password"]
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
if not base_credentials_set or force:
|
|
65
|
-
client_id = click.prompt("Enter client_id")
|
|
66
|
-
client_secret = click.prompt("Enter client_secret", default="", show_default=False)
|
|
67
65
|
username = click.prompt("Enter username", default="", show_default=False)
|
|
68
66
|
password = click.prompt("Enter password", default="", show_default=False)
|
|
69
67
|
|
|
70
|
-
current_credentials["client_id"] = client_id
|
|
71
|
-
current_credentials["client_secret"] = client_secret
|
|
72
68
|
current_credentials["username"] = username
|
|
73
69
|
current_credentials["password"] = password
|
|
74
70
|
|
|
@@ -98,4 +94,4 @@ def rm(key):
|
|
|
98
94
|
current_credentials = _yaml_credentials_file_source(None)
|
|
99
95
|
current_credentials.pop(key, None)
|
|
100
96
|
with credentials_file().open("w") as f:
|
|
101
|
-
yaml.safe_dump(current_credentials, f)
|
|
97
|
+
yaml.safe_dump(current_credentials, f)
|
|
@@ -9,6 +9,7 @@ from proxygen_cli.cli import (
|
|
|
9
9
|
command_spec,
|
|
10
10
|
command_secret,
|
|
11
11
|
command_docker,
|
|
12
|
+
command_pytest_nhsd_apim_token
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
|
|
@@ -23,6 +24,7 @@ main.add_command(command_instance.instance)
|
|
|
23
24
|
main.add_command(command_spec.spec)
|
|
24
25
|
main.add_command(command_secret.secret)
|
|
25
26
|
main.add_command(command_docker.docker)
|
|
27
|
+
main.add_command(command_pytest_nhsd_apim_token.pytest_nhsd_apim)
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
@main.command()
|
|
@@ -15,6 +15,11 @@ from pydantic import (
|
|
|
15
15
|
|
|
16
16
|
from . import dot_proxygen
|
|
17
17
|
|
|
18
|
+
CLIENT_ID = os.environ["proxygen_client_id"]
|
|
19
|
+
CLIENT_SECRET = os.environ["proxygen_client_secret"]
|
|
20
|
+
|
|
21
|
+
data = {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET}
|
|
22
|
+
|
|
18
23
|
|
|
19
24
|
def _yaml_credentials_file_source(_):
|
|
20
25
|
with dot_proxygen.credentials_file().open() as yaml_file:
|
|
@@ -26,7 +31,8 @@ def create_yaml_credentials_file():
|
|
|
26
31
|
file_path = os.path.expanduser("~/.proxygen/credentials.yaml")
|
|
27
32
|
|
|
28
33
|
if not os.path.exists(file_path):
|
|
29
|
-
with open(file_path,
|
|
34
|
+
with open(file_path, "w"):
|
|
35
|
+
yaml.dump(data, file_path)
|
|
30
36
|
pass
|
|
31
37
|
|
|
32
38
|
|
|
@@ -113,6 +119,8 @@ class Credentials(BaseSettings):
|
|
|
113
119
|
|
|
114
120
|
|
|
115
121
|
_CREDENTIALS = None
|
|
122
|
+
|
|
123
|
+
|
|
116
124
|
def initialise_credentials():
|
|
117
125
|
global _CREDENTIALS
|
|
118
126
|
try:
|
|
@@ -2,12 +2,14 @@ from unittest.mock import patch
|
|
|
2
2
|
|
|
3
3
|
import yaml
|
|
4
4
|
import pytest
|
|
5
|
+
import os
|
|
5
6
|
from click.testing import CliRunner
|
|
6
7
|
from pydantic.error_wrappers import ValidationError
|
|
7
8
|
|
|
8
9
|
import proxygen_cli.cli.command_credentials as cmd_credentials
|
|
9
10
|
from proxygen_cli.lib.credentials import Credentials
|
|
10
|
-
|
|
11
|
+
CLIENT_ID = os.environ["proxygen_client_id"]
|
|
12
|
+
CLIENT_SECRET = os.environ["proxygen_client_secret"]
|
|
11
13
|
|
|
12
14
|
def get_test_credentials(**kwargs):
|
|
13
15
|
base_credentials = {
|
|
@@ -26,6 +28,119 @@ def get_test_credentials(**kwargs):
|
|
|
26
28
|
|
|
27
29
|
return "\n".join(text_format_credentials)
|
|
28
30
|
|
|
31
|
+
#get mock values for credentials.yaml file
|
|
32
|
+
def get_test_proxygen_client_credentials(**kwargs):
|
|
33
|
+
client_credentials = {
|
|
34
|
+
"base_url": "https://mock-keycloak-url.nhs.uk",
|
|
35
|
+
"client_id": CLIENT_ID,
|
|
36
|
+
"client_secret": CLIENT_SECRET,
|
|
37
|
+
"password": "mock-password",
|
|
38
|
+
"username": "mock-user",
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
updated_credentials = client_credentials | kwargs
|
|
42
|
+
|
|
43
|
+
text_format_credentials = [
|
|
44
|
+
f"{key}: {value}" for key, value in updated_credentials.items()
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
return "\n".join(text_format_credentials)
|
|
48
|
+
|
|
49
|
+
#set username and password must be successful
|
|
50
|
+
def test_set_proxygen_user_credential(patch_config, credentials_file):
|
|
51
|
+
mock_credentials = get_test_proxygen_client_credentials()
|
|
52
|
+
|
|
53
|
+
with patch_config(credentials=mock_credentials):
|
|
54
|
+
runner = CliRunner()
|
|
55
|
+
runner.invoke(cmd_credentials.set, ["username", "new-username"] )
|
|
56
|
+
|
|
57
|
+
expected_credentials = "\n".join(
|
|
58
|
+
[
|
|
59
|
+
"base_url: https://mock-keycloak-url.nhs.uk",
|
|
60
|
+
"client_id: "+CLIENT_ID,
|
|
61
|
+
"client_secret: "+CLIENT_SECRET,
|
|
62
|
+
"password: mock-password",
|
|
63
|
+
"username: new-username",
|
|
64
|
+
]
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Check the file has been written to
|
|
68
|
+
assert credentials_file() == expected_credentials
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
#overwrite username and password must be successful, with client id and secret values unmodified
|
|
72
|
+
def test_update_proxygen_user_credentials(patch_config, credentials_file):
|
|
73
|
+
mock_credentials = get_test_proxygen_client_credentials()
|
|
74
|
+
|
|
75
|
+
# Convert mock_credentials to a dictionary
|
|
76
|
+
mock_credentials_dict = yaml.safe_load(mock_credentials)
|
|
77
|
+
|
|
78
|
+
# Set an initial value for the username and password field
|
|
79
|
+
initial_username = "old-username"
|
|
80
|
+
mock_credentials_dict["username"] = initial_username
|
|
81
|
+
|
|
82
|
+
initial_password = "old-password"
|
|
83
|
+
mock_credentials_dict["password"] = initial_password
|
|
84
|
+
|
|
85
|
+
with patch_config(credentials=mock_credentials):
|
|
86
|
+
runner = CliRunner()
|
|
87
|
+
runner.invoke(cmd_credentials.set, ["username", "new-username123"])
|
|
88
|
+
runner.invoke(cmd_credentials.set, ["password", "new-password123"])
|
|
89
|
+
|
|
90
|
+
expected_credentials = "\n".join(
|
|
91
|
+
[
|
|
92
|
+
"base_url: https://mock-keycloak-url.nhs.uk",
|
|
93
|
+
"client_id: "+CLIENT_ID,
|
|
94
|
+
"client_secret: "+CLIENT_SECRET,
|
|
95
|
+
"password: new-password123",
|
|
96
|
+
"username: new-username123",
|
|
97
|
+
]
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Check the file has been written to
|
|
101
|
+
assert credentials_file() == expected_credentials
|
|
102
|
+
|
|
103
|
+
#overwrite client id and secret must be successful
|
|
104
|
+
def test_update_proxygen_client_credentials(patch_config, credentials_file):
|
|
105
|
+
mock_credentials = get_test_proxygen_client_credentials()
|
|
106
|
+
|
|
107
|
+
# Convert mock_credentials to a dictionary
|
|
108
|
+
mock_credentials_dict = yaml.safe_load(mock_credentials)
|
|
109
|
+
print("HELLO")
|
|
110
|
+
print(mock_credentials_dict)
|
|
111
|
+
# Set an initial value for the username and password field
|
|
112
|
+
initial_clientid = "old-clientid"
|
|
113
|
+
mock_credentials_dict["username"] = initial_clientid
|
|
114
|
+
|
|
115
|
+
initial_clientsecret = "old-clientsecret"
|
|
116
|
+
mock_credentials_dict["password"] = initial_clientsecret
|
|
117
|
+
|
|
118
|
+
with patch_config(credentials=mock_credentials):
|
|
119
|
+
runner = CliRunner()
|
|
120
|
+
runner.invoke(cmd_credentials.set, ["client_id", "new-clientid123"])
|
|
121
|
+
runner.invoke(cmd_credentials.set, ["client_secret", "new-clientsecret123"])
|
|
122
|
+
|
|
123
|
+
expected_credentials = "\n".join(
|
|
124
|
+
[
|
|
125
|
+
"base_url: https://mock-keycloak-url.nhs.uk",
|
|
126
|
+
"client_id: new-clientid123",
|
|
127
|
+
"client_secret: new-clientsecret123",
|
|
128
|
+
"password: mock-password",
|
|
129
|
+
"username: mock-user",
|
|
130
|
+
]
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Check the file has been written to
|
|
134
|
+
assert credentials_file() == expected_credentials
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
#verify error for missing proxygen username and password
|
|
138
|
+
def test_missing_proxygen_user_credentials(update_config):
|
|
139
|
+
mock_credentials = get_test_proxygen_client_credentials(username="",password="")
|
|
140
|
+
update_config(credentials=mock_credentials)
|
|
141
|
+
|
|
142
|
+
with pytest.raises(ValidationError):
|
|
143
|
+
Credentials()
|
|
29
144
|
|
|
30
145
|
def test_missing_credentials(update_config):
|
|
31
146
|
mock_credentials = get_test_credentials(username="")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{proxygen_cli-2.1.7 → proxygen_cli-2.1.9}/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
|
|
File without changes
|
|
File without changes
|