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

Commit

Permalink
fix: Stringify JSON response for compatibility with KV backend (#214)
Browse files Browse the repository at this point in the history
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}
```
  • Loading branch information
Pluies authored and Flydiverny committed Nov 14, 2019
1 parent e6171c8 commit 5527530
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/backends/vault-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class VaultBackend extends KVBackend {
this._logger.debug(`reading secret key ${key} from vault`)
const secretResponse = await this._client.read(key)

return secretResponse.data.data
return JSON.stringify(secretResponse.data.data)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/backends/vault-backend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('VaultBackend', () => {
sinon.assert.calledWith(clientMock.read, 'fakeSecretKey')

// ... and expect to get its proper value
expect(secretPropertyValue).equals('fakeSecretPropertyValue')
expect(secretPropertyValue).equals('"fakeSecretPropertyValue"')
})

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

// ... and expect to get its proper value
expect(secretPropertyValue).equals('fakeSecretPropertyValue')
expect(secretPropertyValue).equals('"fakeSecretPropertyValue"')
})
})
})

0 comments on commit 5527530

Please sign in to comment.