Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
da379ba
RI-7091 - Add an environment variable to skip the EULA screen - updat…
May 23, 2025
949e2c4
RI-7091 - Add an environment variable to skip the EULA screen - updat…
KIvanow May 23, 2025
4c0f105
RI-7091 - Add an environment variable to skip the EULA screen - updat…
KIvanow May 23, 2025
eaff41e
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
a461c72
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
0b2993b
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
15be851
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
c82e8d8
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
1e8c099
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow May 27, 2025
8fc0333
RI-7091 fix regular autodiscovery
ArtemHoruzhenko May 28, 2025
fc13b7a
Merge pull request #4589 from RedisInsight/feature/RI-7091---autodisc…
May 28, 2025
a81ed32
RI-7091 - Add an environment variable to skip the EULA screen - testi…
May 28, 2025
5c49cbd
testing delaying of the autodiscovery as a way to avoid the odd race …
May 28, 2025
3f07f39
removed setImmediate to check
May 28, 2025
77057c4
removed setTimeouts
KIvanow May 28, 2025
5f4ffd3
RI-7091 - extra logs and removed extra code
May 29, 2025
3b92942
-
May 29, 2025
6f1ff6a
-
KIvanow May 30, 2025
c6f11ba
Merge pull request #4599 from RedisInsight/RI-7091---testig-different…
May 30, 2025
ea03c96
RI-7091 - Add an environment variable to skip the EULA screen - fixed…
KIvanow Jun 2, 2025
b5e238d
RI-7091 - Add an environment variable to skip the EULA screen - added…
Jun 3, 2025
55bf392
RI-7091 - Add an environment variable to skip the EULA screen - added…
Jun 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions redisinsight/api/src/constants/agreements-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"required": false,
"editable": true,
"disabled": false,
"linkToPrivacyPolicy": true,
"category": "privacy",
"since": "1.0.1",
"title": "Usage Data",
Expand All @@ -19,6 +20,7 @@
"required": false,
"editable": true,
"disabled": false,
"linkToPrivacyPolicy": false,
"category": "notifications",
"since": "1.0.6",
"title": "Notification",
Expand All @@ -37,6 +39,7 @@
"required": false,
"editable": true,
"disabled": false,
"linkToPrivacyPolicy": false,
"category": "privacy",
"since": "1.0.3",
"title": "Encryption",
Expand All @@ -49,6 +52,7 @@
"required": false,
"editable": true,
"disabled": true,
"linkToPrivacyPolicy": false,
"category": "privacy",
"since": "1.0.3",
"title": "Encryption",
Expand All @@ -61,6 +65,7 @@
"required": false,
"editable": true,
"disabled": true,
"linkToPrivacyPolicy": false,
"category": "privacy",
"since": "1.0.5",
"title": "Encryption",
Expand All @@ -75,6 +80,7 @@
"required": true,
"editable": false,
"disabled": false,
"linkToPrivacyPolicy": false,
"since": "1.0.4",
"title": "Server Side Public License",
"label": "I have read and understood the Terms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class LocalAgreementsRepository extends AgreementsRepository {
defaultOptions: DefaultAgreementsOptions = {}
): Promise<Agreements> {
let entity = await this.repository.findOneBy({});
if (!entity) {
if (!entity?.data) {
try {
entity = await this.repository.save(
classToClass(AgreementsEntity, plainToInstance(Agreements, {
Expand Down
50 changes: 38 additions & 12 deletions redisinsight/api/src/modules/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Injectable,
InternalServerErrorException,
Logger,
OnApplicationBootstrap,
} from '@nestjs/common';
import { difference, isEmpty, map, cloneDeep } from 'lodash';
import { readFile } from 'fs-extra';
Expand Down Expand Up @@ -35,8 +36,10 @@ import { EncryptionService } from '../encryption/encryption.service';
const SERVER_CONFIG = config.get('server') as Config['server'];

@Injectable()
export class SettingsService {
export class SettingsService implements OnApplicationBootstrap {
private logger = new Logger('SettingsService');
private triggerAutoDiscoveryDueToEnv = false;
private autoDiscoveryDueToEnvTriggered = false;

constructor(
@Inject(forwardRef(() => DatabaseDiscoveryService))
Expand All @@ -51,6 +54,38 @@ export class SettingsService {
private eventEmitter: EventEmitter2,
) {}

async onApplicationBootstrap() {
// Check if we need to run discovery due to environment variables
if (
SERVER_CONFIG.acceptTermsAndConditions
&& this.triggerAutoDiscoveryDueToEnv
&& !this.autoDiscoveryDueToEnvTriggered
) {
this.autoDiscoveryDueToEnvTriggered = true;
process.nextTick(() => this.discoverDatabasesAfterEulaAccepted(null));
}
}

/**
* Discovers databases after EULA has been accepted
* @param sessionMetadata
* @private
*/
private async discoverDatabasesAfterEulaAccepted(
sessionMetadata: SessionMetadata,
): Promise<void> {
try {
await this.databaseDiscoveryService.discover(sessionMetadata, true);
} catch (e) {
// ignore error
this.logger.error(
'Failed discover databases after eula accepted.',
e,
sessionMetadata,
);
}
}

/**
* Method to get settings
*/
Expand All @@ -64,6 +99,7 @@ export class SettingsService {

let defaultOptions: object;
if (SERVER_CONFIG.acceptTermsAndConditions) {
this.triggerAutoDiscoveryDueToEnv = true;
const isEncryptionAvailable = await this.encryptionService.isEncryptionAvailable();

defaultOptions = {
Expand All @@ -84,7 +120,6 @@ export class SettingsService {
sessionMetadata,
);


return classToClass(GetAppSettingsResponse, {
...settings?.data,
acceptTermsAndConditionsOverwritten: SERVER_CONFIG.acceptTermsAndConditions,
Expand Down Expand Up @@ -153,16 +188,7 @@ export class SettingsService {

// Discover databases from envs or autodiscovery flow when eula accept
if (!oldAppSettings?.agreements?.eula && results?.agreements?.eula) {
try {
await this.databaseDiscoveryService.discover(sessionMetadata, true);
} catch (e) {
// ignore error
this.logger.error(
'Failed discover databases after eula accepted.',
e,
sessionMetadata,
);
}
await this.discoverDatabasesAfterEulaAccepted(sessionMetadata);
}

return results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface Props {
checked: boolean
isSettingsPage?: boolean
withoutSpacer?: boolean
linkToPrivacyPolicy?: boolean
}

const ConsentOption = (props: Props) => {
Expand All @@ -25,7 +24,6 @@ const ConsentOption = (props: Props) => {
checked,
isSettingsPage = false,
withoutSpacer = false,
linkToPrivacyPolicy = false,
} = props

return (
Expand All @@ -38,7 +36,7 @@ const ConsentOption = (props: Props) => {
color="subdued"
style={{ marginTop: '12px' }}
>
<ItemDescription description={consent.description} withLink={linkToPrivacyPolicy} />
<ItemDescription description={consent.description} withLink={consent.linkToPrivacyPolicy} />
</EuiText>
<Spacer size="m" />
</>
Expand Down Expand Up @@ -66,7 +64,7 @@ const ConsentOption = (props: Props) => {
color="subdued"
style={{ marginTop: '12px' }}
>
<ItemDescription description={consent.description} withLink={linkToPrivacyPolicy} />
<ItemDescription description={consent.description} withLink={consent.linkToPrivacyPolicy} />
</EuiText>
)}
</FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const ConsentsPrivacy = () => {
onChangeAgreement={onChangeAgreement}
isSettingsPage
key={consent.agreementName}
linkToPrivacyPolicy
/>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IConsent {
required: boolean
editable: boolean
disabled: boolean
linkToPrivacyPolicy: boolean
category?: string
since: string
title: string
Expand Down Expand Up @@ -222,17 +223,6 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
<Spacer size="m" />
{consents.length > 1 && (
<>
<EuiCallOut>
<EuiText
size="s"
className={styles.smallText}
data-testid="plugin-section"
>
To avoid automatic execution of malicious code, when adding new
Workbench plugins, use files from trusted authors only.
</EuiText>
</EuiCallOut>
<Spacer />
<FlexItem>
<Row gap="m">
<FlexItem>
Expand Down Expand Up @@ -287,7 +277,6 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
checked={formik.values[consent.agreementName] ?? false}
onChangeAgreement={onChangeAgreement}
key={consent.agreementName}
linkToPrivacyPolicy
/>
))}
{!!notificationConsents.length && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ test('Verify that user should accept User Agreements to continue working with th
await t.expect(userAgreementDialog.submitButton.hasAttribute('disabled')).ok('Submit button not disabled by default');
await t.expect(myRedisDatabasePage.AddRedisDatabaseDialog.customSettingsButton.exists).notOk('User can\'t add a database');
});
test('Verify that the encryption enabled by default and specific message', async t => {
const expectedPluginText = 'To avoid automatic execution of malicious code, when adding new Workbench plugins, use files from trusted authors only.';
// Verify that section with plugin warning is displayed
test('Verify that the encryption enabled by default and specific message', async t => {
await t.expect(userAgreementDialog.pluginSectionWithText.exists).ok('Plugin text is not displayed');
// Verify that text that is displayed in window is 'While adding new visualization plugins, use files only from trusted authors to avoid automatic execution of malicious code.'
const pluginText = userAgreementDialog.pluginSectionWithText.innerText;
await t.expect(pluginText).eql(expectedPluginText, 'Plugin text is incorrect');

// unskip the verification when encription will be fixed for test builds
// // Verify that encryption enabled by default
// await t.expect(userAgreementDialog.switchOptionEncryption.withAttribute('aria-checked', 'true').exists).ok('Encryption enabled by default');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ test('Verify that user should accept User Agreements to continue working with th
await t.expect(myRedisDatabasePage.AddRedisDatabaseDialog.customSettingsButton.exists).notOk('User can\'t add a database');
});
test('Verify that the encryption enabled by default and specific message', async t => {
const expectedPluginText = 'To avoid automatic execution of malicious code, when adding new Workbench plugins, use files from trusted authors only.';
// Verify that section with plugin warning is displayed
await t.expect(userAgreementDialog.pluginSectionWithText.exists).ok('Plugin text is not displayed');
// Verify that text that is displayed in window is 'While adding new visualization plugins, use files only from trusted authors to avoid automatic execution of malicious code.'
const pluginText = userAgreementDialog.pluginSectionWithText.innerText;
await t.expect(pluginText).eql(expectedPluginText, 'Plugin text is incorrect');
// Verify that encryption enabled by default
await t.expect(userAgreementDialog.switchOptionEncryption.withAttribute('aria-checked', 'true').exists).ok('Encryption enabled by default');
});
Expand Down
Loading