Skip to content

Commit cd3a1d2

Browse files
chrbrtcbrutscher
andauthored
Fixed secret storing to settings.json (#248)
Co-authored-by: cbrutscher <cbrutscher@liveperson.com>
1 parent cb16323 commit cd3a1d2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "liveperson-functions-cli",
33
"description": "LivePerson Functions CLI",
4-
"version": "2.0.3-beta",
4+
"version": "2.0.4-beta",
55
"author": {
66
"name": "LivePersonInc",
77
"email": "faas-lp@liveperson.com"

src/shared/core-functions-toolbelt/secret-storage/secretClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class FunctionsSecretClient implements ISecretClient {
7373

7474
this.secretCache.set(secret.key, secret as CachedSecret);
7575

76-
return { key: secret.key, value: JSON.parse(secret.value as any) };
76+
return { key: secret.key, value: secret.value };
7777
} catch (error) {
7878
throw newSecretClientError(
7979
ErrorCodes.Secret.NotFound,
@@ -130,7 +130,7 @@ export class FunctionsSecretClient implements ISecretClient {
130130

131131
settings.secrets[index] = {
132132
key: secretKey,
133-
value: stringifiedSecret,
133+
value: newSecretValue,
134134
};
135135
this.fs.writeFileSync(this.path, JSON.stringify(settings, null, 4));
136136

test/shared/core-functions-toolbelt/secret-storage/secretClient.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('FunctionsSecretClient', () => {
8080

8181
expect(result).toEqual({
8282
key: mockSecret.key,
83-
value: JSON.parse(mockSecret.value),
83+
value: mockSecret.value,
8484
});
8585
expect(mockFs.readFileSync).toHaveBeenCalledWith(
8686
expect.stringContaining('functions/settings.json'),
@@ -101,7 +101,7 @@ describe('FunctionsSecretClient', () => {
101101

102102
expect(result).toEqual({
103103
key: mockSecret.key,
104-
value: JSON.parse(mockSecret.value),
104+
value: mockSecret.value,
105105
});
106106
expect(mockCache.has).not.toHaveBeenCalled();
107107
expect(mockFs.readFileSync).toHaveBeenCalled();
@@ -149,8 +149,8 @@ describe('FunctionsSecretClient', () => {
149149
describe('updateSecret', () => {
150150
const mockSettings = {
151151
secrets: [
152-
{ key: 'ExistingKey', value: '"ExistingValue"' },
153-
{ key: 'AnotherKey', value: '"AnotherValue"' },
152+
{ key: 'ExistingKey', value: 'ExistingValue' },
153+
{ key: 'AnotherKey', value: 'AnotherValue' },
154154
],
155155
};
156156

@@ -169,7 +169,7 @@ describe('FunctionsSecretClient', () => {
169169
expect(result).toEqual(updatedSecret);
170170
expect(mockFs.writeFileSync).toHaveBeenCalledWith(
171171
expect.stringContaining('functions/settings.json'),
172-
expect.stringContaining('"\\"NewValue\\""'),
172+
expect.stringContaining('NewValue'),
173173
);
174174
expect(mockCache.set).toHaveBeenCalledWith('ExistingKey', {
175175
key: 'ExistingKey',
@@ -279,11 +279,11 @@ describe('FunctionsSecretClient', () => {
279279
expect(writtenData.secrets).toHaveLength(2);
280280
expect(writtenData.secrets[0]).toEqual({
281281
key: 'ExistingKey',
282-
value: '"UpdatedValue"',
282+
value: 'UpdatedValue',
283283
});
284284
expect(writtenData.secrets[1]).toEqual({
285285
key: 'AnotherKey',
286-
value: '"AnotherValue"',
286+
value: 'AnotherValue',
287287
});
288288
});
289289

0 commit comments

Comments
 (0)