forked from rockcarver/frodo-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add config-manager push secret-mappings command #85
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
4
commits into
main
Choose a base branch
from
feature/config-manager-push-secret-mappings
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
4 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
74 changes: 74 additions & 0 deletions
74
src/cli/config-manager/config-manager-push/config-manager-push-secret-mappings.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,74 @@ | ||
| import { frodo } from '@rockcarver/frodo-lib'; | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { configManagerImportSecretMappings } from '../../../configManagerOps/FrConfigSecretMappingsOps'; | ||
| import { getTokens } from '../../../ops/AuthenticateOps'; | ||
| import { printMessage, verboseMessage } from '../../../utils/Console'; | ||
| import { FrodoCommand } from '../../FrodoCommand'; | ||
|
|
||
| const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants; | ||
|
|
||
| const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY]; | ||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand( | ||
| 'frodo config-manager push secret-mappings', | ||
| [], | ||
| deploymentTypes | ||
| ); | ||
|
|
||
| program | ||
| .description('Import secret mappings.') | ||
| .addOption( | ||
| new Option( | ||
| '-n, --name <name>', | ||
| 'Name of the secret mapping, It will only import secret mapping with the specified name.' | ||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-r, --realm <realm>', | ||
| 'Realm name; imports only the secret mappings of the specified realm.' | ||
| ) | ||
| ) | ||
| .action(async (host, realm, user, password, options, command) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
|
|
||
| if (options.name && !options.realm) { | ||
| printMessage( | ||
| 'The -n/--policy-name option requires -r/--realm to be specified.', | ||
| 'error' | ||
| ); | ||
| program.help(); | ||
| process.exitCode = 1; | ||
| return; | ||
| } | ||
|
|
||
| if (await getTokens(false, true, deploymentTypes)) { | ||
| verboseMessage('importing config entity secret-mappings'); | ||
| const outcome = await configManagerImportSecretMappings( | ||
| options.name, | ||
| options.realm | ||
| ); | ||
| if (!outcome) process.exitCode = 1; | ||
| } | ||
| // unrecognized combination of options or no options | ||
| else { | ||
| printMessage( | ||
| 'Unrecognized combination of options or no options...', | ||
| 'error' | ||
| ); | ||
| program.help(); | ||
| process.exitCode = 1; | ||
| } | ||
| }); | ||
|
|
||
| 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
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,60 @@ | ||
| { | ||
| "meta": { | ||
| "exportDate": "2026-04-02T17:35:45.032Z", | ||
| "exportTool": "frodo", | ||
| "exportToolVersion": "v4.0.0-34 [v24.13.0]", | ||
| "exportedBy": "phales@trivir.com", | ||
| "origin": "https://openam-frodo-dev.forgeblocks.com/am", | ||
| "originAmVersion": "9.0.0" | ||
| }, | ||
| "secretstore": { | ||
| "am.authentication.nodes.persistentcookie.encryption": { | ||
| "_id": "am.authentication.nodes.persistentcookie.encryption", | ||
| "_type": { | ||
| "_id": "mappings", | ||
| "collection": true, | ||
| "name": "Mappings" | ||
| }, | ||
| "aliases": [ | ||
| "Btest2" | ||
| ], | ||
| "secretId": "am.authentication.nodes.persistentcookie.encryption" | ||
| }, | ||
| "am.authentication.nodes.webauthn.fidometadataservice.rootcertificate": { | ||
| "_id": "am.authentication.nodes.webauthn.fidometadataservice.rootcertificate", | ||
| "_type": { | ||
| "_id": "mappings", | ||
| "collection": true, | ||
| "name": "Mappings" | ||
| }, | ||
| "aliases": [ | ||
| "Btest" | ||
| ], | ||
| "secretId": "am.authn.authid.signing.HMAC" | ||
| }, | ||
| "am.services.oauth2.oidc.signing.RSA": { | ||
| "_id": "am.services.oauth2.oidc.signing.RSA", | ||
| "_type": { | ||
| "_id": "mappings", | ||
| "collection": true, | ||
| "name": "Mappings" | ||
| }, | ||
| "aliases": [ | ||
| "Atest" | ||
| ], | ||
| "secretId": "am.services.oauth2.oidc.signing.RSA" | ||
| }, | ||
| "am.services.selfservice.token.signing": { | ||
| "_id": "am.services.selfservice.token.signing", | ||
| "_type": { | ||
| "_id": "mappings", | ||
| "collection": true, | ||
| "name": "Mappings" | ||
| }, | ||
| "aliases": [ | ||
| "Atest2" | ||
| ], | ||
| "secretId": "am.services.selfservice.token.signing" | ||
| } | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
test/client_cli/en/__snapshots__/config-manager-push-secret-mappings.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,32 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`CLI help interface for 'config-manager push secret-mappings' should be expected english 1`] = ` | ||
| "Usage: frodo config-manager push secret-mappings [options] [host] [realm] [username] [password] | ||
|
|
||
| [Experimental] Import secret mappings. | ||
|
|
||
| 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. | ||
|
|
||
| Deployment: Cloud-only | ||
|
|
||
| Options: | ||
| -n, --name <name> Name of the secret mapping, It will only import secret | ||
| mapping with the specified name. | ||
| -r, --realm <realm> Realm name; imports only the secret mappings of the | ||
| specified realm. | ||
| -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
10 changes: 10 additions & 0 deletions
10
test/client_cli/en/config-manager-push-secret-mappings.test.js
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 secret-mappings --help'; | ||
| const { stdout } = await exec(CMD); | ||
|
|
||
| test("CLI help interface for 'config-manager push secret-mappings' should be expected english", async () => { | ||
| expect(stdout).toMatchSnapshot(); | ||
| }); |
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
7 changes: 7 additions & 0 deletions
7
test/e2e/__snapshots__/config-manager-push-secret-mappings.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,7 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`frodo config-manager push secret-mappings "frodo config-manager push secret-mappings -D test/e2e/exports/fr-config-manager/cloud ": should import the secret mapping into cloud" 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secret-mappings "frodo config-manager push secret-mappings -r alpha -n am.services.iot.cert.verification -D test/e2e/exports/fr-config-manager/cloud": should import a specific secret mapping by name into cloud" 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secret-mappings "frodo config-manager push secret-mappings -r bravo -D test/e2e/exports/fr-config-manager/cloud": should import a specific secret-mapping by name into cloud" 1`] = `""`; |
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.