@@ -3,10 +3,10 @@ import { fetchMethod, fetchOnce, fetchURL } from '../common/utils/test-utils';
33import { WorkOS } from '../workos' ;
44import { List } from '../common/interfaces' ;
55import {
6- SecretDigest ,
7- SecretMetadata ,
8- SecretVersion ,
9- VaultSecret ,
6+ ObjectDigest ,
7+ ObjectMetadata ,
8+ ObjectVersion ,
9+ VaultObject ,
1010} from './interfaces' ;
1111import { ConflictException } from '../common/exceptions/conflict.exception' ;
1212
@@ -15,9 +15,9 @@ const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
1515describe ( 'Vault' , ( ) => {
1616 beforeEach ( ( ) => fetch . resetMocks ( ) ) ;
1717
18- describe ( 'createSecret ' , ( ) => {
19- it ( 'creates secret ' , async ( ) => {
20- const secretName = 'charger' ;
18+ describe ( 'createObject ' , ( ) => {
19+ it ( 'creates object ' , async ( ) => {
20+ const objectName = 'charger' ;
2121 fetchOnce ( {
2222 id : 's1' ,
2323 context : {
@@ -32,14 +32,14 @@ describe('Vault', () => {
3232 } ,
3333 version_id : 'v1' ,
3434 } ) ;
35- const resource = await workos . vault . createSecret ( {
36- name : secretName ,
35+ const resource = await workos . vault . createObject ( {
36+ name : objectName ,
3737 context : { type : 'spore' } ,
3838 value : 'Full speed ahead' ,
3939 } ) ;
4040 expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv` ) ;
4141 expect ( fetchMethod ( ) ) . toBe ( 'POST' ) ;
42- expect ( resource ) . toStrictEqual < SecretMetadata > ( {
42+ expect ( resource ) . toStrictEqual < ObjectMetadata > ( {
4343 id : 's1' ,
4444 context : {
4545 type : 'spore' ,
@@ -55,17 +55,17 @@ describe('Vault', () => {
5555 } ) ;
5656 } ) ;
5757
58- it ( 'throws an error if secret exists' , async ( ) => {
59- const secretName = 'charger' ;
58+ it ( 'throws an error if object exists' , async ( ) => {
59+ const objectName = 'charger' ;
6060 fetchOnce (
6161 {
6262 error : 'Item already exists' ,
6363 } ,
6464 { status : 409 } ,
6565 ) ;
6666 await expect (
67- workos . vault . createSecret ( {
68- name : secretName ,
67+ workos . vault . createObject ( {
68+ name : objectName ,
6969 context : { type : 'spore' } ,
7070 value : 'Full speed ahead' ,
7171 } ) ,
@@ -75,14 +75,14 @@ describe('Vault', () => {
7575 } ) ;
7676 } ) ;
7777
78- describe ( 'readSecret ' , ( ) => {
79- it ( 'reads a secret by id' , async ( ) => {
80- const secretName = 'lima' ;
81- const secretId = 'secret1 ' ;
78+ describe ( 'readObject ' , ( ) => {
79+ it ( 'reads a object by id' , async ( ) => {
80+ const objectName = 'lima' ;
81+ const objectId = 'object1 ' ;
8282 fetchOnce ( {
83- id : secretId ,
83+ id : objectId ,
8484 metadata : {
85- id : secretId ,
85+ id : objectId ,
8686 context : {
8787 emporer : 'groove' ,
8888 } ,
@@ -95,18 +95,18 @@ describe('Vault', () => {
9595 } ,
9696 version_id : 'version1' ,
9797 } ,
98- name : secretName ,
98+ name : objectName ,
9999 value : 'Pull the lever Gronk' ,
100100 } ) ;
101- const resource = await workos . vault . readSecret ( {
102- id : secretId ,
101+ const resource = await workos . vault . readObject ( {
102+ id : objectId ,
103103 } ) ;
104- expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/${ secretId } ` ) ;
104+ expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/${ objectId } ` ) ;
105105 expect ( fetchMethod ( ) ) . toBe ( 'GET' ) ;
106- expect ( resource ) . toStrictEqual < VaultSecret > ( {
107- id : secretId ,
106+ expect ( resource ) . toStrictEqual < VaultObject > ( {
107+ id : objectId ,
108108 metadata : {
109- id : secretId ,
109+ id : objectId ,
110110 context : {
111111 emporer : 'groove' ,
112112 } ,
@@ -119,14 +119,14 @@ describe('Vault', () => {
119119 } ,
120120 versionId : 'version1' ,
121121 } ,
122- name : secretName ,
122+ name : objectName ,
123123 value : 'Pull the lever Gronk' ,
124124 } ) ;
125125 } ) ;
126126 } ) ;
127127
128- describe ( 'listSecrets ' , ( ) => {
129- it ( 'gets a paginated list of secrets ' , async ( ) => {
128+ describe ( 'listObjects ' , ( ) => {
129+ it ( 'gets a paginated list of objects ' , async ( ) => {
130130 fetchOnce ( {
131131 data : [
132132 {
@@ -140,10 +140,10 @@ describe('Vault', () => {
140140 before : 'charger' ,
141141 } ,
142142 } ) ;
143- const resource = await workos . vault . listSecrets ( ) ;
143+ const resource = await workos . vault . listObjects ( ) ;
144144 expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv` ) ;
145145 expect ( fetchMethod ( ) ) . toBe ( 'GET' ) ;
146- expect ( resource ) . toStrictEqual < List < SecretDigest > > ( {
146+ expect ( resource ) . toStrictEqual < List < ObjectDigest > > ( {
147147 object : 'list' ,
148148 data : [
149149 {
@@ -160,8 +160,8 @@ describe('Vault', () => {
160160 } ) ;
161161 } ) ;
162162
163- describe ( 'listSecretVersions ' , ( ) => {
164- it ( 'gets a paginated list of secret versions' , async ( ) => {
163+ describe ( 'listObjectVersions ' , ( ) => {
164+ it ( 'gets a paginated list of object versions' , async ( ) => {
165165 fetchOnce ( {
166166 data : [
167167 {
@@ -177,10 +177,10 @@ describe('Vault', () => {
177177 before : 'raZUqoHteQkLihH6AG5bj6sYAqMcJS76' ,
178178 } ,
179179 } ) ;
180- const resource = await workos . vault . listSecretVersions ( { id : 'secret1 ' } ) ;
181- expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/secret1 /versions` ) ;
180+ const resource = await workos . vault . listObjectVersions ( { id : 'object1 ' } ) ;
181+ expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/object1 /versions` ) ;
182182 expect ( fetchMethod ( ) ) . toBe ( 'GET' ) ;
183- expect ( resource ) . toStrictEqual < SecretVersion [ ] > ( [
183+ expect ( resource ) . toStrictEqual < ObjectVersion [ ] > ( [
184184 {
185185 createdAt : new Date ( Date . parse ( '2029-03-17T15:51:57.000000Z' ) ) ,
186186 currentVersion : true ,
@@ -190,14 +190,14 @@ describe('Vault', () => {
190190 } ) ;
191191 } ) ;
192192
193- describe ( 'updateSecret ' , ( ) => {
194- it ( 'updates secret ' , async ( ) => {
195- const secretId = 's1' ;
193+ describe ( 'updateObject ' , ( ) => {
194+ it ( 'updates object ' , async ( ) => {
195+ const objectId = 's1' ;
196196 fetchOnce ( {
197- id : secretId ,
197+ id : objectId ,
198198 name : 'charger' ,
199199 metadata : {
200- id : secretId ,
200+ id : objectId ,
201201 context : {
202202 type : 'spore' ,
203203 } ,
@@ -211,17 +211,17 @@ describe('Vault', () => {
211211 version_id : 'v1' ,
212212 } ,
213213 } ) ;
214- const resource = await workos . vault . updateSecret ( {
215- id : secretId ,
214+ const resource = await workos . vault . updateObject ( {
215+ id : objectId ,
216216 value : 'Full speed ahead' ,
217217 } ) ;
218- expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/${ secretId } ` ) ;
218+ expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/${ objectId } ` ) ;
219219 expect ( fetchMethod ( ) ) . toBe ( 'PUT' ) ;
220- expect ( resource ) . toStrictEqual < VaultSecret > ( {
221- id : secretId ,
220+ expect ( resource ) . toStrictEqual < VaultObject > ( {
221+ id : objectId ,
222222 name : 'charger' ,
223223 metadata : {
224- id : secretId ,
224+ id : objectId ,
225225 context : {
226226 type : 'spore' ,
227227 } ,
@@ -238,21 +238,21 @@ describe('Vault', () => {
238238 } ) ;
239239 } ) ;
240240
241- it ( 'throws an error if secret version check fails' , async ( ) => {
241+ it ( 'throws an error if object version check fails' , async ( ) => {
242242 fetchOnce (
243243 {
244244 error : 'Item already exists' ,
245245 } ,
246246 { status : 409 } ,
247247 ) ;
248248 await expect (
249- workos . vault . updateSecret ( {
250- id : 'secret1 ' ,
249+ workos . vault . updateObject ( {
250+ id : 'object1 ' ,
251251 value : 'Full speed ahead' ,
252252 versionCheck : 'notaversion' ,
253253 } ) ,
254254 ) . rejects . toThrow ( ConflictException ) ;
255- expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/secret1 ` ) ;
255+ expect ( fetchURL ( ) ) . toContain ( `/vault/v1/kv/object1 ` ) ;
256256 expect ( fetchMethod ( ) ) . toBe ( 'PUT' ) ;
257257 } ) ;
258258 } ) ;
0 commit comments