mirror of
https://github.com/unraid/api.git
synced 2026-01-01 22:20:05 -06:00
fix: tests and validate token clears screen
This commit is contained in:
@@ -15,7 +15,9 @@ test('it creates a FLASH config with NO OPTIONAL values', () => {
|
|||||||
"extraOrigins": "",
|
"extraOrigins": "",
|
||||||
"version": "",
|
"version": "",
|
||||||
},
|
},
|
||||||
"local": {},
|
"local": {
|
||||||
|
"sandbox": "no",
|
||||||
|
},
|
||||||
"remote": {
|
"remote": {
|
||||||
"accesstoken": "",
|
"accesstoken": "",
|
||||||
"apikey": "",
|
"apikey": "",
|
||||||
@@ -49,7 +51,9 @@ test('it creates a MEMORY config with NO OPTIONAL values', () => {
|
|||||||
"minigraph": "PRE_INIT",
|
"minigraph": "PRE_INIT",
|
||||||
"upnpStatus": "",
|
"upnpStatus": "",
|
||||||
},
|
},
|
||||||
"local": {},
|
"local": {
|
||||||
|
"sandbox": "no",
|
||||||
|
},
|
||||||
"remote": {
|
"remote": {
|
||||||
"accesstoken": "",
|
"accesstoken": "",
|
||||||
"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",
|
"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', () => {
|
|||||||
"extraOrigins": "myextra.origins",
|
"extraOrigins": "myextra.origins",
|
||||||
"version": "",
|
"version": "",
|
||||||
},
|
},
|
||||||
"local": {},
|
"local": {
|
||||||
|
"sandbox": "no",
|
||||||
|
},
|
||||||
"remote": {
|
"remote": {
|
||||||
"accesstoken": "",
|
"accesstoken": "",
|
||||||
"apikey": "",
|
"apikey": "",
|
||||||
@@ -129,7 +135,9 @@ test('it creates a MEMORY config with OPTIONAL values', () => {
|
|||||||
"minigraph": "PRE_INIT",
|
"minigraph": "PRE_INIT",
|
||||||
"upnpStatus": "Turned On",
|
"upnpStatus": "Turned On",
|
||||||
},
|
},
|
||||||
"local": {},
|
"local": {
|
||||||
|
"sandbox": "no",
|
||||||
|
},
|
||||||
"remote": {
|
"remote": {
|
||||||
"accesstoken": "",
|
"accesstoken": "",
|
||||||
"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",
|
"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",
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ exports[`Before init returns default values for all fields 1`] = `
|
|||||||
"minigraph": "PRE_INIT",
|
"minigraph": "PRE_INIT",
|
||||||
"upnpStatus": "",
|
"upnpStatus": "",
|
||||||
},
|
},
|
||||||
"local": {},
|
"local": {
|
||||||
|
"sandbox": "no",
|
||||||
|
},
|
||||||
"nodeEnv": "test",
|
"nodeEnv": "test",
|
||||||
"remote": {
|
"remote": {
|
||||||
"accesstoken": "",
|
"accesstoken": "",
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ test('After init returns values from cfg file for all fields', async () => {
|
|||||||
minigraph: 'PRE_INIT',
|
minigraph: 'PRE_INIT',
|
||||||
upnpStatus: '',
|
upnpStatus: '',
|
||||||
},
|
},
|
||||||
local: {},
|
local: {
|
||||||
|
sandbox: 'no'
|
||||||
|
},
|
||||||
nodeEnv: 'test',
|
nodeEnv: 'test',
|
||||||
remote: {
|
remote: {
|
||||||
accesstoken: '',
|
accesstoken: '',
|
||||||
@@ -74,7 +76,9 @@ test('updateUserConfig merges in changes to current state', async () => {
|
|||||||
minigraph: 'PRE_INIT',
|
minigraph: 'PRE_INIT',
|
||||||
upnpStatus: '',
|
upnpStatus: '',
|
||||||
},
|
},
|
||||||
local: {},
|
local: {
|
||||||
|
sandbox: 'no'
|
||||||
|
},
|
||||||
nodeEnv: 'test',
|
nodeEnv: 'test',
|
||||||
remote: {
|
remote: {
|
||||||
accesstoken: '',
|
accesstoken: '',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { loadConfigFile, updateUserConfig } from '@app/store/modules/config';
|
|||||||
import { writeConfigSync } from '@app/store/sync/config-disk-sync';
|
import { writeConfigSync } from '@app/store/sync/config-disk-sync';
|
||||||
import { DeveloperQuestions } from '@app/unraid-api/cli/developer/developer.questions';
|
import { DeveloperQuestions } from '@app/unraid-api/cli/developer/developer.questions';
|
||||||
import { LogService } from '@app/unraid-api/cli/log.service';
|
import { LogService } from '@app/unraid-api/cli/log.service';
|
||||||
|
import { RestartCommand } from '@app/unraid-api/cli/restart.command';
|
||||||
|
|
||||||
interface DeveloperOptions {
|
interface DeveloperOptions {
|
||||||
disclaimer: boolean;
|
disclaimer: boolean;
|
||||||
@@ -19,7 +20,8 @@ interface DeveloperOptions {
|
|||||||
export class DeveloperCommand extends CommandRunner {
|
export class DeveloperCommand extends CommandRunner {
|
||||||
constructor(
|
constructor(
|
||||||
private logger: LogService,
|
private logger: LogService,
|
||||||
private readonly inquirerService: InquirerService
|
private readonly inquirerService: InquirerService,
|
||||||
|
private readonly restartCommand: RestartCommand
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -34,6 +36,10 @@ export class DeveloperCommand extends CommandRunner {
|
|||||||
store.dispatch(updateUserConfig({ local: { sandbox: options.sandbox ? 'yes' : 'no' } }));
|
store.dispatch(updateUserConfig({ local: { sandbox: options.sandbox ? 'yes' : 'no' } }));
|
||||||
writeConfigSync('flash');
|
writeConfigSync('flash');
|
||||||
|
|
||||||
this.logger.info('Updated Developer Configuration');
|
this.logger.info(
|
||||||
|
'Updated Developer Configuration - restart the API in 5 seconds to apply them...'
|
||||||
|
);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||||
|
await this.restartCommand.run([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ export class ValidateTokenCommand extends CommandRunner {
|
|||||||
}
|
}
|
||||||
const possibleUserIds = configFile.remote.ssoSubIds.split(',');
|
const possibleUserIds = configFile.remote.ssoSubIds.split(',');
|
||||||
if (possibleUserIds.includes(username)) {
|
if (possibleUserIds.includes(username)) {
|
||||||
|
this.logger.clear();
|
||||||
this.logger.info(JSON.stringify({ error: null, valid: true, username }));
|
this.logger.info(JSON.stringify({ error: null, valid: true, username }));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
||||||
|
|
||||||
exports[`FileModificationService > should apply modifications 1`] = `[Error: Application not implemented.]`;
|
|
||||||
Reference in New Issue
Block a user