Skip to content

Commit 6cb1704

Browse files
committed
fix: tests and validate token clears screen
1 parent 30280d2 commit 6cb1704

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

api/src/__test__/core/utils/files/config-file-normalizer.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ test('it creates a FLASH config with NO OPTIONAL values', () => {
1515
"extraOrigins": "",
1616
"version": "",
1717
},
18-
"local": {},
18+
"local": {
19+
"sandbox": "no",
20+
},
1921
"remote": {
2022
"accesstoken": "",
2123
"apikey": "",
@@ -49,7 +51,9 @@ test('it creates a MEMORY config with NO OPTIONAL values', () => {
4951
"minigraph": "PRE_INIT",
5052
"upnpStatus": "",
5153
},
52-
"local": {},
54+
"local": {
55+
"sandbox": "no",
56+
},
5357
"remote": {
5458
"accesstoken": "",
5559
"allowedOrigins": "/var/run/unraid-notifications.sock, /var/run/unraid-php.sock, /var/run/unraid-cli.sock, https://connect.myunraid.net, https://connect-staging.myunraid.net, https://dev-my.myunraid.net:4000",
@@ -88,7 +92,9 @@ test('it creates a FLASH config with OPTIONAL values', () => {
8892
"extraOrigins": "myextra.origins",
8993
"version": "",
9094
},
91-
"local": {},
95+
"local": {
96+
"sandbox": "no",
97+
},
9298
"remote": {
9399
"accesstoken": "",
94100
"apikey": "",
@@ -129,7 +135,9 @@ test('it creates a MEMORY config with OPTIONAL values', () => {
129135
"minigraph": "PRE_INIT",
130136
"upnpStatus": "Turned On",
131137
},
132-
"local": {},
138+
"local": {
139+
"sandbox": "no",
140+
},
133141
"remote": {
134142
"accesstoken": "",
135143
"allowedOrigins": "/var/run/unraid-notifications.sock, /var/run/unraid-php.sock, /var/run/unraid-cli.sock, https://connect.myunraid.net, https://connect-staging.myunraid.net, https://dev-my.myunraid.net:4000",

api/src/__test__/store/modules/__snapshots__/config.test.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ exports[`Before init returns default values for all fields 1`] = `
1010
"minigraph": "PRE_INIT",
1111
"upnpStatus": "",
1212
},
13-
"local": {},
13+
"local": {
14+
"sandbox": "no",
15+
},
1416
"nodeEnv": "test",
1517
"remote": {
1618
"accesstoken": "",

api/src/__test__/store/modules/config.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ test('After init returns values from cfg file for all fields', async () => {
2626
minigraph: 'PRE_INIT',
2727
upnpStatus: '',
2828
},
29-
local: {},
29+
local: {
30+
sandbox: 'no'
31+
},
3032
nodeEnv: 'test',
3133
remote: {
3234
accesstoken: '',
@@ -74,7 +76,9 @@ test('updateUserConfig merges in changes to current state', async () => {
7476
minigraph: 'PRE_INIT',
7577
upnpStatus: '',
7678
},
77-
local: {},
79+
local: {
80+
sandbox: 'no'
81+
},
7882
nodeEnv: 'test',
7983
remote: {
8084
accesstoken: '',

api/src/unraid-api/cli/developer/developer.command.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { loadConfigFile, updateUserConfig } from '@app/store/modules/config';
66
import { writeConfigSync } from '@app/store/sync/config-disk-sync';
77
import { DeveloperQuestions } from '@app/unraid-api/cli/developer/developer.questions';
88
import { LogService } from '@app/unraid-api/cli/log.service';
9+
import { RestartCommand } from '@app/unraid-api/cli/restart.command';
910

1011
interface DeveloperOptions {
1112
disclaimer: boolean;
@@ -19,7 +20,8 @@ interface DeveloperOptions {
1920
export class DeveloperCommand extends CommandRunner {
2021
constructor(
2122
private logger: LogService,
22-
private readonly inquirerService: InquirerService
23+
private readonly inquirerService: InquirerService,
24+
private readonly restartCommand: RestartCommand
2325
) {
2426
super();
2527
}
@@ -34,6 +36,10 @@ export class DeveloperCommand extends CommandRunner {
3436
store.dispatch(updateUserConfig({ local: { sandbox: options.sandbox ? 'yes' : 'no' } }));
3537
writeConfigSync('flash');
3638

37-
this.logger.info('Updated Developer Configuration');
39+
this.logger.info(
40+
'Updated Developer Configuration - restart the API in 5 seconds to apply them...'
41+
);
42+
await new Promise((resolve) => setTimeout(resolve, 5000));
43+
await this.restartCommand.run([]);
3844
}
3945
}

api/src/unraid-api/cli/sso/validate-token.command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class ValidateTokenCommand extends CommandRunner {
8686
}
8787
const possibleUserIds = configFile.remote.ssoSubIds.split(',');
8888
if (possibleUserIds.includes(username)) {
89+
this.logger.clear();
8990
this.logger.info(JSON.stringify({ error: null, valid: true, username }));
9091
process.exit(0);
9192
} else {

api/src/unraid-api/unraid-file-modifier/__snapshots__/unraid-file-modifier.spec.ts.snap

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)