From ac4307ebc8820f5a2ad2587be5e2316fe6b715ad Mon Sep 17 00:00:00 2001 From: Matthew Daubney Date: Tue, 20 Oct 2026 11:08:03 +0100 Subject: [PATCH] Add OpenBao client integration tests Co-Authored-By: Claude Sonnet 5.5 --- src/api/bao.integration.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/api/bao.integration.test.ts diff --git a/src/api/bao.integration.test.ts b/src/api/bao.integration.test.ts new file mode 100644 index 0000000..6fe228e --- /dev/null +++ b/src/api/bao.integration.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, test } from 'vitest' +import { BaoClient } from './bao' + +const addr = process.env.BAO_ADDR ?? 'http://127.0.0.1:8200' +const token = process.env.BAO_TOKEN ?? 'root' + +describe('BaoClient against a dev OpenBao', () => { + const client = new BaoClient(addr, token) + + test('health', async () => { + const h = await client.health() + expect(h.initialized).toBe(true) + expect(h.sealed).toBe(false) + }) + + test('lookupSelf with root token', async () => { + expect((await client.lookupSelf()).policies).toContain('root') + }) + + test('bad token is a forbidden error', async () => { + await expect(client.withToken('nope').lookupSelf()).rejects.toMatchObject({ kind: 'forbidden' }) + }) + + test('list of missing path is empty', async () => { + expect(await client.list('secret/metadata/does-not-exist')).toEqual([]) + }) +})