wcp-library 1.3.4__tar.gz → 1.3.5__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.
- {wcp_library-1.3.4 → wcp_library-1.3.5}/PKG-INFO +1 -1
- {wcp_library-1.3.4 → wcp_library-1.3.5}/pyproject.toml +1 -1
- wcp_library-1.3.4/wcp_library/credentials/credential_manager_asynchronous.py → wcp_library-1.3.5/wcp_library/credentials/_credential_manager_asynchronous.py +19 -4
- wcp_library-1.3.4/wcp_library/credentials/credential_manager_synchronous.py → wcp_library-1.3.5/wcp_library/credentials/_credential_manager_synchronous.py +6 -4
- wcp_library-1.3.5/wcp_library/credentials/api.py +74 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/credentials/ftp.py +2 -2
- wcp_library-1.3.5/wcp_library/credentials/internet.py +66 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/credentials/oracle.py +2 -2
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/credentials/postgres.py +2 -2
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/selenium_helper.py +11 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/README.md +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/__init__.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/credentials/__init__.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/emailing.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/ftp/__init__.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/ftp/ftp.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/ftp/sftp.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/informatica.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/logging.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/sql/__init__.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/sql/oracle.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/sql/postgres.py +0 -0
- {wcp_library-1.3.4 → wcp_library-1.3.5}/wcp_library/time.py +0 -0
@@ -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
|
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
|
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.
|
4
|
-
from wcp_library.credentials.
|
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.
|
6
|
-
from wcp_library.credentials.
|
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.
|
4
|
-
from wcp_library.credentials.
|
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
|
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
|