Skip to content

Commit 77a6e81

Browse files
authored
Merge pull request #255 from RedisInsight/feature/RI-6508/mandatory-encryption
RI-6508: turn on keytar encryption for existing users
2 parents 452bf51 + a37ef1b commit 77a6e81

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed

src/resources/agreements-spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.2",
2+
"version": "1.0.7",
33
"agreements": {
44
"analytics": {
55
"defaultValue": false,
@@ -68,4 +68,4 @@
6868
}
6969
}
7070
}
71-
}
71+
}

src/webviews/src/utils/comparisons/compareConsents.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import { has } from 'lodash'
22
import { isVersionHigher } from 'uiSrc/utils/comparisons/compareVersions'
33

4+
// There was an issue that caused users to have encryption setting populated as false by default
5+
// This is a custom check to address that issue for existing users. The commit should be reverted after some time.
6+
const shouldTriggerKeytarEncryptionSpec = (spec: any, applied: any): boolean => true
7+
// local settings are from v1.0.6
8+
&& applied?.version === '1.0.6'
9+
// has locally stored false value
10+
&& applied.encryption === false
11+
// keytar is enabled
12+
&& spec?.encryption?.disabled === false
13+
// target current version of config
14+
&& spec.encryption.since === '1.0.2'
15+
416
// returns true if has different consents
517
export const isDifferentConsentsExists = (specs: any, applied: any) =>
618
!!compareConsents(specs, applied).length
@@ -19,6 +31,7 @@ export const compareConsents = (
1931
(isReturnAllNonRequired && !specs[consent]?.required)
2032
|| applied === null
2133
|| !has(applied, consent)
34+
|| (consent === 'encryption' && shouldTriggerKeytarEncryptionSpec(specs, applied))
2235
|| isVersionHigher(specs[consent]?.since, applied.version),
2336
)
2437
.map((consent) => ({ ...specs[consent], agreementName: consent }))

src/webviews/src/utils/comparisons/tests/compareConsents.spec.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,62 @@ describe('isDifferentConsentsExists', () => {
6060
expect(isDifferentConsentsExists(spec.agreements, agreements3)).toBeTruthy()
6161
})
6262
})
63+
64+
describe('compareConsents: custom keytar encryption conditions', () => {
65+
const agreementsSpec = {
66+
eula: spec.agreements.eula,
67+
encryption: {
68+
defaultValue: true,
69+
displayInSetting: false,
70+
required: false,
71+
editable: true,
72+
disabled: false,
73+
category: 'privacy',
74+
since: '1.0.2',
75+
title: 'Encryption',
76+
label: 'Encrypt sensitive information',
77+
description:
78+
'Select to encrypt sensitive information using system keychain. Otherwise, this information is stored locally in plain text, which may incur security risk.',
79+
},
80+
}
81+
82+
it('should prompt users with encryption set to false and v1.0.6 to set encryption again', () => {
83+
const agreements = {
84+
eula: true,
85+
encryption: false,
86+
version: '1.0.6',
87+
}
88+
89+
expect(compareConsents(agreementsSpec, agreements)).toHaveLength(1)
90+
})
91+
92+
it('should NOT prompt users with encryption set to false and v1.0.7 to set encryption again', () => {
93+
const agreements = {
94+
eula: true,
95+
encryption: false,
96+
version: '1.0.7',
97+
}
98+
99+
expect(compareConsents(agreementsSpec, agreements)).toHaveLength(0)
100+
})
101+
102+
it('should NOT prompt users with encryption set to true and v1.0.6 to set encryption again', () => {
103+
const agreements = {
104+
eula: true,
105+
encryption: true,
106+
version: '1.0.6',
107+
}
108+
109+
expect(compareConsents(agreementsSpec, agreements)).toHaveLength(0)
110+
})
111+
112+
it('should NOT prompt users with encryption set to true and v1.0.7 to set encryption again', () => {
113+
const agreements = {
114+
eula: true,
115+
encryption: true,
116+
version: '1.0.7',
117+
}
118+
119+
expect(compareConsents(agreementsSpec, agreements)).toHaveLength(0)
120+
})
121+
})

src/webviews/test/helpers/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ export const constants = {
232232
notifications: false,
233233
encryption: false,
234234
eula: true,
235-
version: '1.0.6',
235+
version: '1.0.7',
236236
},
237237
},
238238

239239
SETTINGS_AGREEMENTS_SPEC: {
240-
version: '1.0.6',
240+
version: '1.0.7',
241241
agreements: {
242242
analytics: {
243243
...COMMON_CONSENT_CONTENT,

0 commit comments

Comments
 (0)