proxygen-cli 2.1.9__tar.gz → 2.1.10__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.
Files changed (36) hide show
  1. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/PKG-INFO +6 -6
  2. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/README.md +5 -5
  3. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_credentials.py +8 -4
  4. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/credentials.py +1 -9
  5. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_credentials_test.py +1 -116
  6. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/pyproject.toml +1 -1
  7. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/__init__.py +0 -0
  8. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_docker.py +0 -0
  9. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_instance.py +0 -0
  10. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_main.py +0 -0
  11. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_pytest_nhsd_apim_token.py +0 -0
  12. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_secret.py +0 -0
  13. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_settings.py +0 -0
  14. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/cli/command_spec.py +0 -0
  15. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/auth.py +0 -0
  16. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/constants.py +0 -0
  17. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/dot_proxygen.py +0 -0
  18. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/output.py +0 -0
  19. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/proxygen_api.py +0 -0
  20. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/settings.py +0 -0
  21. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/spec.py +0 -0
  22. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/spec_server.py +0 -0
  23. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/lib/version.py +0 -0
  24. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/__init__.py +0 -0
  25. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_instance_test.py +0 -0
  26. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_main_test.py +0 -0
  27. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_pytest_nhsd_apim_token_test.py +0 -0
  28. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_secret_test.py +0 -0
  29. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_settings_test.py +0 -0
  30. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/command_spec_test.py +0 -0
  31. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/conftest.py +0 -0
  32. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/fixtures/client.key +0 -0
  33. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/fixtures/client.pem +0 -0
  34. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/fixtures/secret.txt +0 -0
  35. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/proxygen_cli/test/mock_private_key.py +0 -0
  36. {proxygen_cli-2.1.9 → proxygen_cli-2.1.10}/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.9
3
+ Version: 2.1.10
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 Proxygen CLI client credentials `client_id`, `client_secret` are setup as part of proxygen CLI package.
41
+ The CLI requires client credentials, which can be obtained from the `platforms-api-producer-support` Slack channel.
42
42
 
43
- All users should have individual credentials. `proxygen-cli` needs to know about them. You can setup your user credentials in proxygen-cli using:
43
+ All users should also have individual credentials. `proxygen-cli` needs to know about them.
44
+ You can setup the credentials in `proxygen-cli` using:
44
45
  ```
45
46
  proxygen credentials set
46
47
  ```
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:
48
+ This command prompts you to enter your `client_id`, `client_secret`, `username`, and `password`.
49
+ To update credentials 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 Proxygen CLI client credentials `client_id`, `client_secret` are setup as part of proxygen CLI package.
16
+ The CLI requires client credentials, which can be obtained from the `platforms-api-producer-support` Slack channel.
17
17
 
18
- All users should have individual credentials. `proxygen-cli` needs to know about them. You can setup your user credentials in proxygen-cli using:
18
+ All users should also have individual credentials. `proxygen-cli` needs to know about them.
19
+ You can setup the credentials in `proxygen-cli` using:
19
20
  ```
20
21
  proxygen credentials set
21
22
  ```
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:
23
+ This command prompts you to enter your `client_id`, `client_secret`, `username`, and `password`.
24
+ To update credentials in the future, use:
25
25
  ```
26
26
  proxygen credentials set <KEY> <VALUE>
27
27
  ```
@@ -2,7 +2,6 @@ import json
2
2
  import click
3
3
  import yaml
4
4
  import pydantic
5
- import os
6
5
 
7
6
  from proxygen_cli.lib import output
8
7
  from proxygen_cli.lib.credentials import (
@@ -11,6 +10,7 @@ from proxygen_cli.lib.dot_proxygen import credentials_file
11
10
 
12
11
  CHOICE_OF_CREDENTIAL_KEYS = click.Choice(Credentials.__fields__.keys())
13
12
 
13
+
14
14
  @click.group()
15
15
  def credentials():
16
16
  """Get/set credentials."""
@@ -55,16 +55,20 @@ def set(custom_pairs, force):
55
55
 
56
56
  current_credentials = _yaml_credentials_file_source(None)
57
57
 
58
- # Check if user credentials are set
58
+ # Check if base credentials are set
59
59
  base_credentials_set = all(
60
60
  current_credentials.get(field) is not None
61
- for field in ["username", "password"]
61
+ for field in ["client_id", "client_secret", "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)
65
67
  username = click.prompt("Enter username", default="", show_default=False)
66
68
  password = click.prompt("Enter password", default="", show_default=False)
67
69
 
70
+ current_credentials["client_id"] = client_id
71
+ current_credentials["client_secret"] = client_secret
68
72
  current_credentials["username"] = username
69
73
  current_credentials["password"] = password
70
74
 
@@ -94,4 +98,4 @@ def rm(key):
94
98
  current_credentials = _yaml_credentials_file_source(None)
95
99
  current_credentials.pop(key, None)
96
100
  with credentials_file().open("w") as f:
97
- yaml.safe_dump(current_credentials, f)
101
+ yaml.safe_dump(current_credentials, f)
@@ -15,11 +15,6 @@ 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
-
23
18
 
24
19
  def _yaml_credentials_file_source(_):
25
20
  with dot_proxygen.credentials_file().open() as yaml_file:
@@ -31,8 +26,7 @@ def create_yaml_credentials_file():
31
26
  file_path = os.path.expanduser("~/.proxygen/credentials.yaml")
32
27
 
33
28
  if not os.path.exists(file_path):
34
- with open(file_path, "w"):
35
- yaml.dump(data, file_path)
29
+ with open(file_path, 'w'):
36
30
  pass
37
31
 
38
32
 
@@ -119,8 +113,6 @@ class Credentials(BaseSettings):
119
113
 
120
114
 
121
115
  _CREDENTIALS = None
122
-
123
-
124
116
  def initialise_credentials():
125
117
  global _CREDENTIALS
126
118
  try:
@@ -2,14 +2,12 @@ from unittest.mock import patch
2
2
 
3
3
  import yaml
4
4
  import pytest
5
- import os
6
5
  from click.testing import CliRunner
7
6
  from pydantic.error_wrappers import ValidationError
8
7
 
9
8
  import proxygen_cli.cli.command_credentials as cmd_credentials
10
9
  from proxygen_cli.lib.credentials import Credentials
11
- CLIENT_ID = os.environ["proxygen_client_id"]
12
- CLIENT_SECRET = os.environ["proxygen_client_secret"]
10
+
13
11
 
14
12
  def get_test_credentials(**kwargs):
15
13
  base_credentials = {
@@ -28,119 +26,6 @@ def get_test_credentials(**kwargs):
28
26
 
29
27
  return "\n".join(text_format_credentials)
30
28
 
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()
144
29
 
145
30
  def test_missing_credentials(update_config):
146
31
  mock_credentials = get_test_credentials(username="")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "proxygen-cli"
3
- version = "2.1.9"
3
+ version = "2.1.10"
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"