wcp-library 1.3.4__tar.gz → 1.3.6__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 (23) hide show
  1. {wcp_library-1.3.4 → wcp_library-1.3.6}/PKG-INFO +1 -1
  2. {wcp_library-1.3.4 → wcp_library-1.3.6}/pyproject.toml +1 -1
  3. wcp_library-1.3.4/wcp_library/credentials/credential_manager_asynchronous.py → wcp_library-1.3.6/wcp_library/credentials/_credential_manager_asynchronous.py +21 -4
  4. wcp_library-1.3.4/wcp_library/credentials/credential_manager_synchronous.py → wcp_library-1.3.6/wcp_library/credentials/_credential_manager_synchronous.py +8 -4
  5. wcp_library-1.3.6/wcp_library/credentials/api.py +74 -0
  6. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/credentials/ftp.py +2 -2
  7. wcp_library-1.3.6/wcp_library/credentials/internet.py +66 -0
  8. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/credentials/oracle.py +2 -2
  9. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/credentials/postgres.py +2 -2
  10. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/selenium_helper.py +11 -0
  11. {wcp_library-1.3.4 → wcp_library-1.3.6}/README.md +0 -0
  12. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/__init__.py +0 -0
  13. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/credentials/__init__.py +0 -0
  14. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/emailing.py +0 -0
  15. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/ftp/__init__.py +0 -0
  16. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/ftp/ftp.py +0 -0
  17. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/ftp/sftp.py +0 -0
  18. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/informatica.py +0 -0
  19. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/logging.py +0 -0
  20. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/sql/__init__.py +0 -0
  21. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/sql/oracle.py +0 -0
  22. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/sql/postgres.py +0 -0
  23. {wcp_library-1.3.4 → wcp_library-1.3.6}/wcp_library/time.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.3.4
3
+ Version: 1.3.6
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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wcp-library"
3
- version = "1.3.4"
3
+ version = "1.3.6"
4
4
  description = "Common utilites for internal development at WCP"
5
5
  authors = ["Mitch-Petersen <mitch.petersen@wcap.ca>"]
6
6
  readme = "README.md"
@@ -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
 
@@ -62,6 +64,8 @@ class AsyncCredentialManager(ABC):
62
64
  password_info = {'PasswordID': password['PasswordID'], 'UserName': password['UserName'], 'Password': password['Password']}
63
65
  for field in password['GenericFieldInfo']:
64
66
  password_info[field['DisplayName']] = field['Value'].lower() if field['DisplayName'].lower() == 'username' else field['Value']
67
+ if password['OTP']:
68
+ password_info['OTP'] = password['OTP']
65
69
  return password_info
66
70
 
67
71
  async def _publish_new_password(self, data: dict) -> bool:
@@ -99,14 +103,24 @@ class AsyncCredentialManager(ABC):
99
103
  logger.debug(f"Credentials for {username} retrieved")
100
104
  return return_credential
101
105
 
106
+ async def get_credential_by_id(self, password_id: int) -> dict:
107
+ """
108
+ Get the credentials for a specific Password ID
109
+
110
+ :param password_id:
111
+ :return:
112
+ """
113
+
114
+ logger.debug(f"Getting credentials for ID {password_id}")
115
+ credential = await self._get_credential(password_id)
116
+ logger.debug(f"Credentials for ID {password_id} retrieved")
117
+ return credential
118
+
102
119
  async def update_credential(self, credentials_dict: dict) -> bool:
103
120
  """
104
121
  Update username and password in PasswordState
105
122
 
106
- Credentials dictionary must have the following keys:
107
- - PasswordID
108
- - UserName
109
- - Password
123
+ Credentials dictionary must the same keys as the original dictionary from the get_credentials method
110
124
 
111
125
  The dictionary can be obtained from the get_credentials method
112
126
 
@@ -114,6 +128,9 @@ class AsyncCredentialManager(ABC):
114
128
  :return:
115
129
  """
116
130
 
131
+ if "OTP" in credentials_dict:
132
+ credentials_dict.pop("OTP")
133
+
117
134
  logger.debug(f"Updating credentials for {credentials_dict['UserName']}")
118
135
  url = (self.password_url / str(self._password_list_id)).with_query("QueryAll")
119
136
  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
 
@@ -58,6 +60,8 @@ class CredentialManager(ABC):
58
60
  password_info = {'PasswordID': password['PasswordID'], 'UserName': password['UserName'], 'Password': password['Password']}
59
61
  for field in password['GenericFieldInfo']:
60
62
  password_info[field['DisplayName']] = field['Value'].lower() if field['DisplayName'].lower() == 'username' else field['Value']
63
+ if password['OTP']:
64
+ password_info['OTP'] = password['OTP']
61
65
  logger.debug("Credential retrieved")
62
66
  return password_info
63
67
 
@@ -110,10 +114,7 @@ class CredentialManager(ABC):
110
114
  """
111
115
  Update the credentials for a specific username
112
116
 
113
- Credentials dictionary must have the following keys:
114
- - PasswordID
115
- - UserName
116
- - Password
117
+ Credentials dictionary must the same keys as the original dictionary from the get_credentials method
117
118
 
118
119
  The dictionary should be obtained from the get_credentials method and modified accordingly
119
120
 
@@ -121,6 +122,9 @@ class CredentialManager(ABC):
121
122
  :return: True if successful, False otherwise
122
123
  """
123
124
 
125
+ if "OTP" in credentials_dict:
126
+ credentials_dict.pop("OTP")
127
+
124
128
  logger.debug(f"Updating credentials for {credentials_dict['UserName']}")
125
129
  url = (self.password_url / str(self._password_list_id)).with_query("QueryAll")
126
130
  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)))
File without changes