Skip to content

Commit

Permalink
Merge pull request #300 from vscheuber/main
Browse files Browse the repository at this point in the history
Consume Trivir PRs
  • Loading branch information
vscheuber committed Oct 11, 2023
2 parents 117bdc6 + bbecddc commit 4be4cb3
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 101 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
]
},
"dependencies": {
"@rockcarver/frodo-lib": "2.0.0-35",
"@rockcarver/frodo-lib": "2.0.0-36",
"chokidar": "^3.5.3",
"cli-progress": "^3.11.2",
"cli-table3": "^0.6.3",
Expand Down
2 changes: 1 addition & 1 deletion src/ops/IdmOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export async function importAllConfigEntities(
export async function countManagedObjects(type: string) {
try {
const result = await queryManagedObjects(type);
printMessage(`${type}: ${result.length}`);
printMessage(`${type}: ${result.length}`, 'data');
} catch (error) {
printMessage(error.response.data, 'error');
printMessage(`Error querying managed objects by type: ${error}`, 'error');
Expand Down
4 changes: 4 additions & 0 deletions src/ops/ThemeOps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { frodo } from '@rockcarver/frodo-lib';
import { type ThemeSkeleton } from '@rockcarver/frodo-lib/types/ops/ThemeOps';
import fs from 'fs';
import { v4 as uuidv4 } from 'uuid';

import {
createProgressIndicator,
Expand Down Expand Up @@ -105,6 +106,7 @@ export async function exportThemeByName(name, file) {
createProgressIndicator('determinate', 1, `Exporting ${name}`);
try {
const themeData = await readThemeByName(name);
if (!themeData._id) themeData._id = uuidv4();
updateProgressIndicator(`Writing file ${fileName}`);
saveToFile('theme', [themeData], '_id', fileName);
stopProgressIndicator(`Successfully exported theme ${name}.`);
Expand Down Expand Up @@ -152,6 +154,7 @@ export async function exportThemesToFile(file) {
'Exporting themes'
);
for (const themeData of allThemesData) {
if (!themeData._id) themeData._id = uuidv4();
updateProgressIndicator(`Exporting theme ${themeData.name}`);
}
saveToFile('theme', allThemesData, '_id', fileName);
Expand All @@ -171,6 +174,7 @@ export async function exportThemesToFiles() {
'Exporting themes'
);
for (const themeData of allThemesData) {
if (!themeData._id) themeData._id = uuidv4();
updateProgressIndicator(`Writing theme ${themeData.name}`);
const fileName = getTypedFilename(themeData.name, 'theme');
saveToFile('theme', themeData, '_id', fileName);
Expand Down
2 changes: 1 addition & 1 deletion test/client_cli/en/__snapshots__/idm-count.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Options:
templates or how to walk through the tenant
admin login flow of Identity Cloud and handle
MFA (choices: "classic", "cloud", "forgeops")
-m, --managed-object <type> Type of managed object to count. E.g.
-o, --managed-object <type> Type of managed object to count. E.g.
"alpha_user", "alpha_role", "user", "role".
--sa-id <sa-id> Service account id.
--sa-jwk-file <file> File containing the JSON Web Key (JWK)
Expand Down
58 changes: 9 additions & 49 deletions test/e2e/__snapshots__/theme-delete.e2e.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,61 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`frodo theme delete "frodo theme delete --all": should display error when no themes can be deleted 1`] = `
"(Use \`frodo --trace-warnings ...\` to show where the warning was created)
Errored ➞ GET https://openam-frodo-dev.forgeblocks.com/am/json/serverinfo/* SyntaxError: /home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_all_1797740195/am_1076162899/recording.har: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.readFileSync (/snapshot/tmp/frodo-lib/node_modules/jsonfile/index.js:52:17)
at API.getRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/node-server/dist/cjs/pollyjs-node-server.js:37:35)
at FSPersister.onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister-fs/dist/cjs/pollyjs-persister-fs.js:35:21)
at onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3586:38)
at FSPersister.findRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3597:30)
at FSPersister.findEntry (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3638:34)
at HttpAdapter.replay (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1329:49)
at HttpAdapter.<anonymous> (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1264:19)
at HttpAdapter.handleRequest (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1219:34)
/home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_all_1797740195/am_1076162899/recording.har: Unexpected end of JSON input
Unrecognized combination of options or no options...
exports[`frodo theme delete "frodo theme delete --theme-id 4eeb434c-1f56-4173-8da3-b49214bedeb6": should display error when the theme with id '4eeb434c-1f56-4173-8da3-b49214bedeb6' cannot be deleted since it does not exist 1`] = `
"Connected to https://openam-frodo-dev.forgeblocks.com/am [alpha] as service account frodo-test [b672336b-41ef-428d-ae4a-e0c082875377]
- Deleting 4eeb434c-1f56-4173-8da3-b49214bedeb6...
✖ Error: '4eeb434c-1f56-4173-8da3-b49214bedeb6' not found in realm 'alpha'
"
`;

exports[`frodo theme delete "frodo theme delete --theme-id 2c23505e-e10c-4f09-be73-13307f615298": should display error when the theme with id '2c23505e-e10c-4f09-be73-13307f615298' cannot be deleted since it does not exist 1`] = `
"(Use \`frodo --trace-warnings ...\` to show where the warning was created)
Errored ➞ GET https://openam-frodo-dev.forgeblocks.com/am/json/serverinfo/* SyntaxError: /home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_theme-id_1554519189/am_1076162899/recording.har: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.readFileSync (/snapshot/tmp/frodo-lib/node_modules/jsonfile/index.js:52:17)
at API.getRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/node-server/dist/cjs/pollyjs-node-server.js:37:35)
at FSPersister.onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister-fs/dist/cjs/pollyjs-persister-fs.js:35:21)
at onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3586:38)
at FSPersister.findRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3597:30)
at FSPersister.findEntry (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3638:34)
at HttpAdapter.replay (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1329:49)
at HttpAdapter.<anonymous> (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1264:19)
at HttpAdapter.handleRequest (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1219:34)
/home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_theme-id_1554519189/am_1076162899/recording.har: Unexpected end of JSON input
Unrecognized combination of options or no options...
"
`;
exports[`frodo theme delete "frodo theme delete --theme-name 'Starter Theme'": should display error when the theme named 'Starter Theme' cannot be deleted since it does not exist 1`] = `
"(Use \`frodo --trace-warnings ...\` to show where the warning was created)
Errored ➞ GET https://openam-frodo-dev.forgeblocks.com/am/json/serverinfo/* SyntaxError: /home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_theme-name_1325589195/am_1076162899/recording.har: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.readFileSync (/snapshot/tmp/frodo-lib/node_modules/jsonfile/index.js:52:17)
at API.getRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/node-server/dist/cjs/pollyjs-node-server.js:37:35)
at FSPersister.onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister-fs/dist/cjs/pollyjs-persister-fs.js:35:21)
at onFindRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3586:38)
at FSPersister.findRecording (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3597:30)
at FSPersister.findEntry (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/persister/dist/cjs/pollyjs-persister.js:3638:34)
at HttpAdapter.replay (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1329:49)
at HttpAdapter.<anonymous> (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1264:19)
at HttpAdapter.handleRequest (/snapshot/tmp/frodo-lib/node_modules/@pollyjs/adapter/dist/cjs/pollyjs-adapter.js:1219:34)
/home/trivir/Work/frodo-rebase/tmp/frodo-lib/mocks/theme_2834462706/delete_1740784714/0_theme-name_1325589195/am_1076162899/recording.har: Unexpected end of JSON input
Unrecognized combination of options or no options...
exports[`frodo theme delete "frodo theme delete --theme-name 'Does Not Exist'": should display error when the theme named 'Does Not Exist' cannot be deleted since it does not exist 1`] = `
"Connected to https://openam-frodo-dev.forgeblocks.com/am [alpha] as service account frodo-test [b672336b-41ef-428d-ae4a-e0c082875377]
- Deleting Does Not Exist...
✖ Error: 'Does Not Exist' not found in realm 'alpha'
"
`;

exports[`frodo theme delete "frodo theme delete -a": should delete all themes 1`] = `""`;

exports[`frodo theme delete "frodo theme delete -i 2c23505e-e10c-4f09-be73-13307f615298": should delete the theme with id '2c23505e-e10c-4f09-be73-13307f615298' 1`] = `""`;
exports[`frodo theme delete "frodo theme delete -i 9e6bf50d-85aa-4d70-a340-439d8bc7bc14": should delete the theme with id '9e6bf50d-85aa-4d70-a340-439d8bc7bc14' 1`] = `""`;

exports[`frodo theme delete "frodo theme delete -n 'Starter Theme'": should delete the theme named 'Starter Theme' 1`] = `""`;
4 changes: 2 additions & 2 deletions test/e2e/agent-gateway-import.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ describe('frodo agent gateway import', () => {
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test(`"frodo agent gateway import -A": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent gateway import -A": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent gateway import -A`;
await testImportAllSeparate(CMD, env, 'agent/gateway');
});

test(`"frodo agent gateway import --all-separate": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent gateway import --all-separate": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent gateway import --all-separate`;
await testImportAllSeparate(CMD, env, 'agent/gateway');
});
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/agent-import.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ describe('frodo agent import', () => {
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test(`"frodo agent import -A": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent import -A": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent import -A`;
await testImportAllSeparate(CMD, env, 'agent');
});

test(`"frodo agent import --all-separate": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent import --all-separate": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent import --all-separate`;
await testImportAllSeparate(CMD, env, 'agent');
});
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/agent-java-import.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ describe('frodo agent java import', () => {
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test(`"frodo agent java import -A": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent java import -A": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent java import -A`;
await testImportAllSeparate(CMD, env, 'agent/java');
});

test(`"frodo agent java import --all-separate": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent java import --all-separate": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent java import --all-separate`;
await testImportAllSeparate(CMD, env, 'agent/java');
});
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/agent-web-import.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ describe('frodo agent web import', () => {
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test(`"frodo agent web import -A": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent web import -A": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent web import -A`;
await testImportAllSeparate(CMD, env, 'agent/web');
});

test(`"frodo agent web import --all-separate": should import all agents from the current directory"`, async () => {
test.skip(`"frodo agent web import --all-separate": should import all agents from the current directory"`, async () => {
const CMD = `frodo agent web import --all-separate`;
await testImportAllSeparate(CMD, env, 'agent/web');
});
Expand Down
65 changes: 30 additions & 35 deletions test/e2e/theme-delete.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@

/*
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete -n 'Starter Theme'
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete -i 2c23505e-e10c-4f09-be73-13307f615298
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete --theme-name 'Does Not Exist'
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete -i 9e6bf50d-85aa-4d70-a340-439d8bc7bc14
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete --theme-id 4eeb434c-1f56-4173-8da3-b49214bedeb6
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete -a
FRODO_MOCK=record FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo theme delete --all
*/
import cp from 'child_process';
import { promisify } from 'util';
Expand All @@ -60,48 +63,40 @@ const exec = promisify(cp.exec);

process.env['FRODO_MOCK'] = '1';
const env = {
env: process.env,
env: process.env,
};
env.env.FRODO_HOST = c.host;
env.env.FRODO_SA_ID = c.saId;
env.env.FRODO_SA_JWK = c.saJwk;

describe('frodo theme delete', () => {
test("\"frodo theme delete -n 'Starter Theme'\": should delete the theme named 'Starter Theme'", async () => {
const CMD = `frodo theme delete -n 'Starter Theme'`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test('"frodo theme delete -n \'Starter Theme\'": should delete the theme named \'Starter Theme\'', async () => {
const CMD = `frodo theme delete -n 'Starter Theme'`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});
test("\"frodo theme delete --theme-name 'Does Not Exist'\": should display error when the theme named 'Does Not Exist' cannot be deleted since it does not exist", async () => {
const CMD = `frodo theme delete --theme-name 'Does Not Exist'`;
const { stderr } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stderr)).toMatchSnapshot();
});

test('"frodo theme delete --theme-name \'Starter Theme\'": should display error when the theme named \'Starter Theme\' cannot be deleted since it does not exist', async () => {
const CMD = `frodo theme delete --theme-name 'Starter Theme'`;
const { stderr } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stderr)).toMatchSnapshot();
});
test('"frodo theme delete -i 9e6bf50d-85aa-4d70-a340-439d8bc7bc14": should delete the theme with id \'9e6bf50d-85aa-4d70-a340-439d8bc7bc14\'', async () => {
const CMD = `frodo theme delete -i 9e6bf50d-85aa-4d70-a340-439d8bc7bc14`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test('"frodo theme delete -i 2c23505e-e10c-4f09-be73-13307f615298": should delete the theme with id \'2c23505e-e10c-4f09-be73-13307f615298\'', async () => {
const CMD = `frodo theme delete -i 2c23505e-e10c-4f09-be73-13307f615298`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test('"frodo theme delete --theme-id 2c23505e-e10c-4f09-be73-13307f615298": should display error when the theme with id \'2c23505e-e10c-4f09-be73-13307f615298\' cannot be deleted since it does not exist', async () => {
const CMD = `frodo theme delete --theme-id 2c23505e-e10c-4f09-be73-13307f615298`;
const { stderr } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stderr)).toMatchSnapshot();
});

test('"frodo theme delete -a": should delete all themes', async () => {
const CMD = `frodo theme delete -a`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});

test('"frodo theme delete --all": should display error when no themes can be deleted', async () => {
const CMD = `frodo theme delete --all`;
const { stderr } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stderr)).toMatchSnapshot();
});
test('"frodo theme delete --theme-id 4eeb434c-1f56-4173-8da3-b49214bedeb6": should display error when the theme with id \'4eeb434c-1f56-4173-8da3-b49214bedeb6\' cannot be deleted since it does not exist', async () => {
const CMD = `frodo theme delete --theme-id 4eeb434c-1f56-4173-8da3-b49214bedeb6`;
const { stderr } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stderr)).toMatchSnapshot();
});

test('"frodo theme delete -a": should delete all themes', async () => {
const CMD = `frodo theme delete -a`;
const { stdout } = await exec(CMD, env);
expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot();
});
});

0 comments on commit 4be4cb3

Please sign in to comment.