forked from rockcarver/frodo-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add config-manager push saml command #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dallinjsevy
wants to merge
3
commits into
main
Choose a base branch
from
feature/config-manager-push-saml
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/cli/config-manager/config-manager-push/config-manager-push-saml.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { configManagerImportSaml } from '../../../configManagerOps/FrConfigSamlOps'; | ||
| import { getTokens } from '../../../ops/AuthenticateOps'; | ||
| import { verboseMessage } from '../../../utils/Console'; | ||
| import { FrodoCommand } from '../../FrodoCommand'; | ||
|
|
||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand( | ||
| 'frodo config-manager push saml', | ||
| [], | ||
| ); | ||
| program | ||
| .description('Import saml configuration.') | ||
| .addOption( | ||
| new Option( | ||
| '-n, --name <name>', | ||
| 'The entityId (or COT _id) of a single SAML entity to import.' | ||
| ) | ||
| ) | ||
| .action(async (host, realm, user, password, options, command) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
| const getTokensIsSuccessful = await getTokens( | ||
| false, | ||
| true, | ||
| ); | ||
| if (!getTokensIsSuccessful) process.exit(1) | ||
| verboseMessage('Importing SAML configuration.') | ||
| const outcomne = await configManagerImportSaml( | ||
| options.name, | ||
| ) | ||
| }); | ||
| return program; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/client_cli/en/__snapshots__/config-manager-push-saml.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`CLI help interface for 'config-manager push saml' should be expected english 1`] = ` | ||
| "Usage: frodo config-manager push saml [options] [host] [realm] [username] [password] | ||
|
|
||
| [Experimental] Import saml configuration. | ||
|
|
||
| Arguments: | ||
| host AM base URL, e.g.: https://cdk.iam.example.com/am. To use a | ||
| connection profile, just specify a unique substring or | ||
| alias. | ||
| realm Realm. Specify realm as '/' for the root realm or 'realm' or | ||
| '/parent/child' otherwise. (default: "alpha" for Identity | ||
| Cloud tenants, "/" otherwise.) | ||
| username Username to login with. Must be an admin user with | ||
| appropriate rights to manage authentication journeys/trees. | ||
| password Password. | ||
|
|
||
| Options: | ||
| -h, --help Help | ||
| -hh, --help-more Help with all options. | ||
| -hhh, --help-all Help with all options, environment variables, and usage | ||
| examples. | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import cp from 'child_process'; | ||
| import { promisify } from 'util'; | ||
|
|
||
| const exec = promisify(cp.exec); | ||
| const CMD = 'frodo config-manager push saml --help'; | ||
| const { stdout } = await exec(CMD); | ||
|
|
||
| test("CLI help interface for 'config-manager push saml' should be expected english", async () => { | ||
| expect(stdout).toMatchSnapshot(); | ||
| }); |
3 changes: 3 additions & 0 deletions
3
test/e2e/__snapshots__/config-manager-push-saml.e2e.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`frodo config-manager push saml "frodo config-manager push saml -D test/e2e/exports/fr-config-manager/forgeops -m forgeops": should import the saml into forgeops" 1`] = `""`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Follow this process to write e2e tests for the CLI project: | ||
| * | ||
| * 1. Test if all the necessary mocks for your tests already exist. | ||
| * In mock mode, run the command you want to test with the same arguments | ||
| * and parameters exactly as you want to test it, for example: | ||
| * | ||
| * $ FRODO_MOCK=1 frodo conn save https://openam-frodo-dev.forgeblocks.com/am volker.scheuber@forgerock.com Sup3rS3cr3t! | ||
| * | ||
| * If your command completes without errors and with the expected results, | ||
| * all the required mocks already exist and you are good to write your | ||
| * test and skip to step #4. | ||
| * | ||
| * If, however, your command fails and you see errors like the one below, | ||
| * you know you need to record the mock responses first: | ||
| * | ||
| * [Polly] [adapter:node-http] Recording for the following request is not found and `recordIfMissing` is `false`. | ||
| * | ||
| * 2. Record mock responses for your exact command. | ||
| * In mock record mode, run the command you want to test with the same arguments | ||
| * and parameters exactly as you want to test it, for example: | ||
| * | ||
| * $ FRODO_MOCK=record frodo conn save https://openam-frodo-dev.forgeblocks.com/am volker.scheuber@forgerock.com Sup3rS3cr3t! | ||
| * | ||
| * Wait until you see all the Polly instances (mock recording adapters) have | ||
| * shutdown before you try to run step #1 again. | ||
| * Messages like these indicate mock recording adapters shutting down: | ||
| * | ||
| * Polly instance 'conn/4' stopping in 3s... | ||
| * Polly instance 'conn/4' stopping in 2s... | ||
| * Polly instance 'conn/save/3' stopping in 3s... | ||
| * Polly instance 'conn/4' stopping in 1s... | ||
| * Polly instance 'conn/save/3' stopping in 2s... | ||
| * Polly instance 'conn/4' stopped. | ||
| * Polly instance 'conn/save/3' stopping in 1s... | ||
| * Polly instance 'conn/save/3' stopped. | ||
| * | ||
| * 3. Validate your freshly recorded mock responses are complete and working. | ||
| * Re-run the exact command you want to test in mock mode (see step #1). | ||
| * | ||
| * 4. Write your test. | ||
| * Make sure to use the exact command including number of arguments and params. | ||
| * | ||
| * 5. Commit both your test and your new recordings to the repository. | ||
| * Your tests are likely going to reside outside the frodo-lib project but | ||
| * the recordings must be committed to the frodo-lib project. | ||
| */ | ||
|
|
||
| /* | ||
| // ForgeOps | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://nightly.gcp.forgeops.com/am frodo config-manager push saml -D test/e2e/exports/fr-config-manager/forgeops -m forgeops | ||
|
dallinjsevy marked this conversation as resolved.
|
||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://nightly.gcp.forgeops.com/am frodo config-manager push saml -n test-IDP -e "https://platform.dev.trivir.com" -D test/e2e/exports/fr-config-manager/forgeops -m forgeops | ||
|
|
||
| */ | ||
|
|
||
| import cp from 'child_process'; | ||
| import { promisify } from 'util'; | ||
| import { getEnv, removeAnsiEscapeCodes } from './utils/TestUtils'; | ||
| import { forgeops_connection as fc } from './utils/TestConfig'; | ||
|
|
||
| const exec = promisify(cp.exec); | ||
|
|
||
| process.env['FRODO_MOCK'] = '1'; | ||
| const forgeopsEnv = getEnv(fc); | ||
|
|
||
| const allDirectory = "test/e2e/exports/fr-config-manager/forgeops"; | ||
|
|
||
| describe('frodo config-manager push saml', () => { | ||
| test(`"frodo config-manager push saml -D ${allDirectory} -m forgeops": should import the saml into forgeops"`, async () => { | ||
| const CMD = `frodo config-manager push saml -D ${allDirectory} -m forgeops`; | ||
| const { stdout } = await exec(CMD, { | ||
| env: { | ||
| ...forgeopsEnv.env, | ||
| TENANT_BASE_URL: "https://platform.dev.trivir.com" | ||
| } | ||
| }); | ||
| expect(removeAnsiEscapeCodes(stdout)).toMatchSnapshot(); | ||
| }); | ||
| test(`"frodo config-manager push saml -n test-IDP -e ... -D ${allDirectory}": should import a single named saml entity`, async () => { | ||
| const CMD = `frodo config-manager push saml -n test-IDP -e "https://platform.dev.trivir.com" -D ${allDirectory} `; | ||
| const { stdout } = await exec(CMD, { env: { ...forgeopsEnv.env } }); | ||
| expect(stdout).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
15 changes: 15 additions & 0 deletions
15
test/e2e/exports/fr-config-manager/forgeops/realms/alpha/realm-config/saml/COT/FR_COT.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "_id": "FR_COT", | ||
| "_rev": "641713822", | ||
| "_type": { | ||
| "_id": "circlesoftrust", | ||
| "collection": true, | ||
| "name": "Circle of Trust" | ||
| }, | ||
| "description": "testCircle", | ||
| "status": "active", | ||
| "trustedProviders": [ | ||
| "ForgeopsTest|saml2", | ||
| "test-IDP|saml2" | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.