Skip to content

Commit 9178098

Browse files
committed
Add basic test for shell command
1 parent 79cee66 commit 9178098

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CLI help interface for 'shell' should be expected english 1`] = `
4+
"Usage: frodo shell [options] [host] [realm] [username] [password]
5+
6+
Launch the frodo interactive shell.
7+
8+
Arguments:
9+
host AM base URL, e.g.:
10+
https://cdk.iam.example.com/am. To use a
11+
connection profile, just specify a
12+
unique substring.
13+
realm Realm. Specify realm as '/' for the root
14+
realm or 'realm' or '/parent/child'
15+
otherwise. (default: "alpha" for
16+
Identity Cloud tenants, "/" otherwise.)
17+
username Username to login with. Must be an admin
18+
user with appropriate rights to manage
19+
authentication journeys/trees.
20+
password Password.
21+
22+
Options:
23+
--allow-await Allows top-level awaits to be used in
24+
the shell.
25+
--curlirize Output all network calls in curl format.
26+
-D, --directory <directory> Set the working directory.
27+
--debug Debug output during command execution.
28+
If specified, may or may not produce
29+
additional output helpful for
30+
troubleshooting.
31+
--flush-cache Flush token cache.
32+
-h, --help Help
33+
--idm-host <idm-host> IDM base URL, e.g.:
34+
https://cdk.idm.example.com/myidm. Use
35+
only if your IDM installation resides in
36+
a different domain and/or if the base
37+
path differs from the default
38+
"/openidm".
39+
-k, --insecure Allow insecure connections when using
40+
SSL/TLS. Has no effect when using a
41+
network proxy for https
42+
(HTTPS_PROXY=http://<host>:<port>), in
43+
that case the proxy must provide this
44+
capability. (default: Don't allow
45+
insecure connections)
46+
--login-client-id <client-id> Specify a custom OAuth2 client id to use
47+
a your own oauth2 client for IDM API
48+
calls in deployments of type "cloud" or
49+
"forgeops". Your custom client must be
50+
configured as a public client and allow
51+
the authorization code grant using the
52+
"openid fr:idm:*" scope. Use the
53+
"--redirect-uri" parameter if you have
54+
configured a custom redirect uri
55+
(default:
56+
"<host>/platform/appAuthHelperRedirect.html").
57+
--login-redirect-uri <redirect-uri> Specify a custom redirect URI to use
58+
with your custom OAuth2 client (efault:
59+
"<host>/platform/appAuthHelperRedirect.html").
60+
-m, --type <type> Override auto-detected deployment type.
61+
Valid values for type:
62+
classic: A classic Access
63+
Management-only deployment with custom
64+
layout and configuration.
65+
cloud: A ForgeRock Identity Cloud
66+
environment.
67+
forgeops: A ForgeOps CDK or CDM
68+
deployment.
69+
The detected or provided deployment type
70+
controls certain behavior like obtaining
71+
an Identity Management admin token or
72+
not and whether to export/import
73+
referenced email templates or how to
74+
walk through the tenant admin login flow
75+
of Identity Cloud and handle MFA
76+
(choices: "classic", "cloud",
77+
"forgeops")
78+
--no-cache Disable token cache for this operation.
79+
--sa-id <sa-id> Service account id.
80+
--sa-jwk-file <file> File containing the JSON Web Key (JWK)
81+
associated with the the service account.
82+
--verbose Verbose output during command execution.
83+
If specified, may or may not produce
84+
additional output.
85+
86+
Environment Variables:
87+
FRODO_HOST: AM base URL. Overridden by 'host' argument.
88+
FRODO_IDM_HOST: IDM base URL. Overridden by '--idm-host' option.
89+
FRODO_REALM: Realm. Overridden by 'realm' argument.
90+
FRODO_USERNAME: Username. Overridden by 'username' argument.
91+
FRODO_PASSWORD: Password. Overridden by 'password' argument.
92+
FRODO_LOGIN_CLIENT_ID: OAuth2 client id for IDM API calls. Overridden by '--login-client-id' option.
93+
FRODO_LOGIN_REDIRECT_URI: Redirect Uri for custom OAuth2 client id. Overridden by '--login-redirect-uri' option.
94+
FRODO_SA_ID: Service account uuid. Overridden by '--sa-id' option.
95+
FRODO_SA_JWK: Service account JWK. Overridden by '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.
96+
FRODO_NO_CACHE: Disable token cache. Same as '--no-cache' option.
97+
FRODO_TOKEN_CACHE_PATH: Use this token cache file instead of '~/.frodo/TokenCache.json'.
98+
FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.
99+
FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.
100+
FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.
101+
FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.
102+
FRODO_MASTER_KEY: Use this master key instead of what's in '~/.frodo/masterkey.key'. Takes precedence over FRODO_MASTER_KEY_PATH.
103+
104+
Usage Examples:
105+
Launch a frodo shell using explicit login parameters:
106+
 $ frodo shell https://openam-matrix.id.forgerock.io/am [email protected] 'Blu3P!ll3d'
107+
 Launch a frodo shell using a connection profile (identified by the full AM base URL):
108+
 $ frodo shell https://openam-matrix.id.forgerock.io/am
109+
 Launch a frodo shell using a connection profile (identified by a unique substring of the AM base URL):
110+
 $ frodo shell matrix
111+

112+
"
113+
`;

test/client_cli/en/shell.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import cp from 'child_process';
2+
import { promisify } from 'util';
3+
4+
const exec = promisify(cp.exec);
5+
const CMD = 'frodo shell --help';
6+
const { stdout } = await exec(CMD);
7+
8+
test("CLI help interface for 'shell' should be expected english", async () => {
9+
expect(stdout).toMatchSnapshot();
10+
});

0 commit comments

Comments
 (0)