Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Vault generated keys #638

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 47 additions & 17 deletions packages/pangea-sdk/tests/integration/test_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,53 @@ def setUp(self) -> None:
self.vault = Vault(self.token, config=self.config, logger_name="vault")
logger_set_pangea_config("vault")

@classmethod
def tearDownClass(cls) -> None:
import time

token = get_test_token(TEST_ENVIRONMENT)
domain = get_test_domain(TEST_ENVIRONMENT)
config = PangeaConfig(domain=domain, custom_user_agent="sdk-test")
vault = Vault(token, config=config, logger_name="vault")

last = None
count = 0
start = time.time()
list_call_count = 0
while count < 1000:
list_resp = vault.list(
filter={
"name__contains": ACTOR,
},
last=last,
)
list_call_count += 1
print(f"List call count: {list_call_count}")
assert list_resp.result

for i in list_resp.result.items:
try:
if (
i.id is not None and i.type != "folder" and i.folder != "/service-tokens/"
): # Skip service token deletion
del_resp = vault.delete(i.id)
count += 1
assert del_resp.result
assert i.id == del_resp.result.id
except pe.PangeaAPIException as e:
print(i)
print(e)

if len(list_resp.result.items) == 0:
print(f"Deleted {count} items")
break

last = list_resp.result.last

end = time.time()
print(f"Deleted {count} items in {end - start} seconds")
print(f"Average delete time: {(end - start) * 1000 / count} ms per item")

def encrypting_cycle(
self, id: str, *, key_type: Literal[ItemType.ASYMMETRIC_KEY, ItemType.SYMMETRIC_KEY] = ItemType.ASYMMETRIC_KEY
) -> None:
Expand Down Expand Up @@ -753,23 +800,6 @@ def test_jwt_sym_life_cycle(self) -> None:
finally:
self.vault.delete(item_id=key_id)

def test_list(self) -> None:
list_resp = self.vault.list()
assert list_resp.result
self.assertGreater(len(list_resp.result.items), 0)
Comment on lines -756 to -759
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to continue testing Vault's list endpoint, though? I know it's called in the new teardown, but I still feel like it deserves its own tests with assertions (ever if only this assertGreater(len(list_resp.result.items), 0) one).


for i in list_resp.result.items:
try:
if (
i.id is not None and i.type != "folder" and i.folder != "/service-tokens/"
): # Skip service token deletion
del_resp = self.vault.delete(i.id)
assert del_resp.result
self.assertEqual(i.id, del_resp.result.id)
except pe.PangeaAPIException as e:
print(i)
print(e)

def test_folders(self) -> None:
FOLDER_PARENT = f"test_parent_folder_{TIME}/"
FOLDER_NAME = "test_folder_name"
Expand Down