Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit 5527530

Browse files
PluiesFlydiverny
authored andcommitted
fix: Stringify JSON response for compatibility with KV backend (#214)
Due to changes in #206, we now need to stringify the response from the backend which currently comes as an object rather than a JSON string. Fixes issue such as: ``` {"level":30,"time":1573653228258,"pid":19,"hostname":"external-secrets-8zq4bq","msg":"running poll on the secret example/example","v":1} {"level":40,"time":1573653228468,"pid":19,"hostname":"external-secrets-8zq4bq","msg":"Failed to JSON.parse value for 'secrets/data/example/credentials', please verify that your secret value is correctly formatted as JSON. To use plain text secret remove the 'property: apiToken'","v":1} ```
1 parent e6171c8 commit 5527530

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/backends/vault-backend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class VaultBackend extends KVBackend {
5353
this._logger.debug(`reading secret key ${key} from vault`)
5454
const secretResponse = await this._client.read(key)
5555

56-
return secretResponse.data.data
56+
return JSON.stringify(secretResponse.data.data)
5757
}
5858
}
5959

lib/backends/vault-backend.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('VaultBackend', () => {
6969
sinon.assert.calledWith(clientMock.read, 'fakeSecretKey')
7070

7171
// ... and expect to get its proper value
72-
expect(secretPropertyValue).equals('fakeSecretPropertyValue')
72+
expect(secretPropertyValue).equals('"fakeSecretPropertyValue"')
7373
})
7474

7575
it('returns secret property value after renewing token if a token exists', async () => {
@@ -93,7 +93,7 @@ describe('VaultBackend', () => {
9393
sinon.assert.calledWith(clientMock.read, 'fakeSecretKey')
9494

9595
// ... and expect to get its proper value
96-
expect(secretPropertyValue).equals('fakeSecretPropertyValue')
96+
expect(secretPropertyValue).equals('"fakeSecretPropertyValue"')
9797
})
9898
})
9999
})

0 commit comments

Comments
 (0)