Skip to content

Latest commit

 

History

History
218 lines (160 loc) · 10.6 KB

User-Guide-CLI.md

File metadata and controls

218 lines (160 loc) · 10.6 KB

Users Guide

Mojaloop Testing Toolkit CLI

Introduction

The intention of this document is to provide a basic user guide to the Mojaloop Testing Toolkit CLI. This easy to use toolkit was designed for both technical and non-technical users, even though the primarily users would likely be Quality Assurance (QA) resources. By following this guide, users will have a better understand of the capabilities and functionality of the cli.

The Mojaloop Testing Toolkit CLI was designed for participants that would like to participate in the Mojaloop scheme. Intentionally build as a standard integration testing tool between a Digital Financial Service Provider (DFSP) and the Mojaloop Switch (Hub), to facilitate testing. This tool set can potentially be used by both the DFSP and the Mojaloop Switch to verify the integration between the 2 entities.

For additional back ground information on the Self Testing Toolkit, please see Mojaloop Testing Toolkit. It would be to the particpant's benefit to familiarise themselves with the understanding of the Architecture Diagram that explains the various components and related flows.

Table of Contents

  1. Getting Started

  2. The Mojaloop Testing Toolkit CLI

    2.1. Help screen

    2.2. Monitoring Mode

    2.3. Outbound Mode

    2.4. AWS S3 Upload

    2.5. Slack Notification

1. Getting Started

To get started, please follow the instructions in the README document. This document covers the use-cases with the Mojaloop Simulator.

2. CLI

2.1 Help screen

The help screen allows you to see the usage, possible options and default values

command:

node src/cli_client/client -h

output:

Usage: client [options]

Options:
  -v, --version                                             output the version number
  -c, --config <config>                                     default configuration: {"mode": "outbound", "reportFormat": "json"}
  -m, --mode <mode>                                         default: "outbound" --- supported modes: "monitoring", "outbound"
  -u, --base-url <baseUrl>                                  default: "http://localhost:5050"
  -i, --input-files <inputFiles>                            csv list of json files or directories; required when the mode is "outbound" --- supported formats: "json"
  -e, --environment-file <environmentFile>                  required when the mode is "outbound" --- supported formats: "json"
  --report-format <reportFormat>                            default: "json" --- supported formats: "json", "html", "printhtml"
  --report-auto-filename-enable <reportAutoFilenameEnable>  default: false, if true the file name will be generated by the backend
  --report-target <reportTarget>                            default: "file://<file_name_genrated_by_backend>"  --- supported targets: "file://path_to_file", "s3://<bucket_name>[/<file_path>]"
  --slack-webhook-url <slackWebhookUrl>                     default: "Disabled"  --- supported formats: "https://....."
  -h, --help                                                output usage information

 *** If the option report-target is set to use AWS S3 service, the variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION) should be passed in environment

2.2 Monitoring Mode

The monitoring mode allows you to monitor incoming requests from the Mojaloop Simulator.

Example:

command:

node src/cli_client/client -m monitoring

output:

Listening on newLog events...
2020-05-12T12:23:32.988Z INFO   (15892862129885sy33i)   Request: post /bulkTransfers
{
  "request": {
    "uniqueId": "15892862129885sy33i",
    "headers": {
      "content-type": "application/vnd.interoperability.parties+json;version=1.0",
      "accept": "application/vnd.interoperability.parties+json;version=1.0",
      "fspiop-source": "testingtoolkitdfsp",
      "date": "Tue, 12 May 2020 12:23:32 GMT",
      "user-agent": "axios/0.19.2",
      "content-length": "256",
      "host": "localhost:4040",
      "connection": "close"
    },
    "body": {
      "bulkTransferId": "202137c6-2ca9-429d-b03b-41d5cf19258c",
      "bulkQuoteId": "8823f09e-728c-4e04-b718-d17a24e55bb0",
      "payerFsp": "string",
      "payeeFsp": "string",
      "expiration": "2020-01-01T10:10:10.000Z",
      "extensionList": {
        "extension": [
          {
            "key": "string",
            "value": "string"
          }
        ]
      }
    }
  }
}

You could Send Transfer from postman or execute outbound mode with an example from examples/test-cases folder

2.3 Outbound Mode

This sections will enable you to intiate requests from the cli to your DFSP implementation.

The user can create a collection of operations and add a number of assertions to these operations. The assertions can be setup and customized to support your testing requirements and verify both positive and negative requests and responses.

Default values

mode:

  • outbound reportFormat:
  • json reportName:
  • when reportFormat is json: ${test-name}-${date-now}.json
  • when reportFormat is html/printhtml format: value is generated by the service responsible for converting the json to the given format

Exit codes

The CLI tool is able to return the proper exit codes in case of success and failures. This will enable this tool to use in automation systems (CICD).

  • 0: all assertions passed
  • 1: there is at least 1 failed assertion

Example

command:

node src/cli_client/client -m outbound -i examples/collections/dfsp/p2p_happy_path.json -e examples/environments/dfsp_local_environment.json --report-format html

output:

Listening on outboundProgress events...
 ████████████████████████████████████████ 100% | ETA: 0s | 3/3
--------------------TEST CASES--------------------
P2P Transfer Happy Path
        Get party information - GET - /parties/{Type}/{ID} - [8/8]
        Send quote - POST - /quotes - [11/11]
        Send transfer - POST - /transfers - [9/9]
--------------------TEST CASES--------------------
┌───────────────────────────────────────────────────────┐
│                        SUMMARY                        │
├───────────────────────┬───────────────────────────────┤
│ Total assertions      │ 28                            │
├───────────────────────┼───────────────────────────────┤
│ Passed assertions     │ 28                            │
├───────────────────────┼───────────────────────────────┤
│ Failed assertions     │ 0                             │
├───────────────────────┼───────────────────────────────┤
│ Total requests        │ 3                             │
├───────────────────────┼───────────────────────────────┤
│ Total test cases      │ 1                             │
├───────────────────────┼───────────────────────────────┤
│ Passed percentage     │ 100.00%                       │
├───────────────────────┼───────────────────────────────┤
│ Started time          │ Mon, 01 Jun 2020 14:46:20 GMT │
├───────────────────────┼───────────────────────────────┤
│ Completed time        │ Mon, 01 Jun 2020 14:46:21 GMT │
├───────────────────────┼───────────────────────────────┤
│ Runtime duration      │ 832 ms                        │
├───────────────────────┼───────────────────────────────┤
│ Average response time │ NA                            │
└───────────────────────┴───────────────────────────────┘
TTK-Assertion-Report-dfsp-p2p-tests-2020-06-01T14:46:21.303Z.html was generated
Terminate with exit code 0

You will find a report in the project folder - 'TTK-Assertion-Report-{collection-name}-{ISO-date}.{report-format}'

2.4 AWS S3 Upload

You can choose to upload the generated report to AWS S3 at the end of tests execution.

Use the command line option '--report-target' to specify the target in the format s3://<bucket_name>/<object_key>

You can use the option '--report-auto-filename-enable' to replace the file name specified in the target with an auto generated file name.

To use AWS S3 service, the following environment variables should be set with proper credentials

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION

Example Command:

node src/cli_client/client -m outbound -i examples/collections/dfsp/p2p_happy_path.json -e examples/environments/dfsp_local_environment.json --report-format html --report-auto-filename-enable true --report-target s3://qa-reports-bucket/reports-folder/report-name.html

2.5 Slack Notification

You can choose to notify over a slack channel after a completed tests execution. For this, you have to generate your slack webhook in slack portal and provide the webhook URL by the command line option '--slack-webhook-url'

If the S3 option is also set, then a link to the uploaded report will be sent in the slack notification.

Example Command:

node src/cli_client/client -m outbound -i examples/collections/dfsp/p2p_happy_path.json -e examples/environments/dfsp_local_environment.json --slack-webhook-url=https://hooks.slack.com/services/blablabla...