Skip to content

Commit 78cd697

Browse files
authored
Merge pull request #17 from cognifloyd/drop-deprecated-hvac-usage
Drop deprecated API usage in HVAC
2 parents 11272ec + 2f3c6b5 commit 78cd697

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

CHANGES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## 0.6.0
4+
5+
WARNING: This is the last version that "supports" python2.7.
6+
The next version will be 1.0.0 and "2" will be dropped from python_versions.
7+
8+
- Add ability to authenticate with approle instead of with token.
9+
- Drop testing with python2.7 due to broken infrastructure.
10+
- Add unit tests for all actions.
11+
- Update minimum required version of hvac to 0.10.6.
12+
- Migrate from deprecated hvac methods to their replacements.
13+
314
## 0.5.2
415

516
- Pass certificate correctly to hvac

actions/delete_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class VaultPolicyDeleteAction(action.VaultBaseAction):
55
def run(self, name):
6-
return self.vault.delete_policy(name)
6+
return self.vault.sys.delete_policy(name)

actions/is_initialized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class VaultIsInitializedAction(action.VaultBaseAction):
55
def run(self):
6-
return self.vault.is_initialized()
6+
return self.vault.sys.is_initialized()

actions/read_kv.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ def run(self, path, kv_version, mount_point, version):
66
value = None
77

88
if kv_version == 1:
9-
value = self.vault.kv.v1.read_secret(path=path, mount_point=mount_point)
9+
value = self.vault.secrets.kv.v1.read_secret(
10+
path=path, mount_point=mount_point
11+
)
1012
elif kv_version == 2:
11-
value = self.vault.kv.v2.read_secret_version(path=path, mount_point=mount_point,
12-
version=version)
13+
value = self.vault.secrets.kv.v2.read_secret_version(
14+
path=path, mount_point=mount_point, version=version
15+
)
1316

1417
if value:
1518
return value['data']

actions/set_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class VaultPolicySetAction(action.VaultBaseAction):
55
def run(self, name, rules):
6-
return self.vault.set_policy(name, rules)
6+
return self.vault.sys.create_or_update_policy(name, rules)

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ref: vault
33
name: vault
44
description: HashiCorp Vault
5-
version: 0.5.2
5+
version: 0.6.0
66
python_versions:
77
- "2"
88
- "3"

tests/test_action_delete_policy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from requests import Response
2+
13
from delete_policy import VaultPolicyDeleteAction
24
from tests.vault_action_tests_base import VaultActionTestCase
35

@@ -12,7 +14,7 @@ def test_method(self):
1214
# test
1315
action = self.get_action_instance(config=self.dummy_pack_config)
1416
action_result = action.run(name="stanley")
15-
self.assertIsNone(action_result)
17+
self.assertIsInstance(action_result, Response)
1618

1719
result = self.client.get_policy("stanley")
1820
self.assertIsNone(result)

tests/test_action_set_policy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from requests import Response
2+
13
from set_policy import VaultPolicySetAction
24
from tests.vault_action_tests_base import VaultActionTestCase
35

@@ -18,7 +20,7 @@ def test_method(self):
1820
name="stanley",
1921
rules=rules_text,
2022
)
21-
self.assertIsNone(action_result)
23+
self.assertIsInstance(action_result, Response)
2224

2325
result = self.client.get_policy("stanley")
2426
self.assertEqual(result, rules_text)

0 commit comments

Comments
 (0)