Skip to content

Commit bd99a0e

Browse files
committed
e2e testing with encrypted object CRUD
1 parent b300ed3 commit bd99a0e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

workos/vault.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import base64
22
from typing import Optional, Protocol, Sequence, Tuple
3-
from workos.types.vault import VaultObject, ObjectVersion
3+
from workos.types.vault import VaultObject, ObjectVersion, ObjectDigest, ObjectMetadata
44
from workos.types.vault.key import DataKey, DataKeyPair, KeyContext, DecodedKeys
55
from workos.types.list_resource import (
66
ListArgs,
@@ -22,7 +22,7 @@
2222

2323
DEFAULT_RESPONSE_LIMIT = DEFAULT_LIST_RESPONSE_LIMIT
2424

25-
VaultObjectList = WorkOSListResource[VaultObject, ListArgs, ListMetadata]
25+
VaultObjectList = WorkOSListResource[ObjectDigest, ListArgs, ListMetadata]
2626

2727

2828
class VaultModule(Protocol):
@@ -79,7 +79,7 @@ def create_object(
7979
name: str,
8080
value: str,
8181
key_context: KeyContext,
82-
) -> VaultObject:
82+
) -> ObjectMetadata:
8383
"""
8484
Create a new Vault object.
8585
@@ -245,10 +245,14 @@ def list_objects(
245245
params=list_params,
246246
)
247247

248+
# Ensure object field is present
249+
if "object" not in response:
250+
response["object"] = "list"
251+
248252
return VaultObjectList(
249253
list_method=self.list_objects,
250254
list_args=list_params,
251-
**ListPage[VaultObject](**response).model_dump(),
255+
**ListPage[ObjectDigest](**response).model_dump(),
252256
)
253257

254258
def list_object_versions(
@@ -275,7 +279,7 @@ def create_object(
275279
name: str,
276280
value: str,
277281
key_context: KeyContext,
278-
) -> VaultObject:
282+
) -> ObjectMetadata:
279283
if not name or not value:
280284
raise ValueError(
281285
"Incomplete arguments: 'name' and 'value' are required arguments"
@@ -284,7 +288,7 @@ def create_object(
284288
request_data = {
285289
"name": name,
286290
"value": value,
287-
"context": key_context,
291+
"key_context": key_context,
288292
}
289293

290294
response = self._http_client.request(
@@ -293,7 +297,7 @@ def create_object(
293297
json=request_data,
294298
)
295299

296-
return VaultObject.model_validate(response)
300+
return ObjectMetadata.model_validate(response)
297301

298302
def update_object(
299303
self,

0 commit comments

Comments
 (0)