The Service Library can be used to add definitions of services that can be reused in Test Cases to hide the technical complexity from testing engineers. A service has a name and a list of input and output parameters.
Currently, there is one service subtype, Web Call. It can be used to invoke any HTTP/HTTPS-based data exchange interface, such as:
- REST
- WebService
- Any HTTP/HTTPS based endpoint
The services can be embedded in Voice Test Cases to invoke actions such as setup of data or validation during execution.
- From the main menu on the Cyara Portal, click
This screen displays a folder view that displays the folder structure. The Service Library folder is the default root folder and cannot be deleted or renamed.
. The Service Librarty page displays all the Services that are
created: - To create a new folder under the root folder, right-click the Service Library folder and click New . A new folder is created with the default name New Folder.
- Click a particular folder to view the Services. The Service List appears in the Service Library view on the right panel.
- To search for existing Services, enter the search string in the Search box and select the Search button. Use the Reset button to restore the unfiltered list of Service Libraries.
Using OAuth2 Authentication for a Service
Many services use an API gateway with a range of authentication methods, OAuth2 being one of the most popular types. OAuth2 has several grant types, currently Cyara supports the Client Credentials grant type. The graphic below demonstrates how Cyara sends a provided ClientID and Secret to an Access Token URL to retrieve the access token. Service Libraries do not retain any authentication tokens for future requests, each time the Service Library is used the token will be re-requested. This token will be then sent to the service via the service API, using this access token for authentication.
To setup OAuth2 Authentication for a service, follow the steps below.
- Click on Tools and Service Library from the nop navigation menu
- Either click on an existing service or create a new service with the New Service button.
- In the Input Parameters section, enter the URL to call in the
External Service field and set the API call type.
- Additional Input Parameters can be added using the table below the External Service URL field.
- In the Authentication section, select OAuth2
- Enter the following information
- Access Token URL - This is the URL of the authorization server to exchange the authorization code.
- Client ID - The client ID used in the registration process to obtain the authorization code.
- Client Secret - The secret that matches the above Client ID to obtain the authorization code.
- Scope - an optional comma separated list of values to set the scope of access required.
- Client Authentication - Select Basic Auth, to have the authentication token sent back as a base64 string in the header response, while selecting Body will supply the authentication token in the body response.
Creating a Web Call Service
The Web Call service can be used to perform any HTTP-based operation, such as:
- Updating data via REST
- Invoking a predefined WebService call
- Calling raw HTTP endpoint
- From the main menu select . A service management page is displayed.
- Click New Service, and a
screen as shown below appears:
- Enter a unique Name for the Service.
- Enter a description of the Service Library in the Description field.
- Browse and select the Folder Path where the Service is to be stored.
- Scroll down and in the Input
Parameter section, enter External Service
URL.
- The URL must be a valid HTTP/HTTPS address
- A protocol prefix such as
http://
must be included - If the URL requires
parameters, use the
$variable
syntax to add them
Note: Variable name must begin with an alphabet and can contain alphabets, numbers, and underscore (“_”) character. - In the drop-down, choose the HTTP
method. The following methods are supported:
- POST: request body can be populated as well
- PUT: request body can be populated as well
- GET
- DELETE
- Enter the input parameters you want
to pass to the service
- Name of the parameter:
alphanumeric without spaces. The parameter can be referred from the
URL or body by prefixing it with a dollar sign. For example,
$AccountID
- Description: to clarify the details
- Default Value: a default value to use
- Name of the parameter:
alphanumeric without spaces. The parameter can be referred from the
URL or body by prefixing it with a dollar sign. For example,
- If the URL is secured, check the
Use Authentication checkbox and enter the
Username and Password
Note: Currently, HTTP Basic authentication is supported
-
If the POST or PUT methods are used for the service call, specify the request body
- Choose request content type: JSON, XML, or x-www-form-urlencoded
- Enter the content to submit in the editor
- If your endpoint uses the x-www-form-urlencoded content type, submit the content in the format: key1=value1&key2=value2&keyn=valuen
- In the output parameter table,
enter the values to extract from the response. Use the Run
Now function to test the configuration.
- Enter the Name of the output parameter. The name must be alphanumeric without spaces.
- Add a Description if clarification is required
- Define the path to extract
the value from the response
- If the content type
is XML, use an XML Path statement. XML Path specification:
https://www.w3.org/TR/1999/REC-xpath-19991116/
- If the content type
is JSON, use a JSONPath statement. JSONPath specification:
https://goessner.net/articles/JsonPath/
- The path can point to a single or multiple value in the HTTP response body. Currently only Virtual Agent supports processing of multiple values. For Test Case steps the service must point to a single value.
- If the content type
is XML, use an XML Path statement. XML Path specification:
Validating a Service
- To verify the service
configuration, click the
Run Now button.
- In the dialog, enter the input parameter values and click Run Now within the modal dialog.
- Wait for the operation
to complete. Note that some services may take several seconds to execute.
- This will invoke the service by passing in the input parameters and extracting the output ones
- The response body will be populated and the correct content type, XML or JSON, will be selected
Editing a Service
- From the main menu on the Cyara Portal, select
ToolboxService Library to
view all the Service Libraries:
- To edit an existing Service, click the Service name. The steps from here are similar to the details mentioned under Creating a Web Call Service
Moving or Copying a Service
- To select the Services, click Select
Visible or use the checkboxes to select the required Service
Libraries. To select all Service Libraries displayed on the screen, click
the Select All button from the Service
Library page.
- To move the selected Services, select Action and click Move.
- On the Select Folder pop-up
menu, select the destination folder and click Choose.
All the selected Services will be moved to the destination folder.
Copying Services
- To copy, select the Service/s, select Action, and then click the Copy button.
You can also create a new destination folder to copy the Services in the folder tree on the left.
Deleting Services
Services can either be deleted individually or by selecting a group to delete.
- To delete an individual Service, select the
checkbox against the Service, then select Actions, then
click Delete.
ORYou can click the three dots at the end of the row of the individual Service and clickDelete.
- To delete multiple Services, use the Select All button.
- To select the visible Services on the page, use the Select Visible button. To clear selections, use the Clear Selection button.
- To delete all the selected Services, select Actions and then click the Delete button.
Example to Create a Web Call Service
- To create a new Service, click the New Service button in the top right corner of the Service Library page.
- Enter the General Details.
- Give the Service a name “Get User Name”.
- Add a description “Get name of the first user”.
- If a specific folder is desired to organize the Services, use the Folder Path Browse button to choose one.
- Fill out the
Input Parameter section to describe what
should be passed in to the Service.
- Enter the
https://reqres.in/api/users?page=$Page
URL in the
External Service field and select the
GET
method in the drop-down. - In the parameter table below, click in the Name column and enter the input variable name “Page”.
- Press Tab to navigate to the Default Values field and set the default value to 1.
- Press Enter to finish editing the row. You can also use mouse-click outside of the table to finish editing.
- Leave the authentication section empty as the Service does not require credentials.
- The above steps create
a Service URL with a Page parameter. When the Service will be executed, the
$Page will be substituted with a value. For example:
- Enter the
https://reqres.in/api/users?page=$Page
URL in the
External Service field and select the
- To perform a Service test
run:
- Select the Run Now button to perform a test run.
- The dialog will ask for parameters with the default one set to “1”.
- Click the Run Now button to execute.
- The Body section will be populated with the Service response.
- Above the body Service run date, the status and duration will be displayed.
- Configure the Service
Output Parameter section:
- Click in the Name column of the output parameter table and enter “FirstName” as the name.
- Press Tab and enter the Description.
- Press
Tab again and enter the
JSONPath
statement: “$..data[0].first_name
”. The statement will extract the first user's name from the JSON structure in the body of the Service output. - Press Enter to finish
editing the row. You will notice that the Values Returned column
gets populated with “George” — the name of
the first user. This read-only column is helpful when specifying
statements to load values from the service output.
- Click Save to store the Service and include it in a Voice Test Case of your choice.
Example to Create a Service to Load Avaya Attached Data
In this example, we create a Service to retrieve attached data collection from a REST endpoint. The endpoint will not be secured and will not require authentication.
Sample URL:
http://www.mocky.io/v2/5c5301bc320000bd4d855f45
Query parameter: uui
{
"customer_id ": "A1122241 ",
"CRM_id ": "24444512 ",
"ActiveOrders ": 2,
"Claims ": 1
}
- To create a new Service, click the New Service button in the top right corner of the Service Library page.
- Enter the
General Details.
- Give the Service a
name “
Get Attached Data
”. - Add a description
“
Get attached data from back-end by UUI
”. - If a specific folder is desired to organize the Services, use the Folder Path Browse button to choose one.
- Give the Service a
name “
- Fill out the
Input Parameter section to describe what
should be passed in to the Service.
- Enter the
http://www.mocky.io/v2/5c5301bc320000bd4d855f45?uui=$UUI
URL in the External Service field and select theGET
method in the drop-down. - In the parameter
table below, click in the
Name column and enter the input
variable name “
UUI
”. - Press tab to navigate to the Default Values field and set the default value to 1.
- Press
Enter to finish editing the row. You
can also use
mouse-click
outside of the table to finish editing. - Leave the authentication section empty as the Service does not require credentials
- The above steps
create a Service URL with “
UUI
” parameter. When the Service will be executed, the$UUI
will be substituted with a value.
- Enter the
- To perform a Service
test run:
- Select the Run Now button to perform a test run.
- The dialog will ask for parameters; enter a known UUI value to test the Service.
- Click the Run Now button to execute.
- The Body section will be populated with the Service response.
- Above the body Service run date, the status and duration will be displayed.
- Configure the Service
Output Parameter section:
- Click in the Name column of the output parameter table and enter “AttachedData” as the name.
- Press Tab and enter the Description.
- Press
Tab again and enter the
JSONPath
statement: "$
". The statement will extract a full response from the JSON structure in the body of the Service output. - Press Enter to finish
editing the row. You will notice that the Values Returned column
gets populated with a label “Multiple
Values”. Click on it and it will display a popup
window with the variables. This read-only column is helpful when
specifying statements to load values from the Service output.
- Click the multiplevalues
values in the Values Returned column to
inspect the output.
- Click Save to store the
Service and include it in a Voice Test Case of your choice.
This Service can be used in a Virtual Agent Behavior to load additional attached data by a call identifier. For example, it can be used in an Avaya vendor Behavior to load more data for a UUI attached data attribute as the only key in CTI is
Interaction.UserData.UUI
.
Comments
0 comments
Please sign in to leave a comment.