Skip to content

IFS Script-A-Rest

IFS Script-A-Rest provides an easy way to script any aspect of IFS Cloud functionality using IFS Cloud RESTful APIs.

Important Capabilities

  • Create, modify and read data from IFS OData APIs
  • Use parameters in both URLs and body payloads
  • Evaluate expressions using a C# syntax
  • Call other scripts to divide larger tests into smaller units
  • Support for authentication
  • Assert values, ignore errors, and organize scripts into test cases and test suites. These are uses of Script-A-Rest for API level integration testing.

Tool is based on .NET Core 3.1 and can be run on both Windows and Linux.

Getting started

Installing prebuilt binaries

  1. Get the IFS Script-A-Rest binaries and samples from this download location and unpack it to a suitable location
  2. Run the _install.cmd file to register a Script-A-Rest context menu.
    • Edit the _test_a_rest.cmd file to use the server and credentials if you prefer any other server than default.
  3. Try a sample using the Script-A-REST Context menu

alt text

Basic Usage

Create a basic script to create one item

DockCode.md:

# Markdown content to describe what script does

```cs
Create DockCodesHandling.svc/PurchaseDockCodes
{
    "Contract": "1",
    "DockCode": "DockA",
    "Description": "Main Gate"
}

Script must be enclosed within the triple backticks.

Run the tool either by using the Script-A-REST context menu or from command line.

ScriptARest.exe ServerUrl=https://ifscloudenvironment.com Username=ifsapp Password=ifsapp FileToRead=json1.md ResultFilePath=C:\\TAR_logs

Authentication info

Edit the script_a_rest.cmd file setting the credentials you want

There is also possible to provide an external token for access using the Token argument. If a Token argument is passed, Script-A-Rest will not attempt to perform any logon procedures.

appsettings.config

Script-A-Rest has a configuration file named appsettings.config where default settings can be defined in the following way:

{
     "LogLevel": "Normal",
     "ServerUrl": "https://someserver:48080",
     "Username": "ifsapp",
     "Password": "ifsapp",
     "Token": "",
     "client_secret": "",
     "FileToRead": "someFile.md",
     "ResultFilePath": "c:\\results"
}

This makes it possible to run Script-A-Rest without any command line arguments. If command line arguments are given, they take precedence over the settings in the configuration file.

Adding the ResultFilePath parameter will generate the test result xml files and the performance json files in the specified location. Additionally, if you set PerfDetails=false it will not generate the performance json files.

The appsettings.config file should be placed in the folder where Script-A-Rest is installed.

Interactive mode

Script-A-Rest can also be run without a file input, execute in interactive mode, very similar to Oracle SQL*Plus.

Start Script-A-Rest without FileToRead parameter to enable interactive mode.

ScriptARest.exe ServerUrl=https://ifscloudenvironment.com Username=ifsapp Password=ifsapp

Log level

It's possible to control how much output Script-A-Rest should produce using the LogLevel parameter.

These are the supported log levels:

  • normal (default)
  • info
  • diag
  • debug

Here is how you set the log level to Debug:

ScriptARest.exe ServerUrl=https://ifscloudenvironment.com Username=ifsapp Password=ifsapp FileToRead=MyTest.md ResultFilePath=C:\\TAR_logs LogLevel=Debug

Command reference and documentation

Read more about all features in Script-A-Rest here in the Commands Reference.

Sample output

IFS Script-A-Rest v 1.2.0.35
======================================

2019-10-31 13:23:59 Start
2019-10-31 13:23:59 2WoRLZV7HT
2019-10-31 13:24:00 Login OK: IFSSESSIONID48080=5FQhxcVAATxXQxuSxBF2REe_hjmXVH6IJAUZXRLeV6j7TR9XPaz_!-200659304; _WL_AUTHCOOKIE_IFSSESSIONID48080=2Nqll4..IXqn0DQcyKCy
Number of Code blocks found in file: 1
2019-10-31 13:24:00 Command:  Post DockCodesHandling.svc/PurchaseDockCodes
2019-10-31 13:24:00 Request body:
{
        "Contract": "1",
        "DockCode": "DockA",
        "Description": "Main Gate"
}

2019-10-31 13:24:00 Result (201) Created
2019-10-31 13:24:00 Response
{"@odata.context":"https://ifscloudenvironment.com:48080/main/ifsapplications/projection/v1/DockCodesHandling.svc/$metadata#PurchaseDockCodes/$entity","@odata.etag":"W/\"Vy8iQUFDSU1HQUFGQUFCcElIQUFBOjIwMTkxMDMxMTMyNDAwIg==\"","luname":"PurchaseDockCode","keyref":"CONTRACT=1^DOCK_CODE=DockA^","Objgrants":null,"Contract":"1","DockCode":"DockA","Description":"Main Gate"}
2019-10-31 13:24:00 Timings  time to first response: 165 ms. Time to response complete 165 ms.
2019-10-31 13:24:00 End