Skip to content
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

Oauth client mgmt #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
85c3991
Added support for basic management of Oauth clients
tobiaslohr Apr 3, 2020
ec04968
Added support for basic management of Oauth clients
tobiaslohr Apr 3, 2020
9ce5179
Merge with remote
tobiaslohr Apr 3, 2020
ef7f1c3
Merge branch 'master' into oauth-client-mgmt
tobiaslohr Apr 30, 2020
7328ff3
Merge branch 'master' into oauth-client-mgmt
tobiaslohr Nov 12, 2021
8cc71dc
add API client creation
hnestmann Nov 22, 2021
7311737
add client list / rename client add to client create
hnestmann Nov 23, 2021
23f0cf3
Update README.md
hnestmann Jan 28, 2022
7283140
Merge branch 'master' into oauth-client-mgmt
tobiaslohr Feb 2, 2022
6bb62f0
Improve command description, rename internal component to create a user
tobiaslohr Feb 15, 2022
4ea6e87
Remove client:info in favor of client:list, updated documentation
tobiaslohr Feb 15, 2022
af392e1
Reorder client:create and client:update
tobiaslohr Feb 15, 2022
3198063
Merge branch 'master' into oauth-client-mgmt
tobiaslohr Feb 15, 2022
35d0900
Improve client list, fix reference error
tobiaslohr Feb 15, 2022
5fdd6dd
Use generate-password@v1.7.0
tobiaslohr Feb 15, 2022
264ee88
Adding CLI tests
tobiaslohr Feb 15, 2022
b1f574f
Use --clientid consistently
tobiaslohr Feb 15, 2022
0972076
Use page size of 25 consistently
tobiaslohr Feb 15, 2022
2247ed4
Obtain authenticated user and client
tobiaslohr Jan 24, 2023
e1156a8
Reimplementation of client mgmt operations, add rotation logic
tobiaslohr Jan 24, 2023
64f305d
Adding supporting function to obtain org details for authenticated su…
tobiaslohr Jan 24, 2023
2deb4fd
Adding cli tests, rework of cli operations for clients
tobiaslohr Jan 24, 2023
2fbed24
Update readme
tobiaslohr Jan 24, 2023
e9e95a1
Remove debug code
tobiaslohr Jan 24, 2023
ec89cac
Merge changes from master
tobiaslohr Jan 25, 2023
fe4f7ea
Use consistent shortcut flag for --clientid
tobiaslohr Jan 25, 2023
e732ae1
Remove some properties from client representation
tobiaslohr Jan 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,26 @@ You are now ready to use the tool by running the main command `sfcc-ci`.
Use `sfcc-ci --help` or just `sfcc-ci` to get started and see the full list of commands available:

```bash
Usage: cli [options] [command]
Usage: cli [options] [command]

Options:
-V, --version output the version number
-D, --debug enable verbose output
--selfsigned allow connection to hosts using self-signed certificates
-I, --ignorewarnings ignore any warnings logged to the console
-h, --help output usage information
-j, --json print output as JSON instead of plain text

Commands:
auth:login [options] [client] [secret] Authenticate a present user for interactive use
auth:logout End the current sessions and clears the authentication
client:auth [options] [client] [secret] [user] [user_password] Authenticate an API client with an optional user for automation use
client:auth:renew Renews the client authentication. Requires the initial client authentication to be run with the --renew option.
client:auth:token Return the current authentication token
client:list [options] Lists a Oauth clients you have access to
client:create [options] Creates a new Oauth client
client:update [options] Update an Oauth client
client:rotate [options] Rotate credentials of an Oauth client
client:delete [options] Delete an Oauth client
data:upload [options] Uploads a file onto a Commerce Cloud instance
sandbox:realm:list [options] List realms eligible to manage sandboxes for
sandbox:realm:update [options] Update realm settings
Expand Down Expand Up @@ -336,9 +340,9 @@ Use `sfcc-ci --help` or just `sfcc-ci` to get started and see the full list of c
code:deploy [options] <archive> Deploys a custom code archive onto a Commerce Cloud instance
code:activate [options] <version> Activate the custom code version on a Commerce Cloud instance
code:delete [options] Delete a custom code version
code:manifest:generate <localdirectorypaths> Generates the manifest file based on the given local directories
code:compare <localdirectorypaths> Compares the given local directories with the given code version (or the active one if none specified) of the Commerce Cloud instance and provide a diff between the two
code:deploy:diff <codeversion> <localdirectorypaths> Deploys only the local changes to the instance and not a full new code version
code:manifest:generate [options] <localdirectorypaths> Generates the manifest file based on the given local directories.
code:compare [options] <localdirectorypaths> Compare the given local directories with the given code version (or the active one if none specified) of the Commerce Cloud instance and provide a diff between the two.
code:deploy:diff [options] <codeversion> <localdirectorypaths> Generate a manifest for the given local directories. Compare this manifest with the one within the active code version of the instance. Deploy only the files which have been updated locally comparing to the remote, within a newly created code version.Activate this newly generated code version if required in the options
job:run [options] <job_id> [job_parameters...] Starts a job execution on a Commerce Cloud instance
job:status [options] <job_id> <job_execution_id> Get the status of a job execution on a Commerce Cloud instance
cartridge:add [options] <cartridgename> Adds a cartridge-name to the site cartridge path
Expand All @@ -360,32 +364,32 @@ Use `sfcc-ci --help` or just `sfcc-ci` to get started and see the full list of c
slas:client:list [options] Lists all SLAS clients that belong to a given tenant
slas:client:delete [options] Deletes a SLAS client from a given tenant

Environment:
Environment:

$SFCC_LOGIN_URL set login url used for authentication
$SFCC_OAUTH_LOCAL_PORT set Oauth local port for authentication flow
$SFCC_OAUTH_CLIENT_ID client id used for authentication
$SFCC_OAUTH_CLIENT_SECRET client secret used for authentication
$SFCC_OAUTH_USER_NAME user name used for authentication
$SFCC_OAUTH_USER_PASSWORD user password used for authentication
$SFCC_SANDBOX_API_HOST set alternative sandbox API host
$SFCC_SANDBOX_API_POLLING_TIMEOUT set timeout for sandbox polling in minutes
$SFCC_SCAPI_SHORTCODE the Salesforce Commerce (Headless) API Shortcode
$SFCC_SCAPI_TENANTID the Salesforce Commerce (Headless) API TenantId
$DEBUG enable verbose output
$SFCC_LOGIN_URL set login url used for authentication
$SFCC_OAUTH_LOCAL_PORT set Oauth local port for authentication flow
$SFCC_OAUTH_CLIENT_ID client id used for authentication
$SFCC_OAUTH_CLIENT_SECRET client secret used for authentication
$SFCC_OAUTH_USER_NAME user name used for authentication
$SFCC_OAUTH_USER_PASSWORD user password used for authentication
$SFCC_SANDBOX_API_HOST set sandbox API host
$SFCC_SANDBOX_API_POLLING_TIMEOUT set timeout for sandbox polling in minutes
$SFCC_SCAPI_SHORTCODE the Salesforce Commerce (Headless) API Shortcode
$SFCC_SCAPI_TENANTID the Salesforce Commerce (Headless) API TenantId
$DEBUG enable verbose output

Detailed Help:
Detailed Help:

Use sfcc-ci <sub:command> --help to get detailed help and example usage of sub:commands
Use sfcc-ci <sub:command> --help to get detailed help and example usage of sub:commands

Useful Resources:
Useful Resources:

Salesforce Commerce Cloud CLI Release Notes: https://sfdc.co/sfcc-cli-releasenotes
Salesforce Commerce Cloud CLI Readme: https://sfdc.co/sfcc-cli-readme
Salesforce Commerce Cloud CLI Cheatsheet: https://sfdc.co/sfcc-cli-cheatsheet
Salesforce Commerce Cloud Account Manager: https://account.demandware.com
Salesforce Commerce Cloud API Explorer: https://api-explorer.commercecloud.salesforce.com
Salesforce Commerce Cloud Documentation: https://documentation.b2c.commercecloud.salesforce.com
Salesforce Commerce Cloud CLI Release Notes: https://sfdc.co/sfcc-cli-releasenotes
Salesforce Commerce Cloud CLI Readme: https://sfdc.co/sfcc-cli-readme
Salesforce Commerce Cloud CLI Cheatsheet: https://sfdc.co/sfcc-cli-cheatsheet
Salesforce Commerce Cloud Account Manager: https://account.demandware.com
Salesforce Commerce Cloud API Explorer: https://api-explorer.commercecloud.salesforce.com
Salesforce Commerce Cloud Documentation: https://documentation.b2c.commercecloud.salesforce.com
```

Use `sfcc-ci <sub:command> --help` to get detailed help and example usage of a sub:command.
Expand Down
134 changes: 130 additions & 4 deletions bin/test-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ else
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci sandbox:realm:list´
###############################################################################

# we have to re-authenticate with API key and user first
echo "Running ´sfcc-ci client:auth <api_key> <secret> <user> <pwd>´:"
node ./cli.js client:auth "$ARG_CLIENT_ID" "$ARG_CLIENT_SECRET" "$ARG_USER" "$ARG_USER_PW"
Expand All @@ -205,6 +201,136 @@ else
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci client:create´
###############################################################################

echo "Testing command ´sfcc-ci client:create´ without option (expected to fail):"
node ./cli.js client:create
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:create --configuration <configuration>´ --noprompt:"
TEST_NEW_CLIENT_RESULT=`node ./cli.js client:create --configuration '{"name": "My new client", "password": "%2secret(Sauce7?!"}' --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# grab some client details for next set of tests
TEST_NEW_CLIENT_ID=`echo $TEST_NEW_CLIENT_RESULT | jq '.client.id' -r`

###############################################################################
###### Testing ´sfcc-ci client:list´
###############################################################################

echo "Testing command ´sfcc-ci client:list´:"
node ./cli.js client:list
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:list´ --clientid <INVALID_CLIENT>´ (expected to fail):"
node ./cli.js client:list --clientid INVALID_CLIENT
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:list´ --clientid <client_id>´:"
node ./cli.js client:list --clientid $TEST_NEW_CLIENT_ID
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci client:update´
###############################################################################

echo "Testing command ´sfcc-ci client:update´ without option (expected to fail):"
node ./cli.js client:update
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:update --clientid <client_id> --changes <changes> --noprompt´:"
node ./cli.js client:update --clientid $TEST_NEW_CLIENT_ID --changes '{"active": false}' --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci client:rotate´
###############################################################################

echo "Testing command ´sfcc-ci client:rotate´ without option (expected to fail):"
node ./cli.js client:rotate
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:rotate --clientid <client_id> --noprompt´:"
TEST_ROTATION_RESULT=`node ./cli.js client:rotate --clientid $TEST_NEW_CLIENT_ID --noprompt`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# grab some client details for cleanup
TEST_ROTATION_ID=`echo $TEST_ROTATION_RESULT | jq '.client.id' -r`

###############################################################################
###### Testing ´sfcc-ci client:delete´
###############################################################################

echo "Testing command ´sfcc-ci client:delete´ without option (expected to fail):"
node ./cli.js client:delete
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

echo "Testing command ´sfcc-ci client:delete --clientid <client_id> --noprompt´:"
node ./cli.js client:delete --clientid $TEST_NEW_CLIENT_ID --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

# cleanup client created during rotation
node ./cli.js client:delete --clientid $TEST_ROTATION_ID --noprompt

###############################################################################
###### Testing ´sfcc-ci sandbox:realm:list´
###############################################################################

echo "Testing command ´sfcc-ci sandbox:realm:list´:"
node ./cli.js sandbox:realm:list
if [ $? -eq 0 ]; then
Expand Down
Loading