wcp-library 1.3.4__py3-none-any.whl → 1.3.5__py3-none-any.whl

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.
@@ -38,6 +38,8 @@ class AsyncCredentialManager(ABC):
38
38
  for field in password['GenericFieldInfo']:
39
39
  password_info[field['DisplayName']] = field['Value'].lower() if field['DisplayName'].lower() == 'username' else field['Value']
40
40
  password_dict[password['UserName'].lower()] = password_info
41
+ if password['OTP']:
42
+ password_dict[password['UserName'].lower()]['OTP'] = password['OTP']
41
43
  logger.debug("Credentials retrieved")
42
44
  return password_dict
43
45
 
@@ -99,14 +101,24 @@ class AsyncCredentialManager(ABC):
99
101
  logger.debug(f"Credentials for {username} retrieved")
100
102
  return return_credential
101
103
 
104
+ async def get_credential_by_id(self, password_id: int) -> dict:
105
+ """
106
+ Get the credentials for a specific Password ID
107
+
108
+ :param password_id:
109
+ :return:
110
+ """
111
+
112
+ logger.debug(f"Getting credentials for ID {password_id}")
113
+ credential = await self._get_credential(password_id)
114
+ logger.debug(f"Credentials for ID {password_id} retrieved")
115
+ return credential
116
+
102
117
  async def update_credential(self, credentials_dict: dict) -> bool:
103
118
  """
104
119
  Update username and password in PasswordState
105
120
 
106
- Credentials dictionary must have the following keys:
107
- - PasswordID
108
- - UserName
109
- - Password
121
+ Credentials dictionary must the same keys as the original dictionary from the get_credentials method
110
122
 
111
123
  The dictionary can be obtained from the get_credentials method
112
124
 
@@ -114,6 +126,9 @@ class AsyncCredentialManager(ABC):
114
126
  :return:
115
127
  """
116
128
 
129
+ if "OTP" in credentials_dict:
130
+ credentials_dict.pop("OTP")
131
+
117
132
  logger.debug(f"Updating credentials for {credentials_dict['UserName']}")
118
133
  url = (self.password_url / str(self._password_list_id)).with_query("QueryAll")
119
134
  async with aiohttp.ClientSession() as session:
@@ -36,6 +36,8 @@ class CredentialManager(ABC):
36
36
  for field in password['GenericFieldInfo']:
37
37
  password_info[field['DisplayName']] = field['Value'].lower() if field['DisplayName'].lower() == 'username' else field['Value']
38
38
  password_dict[password['UserName'].lower()] = password_info
39
+ if password['OTP']:
40
+ password_dict[password['UserName'].lower()]['OTP'] = password['OTP']
39
41
  logger.debug("Credentials retrieved")
40
42
  return password_dict
41
43
 
@@ -110,10 +112,7 @@ class CredentialManager(ABC):
110
112
  """
111
113
  Update the credentials for a specific username
112
114
 
113
- Credentials dictionary must have the following keys:
114
- - PasswordID
115
- - UserName
116
- - Password
115
+ Credentials dictionary must the same keys as the original dictionary from the get_credentials method
117
116
 
118
117
  The dictionary should be obtained from the get_credentials method and modified accordingly
119
118
 
@@ -121,6 +120,9 @@ class CredentialManager(ABC):
121
120
  :return: True if successful, False otherwise
122
121
  """
123
122
 
123
+ if "OTP" in credentials_dict:
124
+ credentials_dict.pop("OTP")
125
+
124
126
  logger.debug(f"Updating credentials for {credentials_dict['UserName']}")
125
127
  url = (self.password_url / str(self._password_list_id)).with_query("QueryAll")
126
128
  passwords = requests.get(str(url), headers=self.headers).json()
@@ -0,0 +1,74 @@
1
+ import logging
2
+
3
+ from wcp_library.credentials._credential_manager_asynchronous import AsyncCredentialManager
4
+ from wcp_library.credentials._credential_manager_synchronous import CredentialManager
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+
9
+ class APICredentialManager(CredentialManager):
10
+ def __init__(self, passwordState_api_key: str):
11
+ super().__init__(passwordState_api_key, 214)
12
+
13
+ def new_credentials(self, credentials_dict: dict) -> bool:
14
+ """
15
+ Create a new credential entry
16
+
17
+ Credentials dictionary can have the following keys:
18
+ - Title
19
+ - UserName
20
+ - Password
21
+ - API KEY
22
+ - Authentication Header
23
+ - URL
24
+
25
+ :param credentials_dict:
26
+ :return: True if successful, False otherwise
27
+ """
28
+
29
+ data = {
30
+ "PasswordListID": self._password_list_id,
31
+ "Title": credentials_dict['UserName'].upper() if "Title" not in credentials_dict else credentials_dict['Title'].upper(),
32
+ "Notes": credentials_dict['Notes'] if 'Notes' in credentials_dict else None,
33
+ "UserName": credentials_dict['UserName'],
34
+ "Password": credentials_dict['Password'],
35
+ "GenericField1": credentials_dict['API KEY'],
36
+ "GenericField2": credentials_dict['Authentication Header'],
37
+ "URL": credentials_dict['URL']
38
+ }
39
+
40
+ return self._publish_new_password(data)
41
+
42
+
43
+ class AsyncAPICredentialManager(AsyncCredentialManager):
44
+ def __init__(self, passwordState_api_key: str):
45
+ super().__init__(passwordState_api_key, 214)
46
+
47
+ async def new_credentials(self, credentials_dict: dict) -> bool:
48
+ """
49
+ Create a new credential entry
50
+
51
+ Credentials dictionary can have the following keys:
52
+ - Title
53
+ - UserName
54
+ - Password
55
+ - API KEY
56
+ - Authentication Header
57
+ - URL
58
+
59
+ :param credentials_dict:
60
+ :return:
61
+ """
62
+
63
+ data = {
64
+ "PasswordListID": self._password_list_id,
65
+ "Title": credentials_dict['UserName'].upper() if "Title" not in credentials_dict else credentials_dict['Title'].upper(),
66
+ "Notes": credentials_dict['Notes'] if 'Notes' in credentials_dict else None,
67
+ "UserName": credentials_dict['UserName'],
68
+ "Password": credentials_dict['Password'],
69
+ "GenericField1": credentials_dict['API KEY'],
70
+ "GenericField2": credentials_dict['Authentication Header'],
71
+ "URL": credentials_dict['URL']
72
+ }
73
+
74
+ return await self._publish_new_password(data)
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
- from wcp_library.credentials.credential_manager_asynchronous import AsyncCredentialManager
4
- from wcp_library.credentials.credential_manager_synchronous import CredentialManager
3
+ from wcp_library.credentials._credential_manager_asynchronous import AsyncCredentialManager
4
+ from wcp_library.credentials._credential_manager_synchronous import CredentialManager
5
5
 
6
6
  logger = logging.getLogger(__name__)
7
7
 
@@ -0,0 +1,66 @@
1
+ import logging
2
+
3
+ from wcp_library.credentials._credential_manager_asynchronous import AsyncCredentialManager
4
+ from wcp_library.credentials._credential_manager_synchronous import CredentialManager
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+
9
+ class InternetCredentialManager(CredentialManager):
10
+ def __init__(self, passwordState_api_key: str):
11
+ super().__init__(passwordState_api_key, 93)
12
+
13
+ def new_credentials(self, credentials_dict: dict) -> bool:
14
+ """
15
+ Create a new credential entry
16
+
17
+ Credentials dictionary must have the following keys:
18
+ - Title
19
+ - UserName
20
+ - Password
21
+ - URL
22
+
23
+ :param credentials_dict:
24
+ :return:
25
+ """
26
+
27
+ data = {
28
+ "PasswordListID": self._password_list_id,
29
+ "Title": credentials_dict['UserName'].upper() if "Title" not in credentials_dict else credentials_dict['Title'].upper(),
30
+ "Notes": credentials_dict['Notes'] if 'Notes' in credentials_dict else None,
31
+ "UserName": credentials_dict['UserName'].lower(),
32
+ "Password": credentials_dict['Password'],
33
+ "URL": credentials_dict['URL']
34
+ }
35
+
36
+ return self._publish_new_password(data)
37
+
38
+
39
+ class AsyncInternetCredentialManager(AsyncCredentialManager):
40
+ def __init__(self, passwordState_api_key: str):
41
+ super().__init__(passwordState_api_key, 93)
42
+
43
+ async def new_credentials(self, credentials_dict: dict) -> bool:
44
+ """
45
+ Create a new credential entry
46
+
47
+ Credentials dictionary must have the following keys:
48
+ - Title
49
+ - UserName
50
+ - Password
51
+ - URL
52
+
53
+ :param credentials_dict:
54
+ :return:
55
+ """
56
+
57
+ data = {
58
+ "PasswordListID": self._password_list_id,
59
+ "Title": credentials_dict['UserName'].upper() if "Title" not in credentials_dict else credentials_dict['Title'].upper(),
60
+ "Notes": credentials_dict['Notes'] if 'Notes' in credentials_dict else None,
61
+ "UserName": credentials_dict['UserName'].lower(),
62
+ "Password": credentials_dict['Password'],
63
+ "URL": credentials_dict['URL']
64
+ }
65
+
66
+ return await self._publish_new_password(data)
@@ -2,8 +2,8 @@ import logging
2
2
 
3
3
  import aiohttp
4
4
 
5
- from wcp_library.credentials.credential_manager_asynchronous import AsyncCredentialManager
6
- from wcp_library.credentials.credential_manager_synchronous import CredentialManager
5
+ from wcp_library.credentials._credential_manager_asynchronous import AsyncCredentialManager
6
+ from wcp_library.credentials._credential_manager_synchronous import CredentialManager
7
7
 
8
8
  logger = logging.getLogger(__name__)
9
9
 
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
- from wcp_library.credentials.credential_manager_asynchronous import AsyncCredentialManager
4
- from wcp_library.credentials.credential_manager_synchronous import CredentialManager
3
+ from wcp_library.credentials._credential_manager_asynchronous import AsyncCredentialManager
4
+ from wcp_library.credentials._credential_manager_synchronous import CredentialManager
5
5
 
6
6
  logger = logging.getLogger(__name__)
7
7
 
@@ -75,3 +75,14 @@ class SeleniumHelper:
75
75
  """
76
76
 
77
77
  WebDriverWait(self.driver, timeout).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, css_element)))
78
+
79
+ def wait_until_clickable(self, css_element: str, timeout: int = 30) -> None:
80
+ """
81
+ Wait until an element is clickable
82
+
83
+ :param css_element:
84
+ :param timeout:
85
+ :return:
86
+ """
87
+
88
+ WebDriverWait(self.driver, timeout).until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, css_element)))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.3.4
3
+ Version: 1.3.5
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Home-page: https://github.com/Whitecap-DNA/WCP-Library
6
6
  Author: Mitch-Petersen
@@ -1,21 +1,23 @@
1
1
  wcp_library/__init__.py,sha256=hwLbcu00uI6L_xjXO9-I0YcODl2WtIOkdNLoDcXv7zk,591
2
2
  wcp_library/credentials/__init__.py,sha256=HRmg7mqcATeclIz3lZQjSR4nmK6aY6MK9-QXEYZoFrw,1857
3
- wcp_library/credentials/credential_manager_asynchronous.py,sha256=avAvolbtE1qPTTaUas_fMX7Oj_fiBUMutAFztRDDKJI,5722
4
- wcp_library/credentials/credential_manager_synchronous.py,sha256=ouPNLt20FvocuMoFx49mbDL7-Moj_WrlpR7k97mx-i4,5512
5
- wcp_library/credentials/ftp.py,sha256=O4oSPtCCv_0w6sLITFnY9EpN6-K2XxeibbGB0VnTHJ4,2589
6
- wcp_library/credentials/oracle.py,sha256=m0WtmSyUdKUfsz1SPkRgc7A080rK6cq7jVoQ0YcWJ50,2867
7
- wcp_library/credentials/postgres.py,sha256=tCCWdc10lgdu6zbU-Hv0ZxGw9rn6ZvDvFkMZqm9qfBo,2571
3
+ wcp_library/credentials/_credential_manager_asynchronous.py,sha256=XLYZ6XjLU3Cp18cin3BidIBPvjoqqdJ5L7hhueMCfpU,6311
4
+ wcp_library/credentials/_credential_manager_synchronous.py,sha256=5QyIYYPM2HUlApdZl6ELypuuCioi6Z-JHwyJWFrwYBs,5685
5
+ wcp_library/credentials/api.py,sha256=NZfZcN46-ZVB_-DatR0DLBYAtJxulDlKD2cculzbyXo,2625
6
+ wcp_library/credentials/ftp.py,sha256=lSjOlfU68j9PsOCaoWJSdjbR1QmjTxjVmSxOpMdMG7Q,2591
7
+ wcp_library/credentials/internet.py,sha256=z9tihFddTJcX2pt-iHFP_rkCoheLhTdFgn4ksc2sYYE,2239
8
+ wcp_library/credentials/oracle.py,sha256=OV02op95LNUT21cNDM4zDbD63C1ldiq--vYofDpU-zU,2869
9
+ wcp_library/credentials/postgres.py,sha256=B5qNPKYzuzOJZ5S4M3MCN4xUelvZ6AgyR6QJc4z0Cgo,2573
8
10
  wcp_library/emailing.py,sha256=xqNly6Tmj-pvwl5bdys3gauZFDd4SuWCQYzGFNemv2Q,2496
9
11
  wcp_library/ftp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
12
  wcp_library/ftp/ftp.py,sha256=EpyW0J2QIGxP8zVGD4VarA0hi4C2XAPDPF-0j2sRdpI,4350
11
13
  wcp_library/ftp/sftp.py,sha256=hykXGLGdxe7DYAxFdTwjPjTEOYuIpSMyK3NOiTQNUK0,4176
12
14
  wcp_library/informatica.py,sha256=_g9lzSd-JLsY4e5_g6YcxQtOxP6fkg4sGfvNJaAN7jY,8123
13
15
  wcp_library/logging.py,sha256=e6gG7HFgUrMajUZs4Gs0atFfOJJmdmxN0GerfynNWlY,2061
14
- wcp_library/selenium_helper.py,sha256=rlphTXsUgnbaXZknY5nfQqxFhnc7UmrpzhV3hQ-cv7k,2509
16
+ wcp_library/selenium_helper.py,sha256=2PENUH8bgpyzovbLjP8a4Oyd7c3yOwoyQJt-a8-zq0c,2855
15
17
  wcp_library/sql/__init__.py,sha256=s2psmwkq_ZU23iGWvXjJrLu0hD1fB6CDv6RHcK7y828,1917
16
18
  wcp_library/sql/oracle.py,sha256=TGiTC5L5UcM5QcHFajgn43NI8HygOGIEAtLmLbVFp2I,15772
17
19
  wcp_library/sql/postgres.py,sha256=GElSjLDworrRlzA7DLrbcQlW7BqvhgMbvW89v-yZejk,14533
18
20
  wcp_library/time.py,sha256=ktSzhK7SZnGPNXobFexnhFGQAcriLCJQKxnO0fed8fQ,1740
19
- wcp_library-1.3.4.dist-info/METADATA,sha256=-3zbu2jB2faCUbBvOLm0I3ikaxEOYbNaxlNaGJY0tUU,1552
20
- wcp_library-1.3.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
21
- wcp_library-1.3.4.dist-info/RECORD,,
21
+ wcp_library-1.3.5.dist-info/METADATA,sha256=hnu1wsVA8QLeWwq7wFNuYu_eZH3R3CqCot1_NWQ4D60,1552
22
+ wcp_library-1.3.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
23
+ wcp_library-1.3.5.dist-info/RECORD,,