11import vault from "node-vault" ;
22import { getImage } from "../../../testcontainers/src/utils/test-helper" ;
3- import { StartedVaultContainer , VaultContainer } from "./vault-container" ;
3+ import { VaultContainer } from "./vault-container" ;
44
55const VAULT_TOKEN = "my-root-token" ;
66const IMAGE = getImage ( __dirname ) ;
77
88describe ( "VaultContainer" , { timeout : 180_000 } , ( ) => {
9- let container : StartedVaultContainer ;
10-
11- afterEach ( async ( ) => {
12- await container ?. stop ( ) ;
13- } ) ;
14-
159 // inside_block:readWrite {
1610 it ( "should start Vault and allow reading/writing secrets" , async ( ) => {
17- container = await new VaultContainer ( IMAGE ) . withVaultToken ( VAULT_TOKEN ) . start ( ) ;
11+ const container = await new VaultContainer ( IMAGE ) . withVaultToken ( VAULT_TOKEN ) . start ( ) ;
1812
1913 const client = vault ( {
2014 apiVersion : "v1" ,
@@ -34,12 +28,14 @@ describe("VaultContainer", { timeout: 180_000 }, () => {
3428
3529 expect ( data . message ) . toBe ( "world" ) ;
3630 expect ( data . other ) . toBe ( "vault" ) ;
31+
32+ await container . stop ( ) ;
3733 } ) ;
3834 // }
3935
4036 // inside_block:initCommands {
4137 it ( "should execute init commands using vault CLI" , async ( ) => {
42- container = await new VaultContainer ( IMAGE )
38+ const container = await new VaultContainer ( IMAGE )
4339 . withVaultToken ( VAULT_TOKEN )
4440 . withInitCommands ( "secrets enable transit" , "write -f transit/keys/my-key" )
4541 . start ( ) ;
@@ -48,6 +44,8 @@ describe("VaultContainer", { timeout: 180_000 }, () => {
4844
4945 expect ( result . exitCode ) . toBe ( 0 ) ;
5046 expect ( result . output ) . toContain ( "my-key" ) ;
47+
48+ await container . stop ( ) ;
5149 } ) ;
5250 // }
5351} ) ;
0 commit comments