get-hc-secrets 1.5.7__tar.gz → 1.5.8__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.
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/PKG-INFO +1 -1
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/pyproject.toml +1 -1
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/getSecrets/__init__.py +23 -5
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/PKG-INFO +1 -1
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/SOURCES.txt +2 -1
- get_hc_secrets-1.5.8/tests/test_getsecrets.py +24 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/LICENSE +0 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/README.md +0 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/setup.cfg +0 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/dependency_links.txt +0 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/requires.txt +0 -0
- {get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/top_level.txt +0 -0
|
@@ -3,13 +3,28 @@ from os import getenv
|
|
|
3
3
|
from os.path import join
|
|
4
4
|
import requests
|
|
5
5
|
import yaml
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
6
9
|
|
|
7
|
-
_config_file = "~/.config/.vault/vault.yml"
|
|
8
|
-
_home = getenv("HOME")
|
|
9
|
-
_config = yaml.safe_load(open(join(_home, _config_file.replace("~/", ''))))
|
|
10
10
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s',
|
|
11
11
|
datefmt='%m/%d/%Y %I:%M:%S %p')
|
|
12
12
|
|
|
13
|
+
_config_file = "~/.config/.vault/vault.yml"
|
|
14
|
+
_home = getenv("HOME")
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
_config = yaml.safe_load(open(join(_home, _config_file.replace("~/", ''))))
|
|
18
|
+
except FileNotFoundError:
|
|
19
|
+
if not os.path.exists("/etc/vault"):
|
|
20
|
+
os.makedirs("/etc/vault")
|
|
21
|
+
_home = "/etc/vault"
|
|
22
|
+
try:
|
|
23
|
+
_config = yaml.safe_load(open(join(_home, 'vault.yaml')))
|
|
24
|
+
except FileNotFoundError:
|
|
25
|
+
logging.error(f"No vault configuration found in {_home}")
|
|
26
|
+
sys.exit(1)
|
|
27
|
+
|
|
13
28
|
|
|
14
29
|
def get_secret(id: str, repo: str = 'secret') -> dict:
|
|
15
30
|
"""
|
|
@@ -24,9 +39,12 @@ def get_secret(id: str, repo: str = 'secret') -> dict:
|
|
|
24
39
|
"""
|
|
25
40
|
|
|
26
41
|
base_url = _config['vault']['vault_addr']
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
if _home == '/etc/vault':
|
|
43
|
+
certs = '/etc/vault/bundle.pem'
|
|
44
|
+
else:
|
|
45
|
+
certs = join(_home, _config['vault']['certs'].replace("~/", ''))
|
|
29
46
|
|
|
47
|
+
token = _config['vault']['token']
|
|
30
48
|
headers = {"X-Vault-Token": token}
|
|
31
49
|
uri = f"/v1/{repo}/data/"
|
|
32
50
|
url = f"{base_url}{uri}{id}"
|
|
@@ -6,4 +6,5 @@ src/get_hc_secrets.egg-info/PKG-INFO
|
|
|
6
6
|
src/get_hc_secrets.egg-info/SOURCES.txt
|
|
7
7
|
src/get_hc_secrets.egg-info/dependency_links.txt
|
|
8
8
|
src/get_hc_secrets.egg-info/requires.txt
|
|
9
|
-
src/get_hc_secrets.egg-info/top_level.txt
|
|
9
|
+
src/get_hc_secrets.egg-info/top_level.txt
|
|
10
|
+
tests/test_getsecrets.py
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import secrets
|
|
2
|
+
import unittest
|
|
3
|
+
import getSecrets as gs
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestGetSecrets(unittest.TestCase):
|
|
7
|
+
|
|
8
|
+
def test_listsecret(self):
|
|
9
|
+
secrets = gs.list_secret()
|
|
10
|
+
self.assertTrue('test' in secrets)
|
|
11
|
+
|
|
12
|
+
def test_getsecrets(self):
|
|
13
|
+
secret = gs.get_secret('test')
|
|
14
|
+
self.assertTrue('test' in secret)
|
|
15
|
+
self.assertEqual(secret['test'], 'test')
|
|
16
|
+
|
|
17
|
+
def test_usr_pwd(self):
|
|
18
|
+
usr, pwd = gs.get_user_pwd('test')
|
|
19
|
+
self.assertEqual(usr, 'test')
|
|
20
|
+
self.assertEqual(pwd, 'test')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == '__main__':
|
|
24
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{get_hc_secrets-1.5.7 → get_hc_secrets-1.5.8}/src/get_hc_secrets.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|