Fix codeQL error using URL params as part of the URL & remove commit added by mistake
Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
@@ -42,11 +42,11 @@ describe('api', () => {
|
||||
|
||||
const setupHandlers = () => {
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/v1/secrets`, (req, res, ctx) => {
|
||||
const path = req.url.searchParams.get('path');
|
||||
if (path === 'test/success') {
|
||||
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
|
||||
const { path } = req.params;
|
||||
if (path === 'test%2Fsuccess') {
|
||||
return res(ctx.json(mockSecretsResult));
|
||||
} else if (path === 'test/error') {
|
||||
} else if (path === 'test%2Ferror') {
|
||||
return res(ctx.json([]));
|
||||
}
|
||||
return res(ctx.status(400));
|
||||
|
||||
@@ -56,9 +56,13 @@ export class VaultClient implements VaultApi {
|
||||
}
|
||||
|
||||
async listSecrets(secretPath: string): Promise<VaultSecret[]> {
|
||||
const result = await this.callApi<VaultSecret[]>('v1/secrets', {
|
||||
path: secretPath,
|
||||
});
|
||||
if (secretPath === '') {
|
||||
return [];
|
||||
}
|
||||
const result = await this.callApi<VaultSecret[]>(
|
||||
`v1/secrets/${encodeURIComponent(secretPath)}`,
|
||||
{},
|
||||
);
|
||||
if (!result) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ describe('EntityVautTable', () => {
|
||||
|
||||
const setupHandlers = () => {
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/v1/secrets`, (req, res, ctx) => {
|
||||
const path = req.url.searchParams.get('path');
|
||||
if (path === 'test/success') {
|
||||
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
|
||||
const { path } = req.params;
|
||||
if (path === 'test%2Fsuccess') {
|
||||
return res(ctx.json(mockSecretsResult));
|
||||
} else if (path === 'test/error') {
|
||||
} else if (path === 'test%2Ferror') {
|
||||
return res(ctx.json([]));
|
||||
}
|
||||
return res(ctx.status(400));
|
||||
|
||||
Reference in New Issue
Block a user