Customisation of Mock Entity and Responses
This page explains how to use APIs to create custom mock entities for integration purposes. Additionally, responses for any scenario can be simulated by adding a custom expected response to a specific mock entity. The behavior of the created mock entities will default to the Response Simulator.
Overview:
The Response Simulator is built to handle custom entities and responses for any request, while also mimicking the behavior of real Entity Protocol APIs. It offers a controlled environment for developers to test and validate custom scenarios without depending on the default behavior of the Response Simulator.
Authorization:
All the APIs listed below require a user token for authorization. Onboarded users can generate a token using their credentials, which can then be used to create mock entities, configure custom responses, and more.
Identity & Access ManagementWe recommend to use below postman collection for quicker access
Register a new custom mock entity using user token.
Bearer <UserToken>
1.0
2024-08-28T01:58:50.505Z
1fbb-11ed-861d-0242
FIP
Successful onboarding of the entity
Bad Request due to certificate existence
Unauthorized access due to invalid token
Conflict due to entity already existing
POST /iam/v1/entity/mock/register HTTP/1.1
Host: api.sandbox.sahamati.org.in
Authorization: Bearer <UserToken>
Content-Type: application/json
Accept: */*
Content-Length: 763
{
"ver": "1.0",
"timestamp": "2024-08-28T01:58:50.505Z",
"txnid": "1fbb-11ed-861d-0242",
"type": "FIP",
"entityinfo": {
"name": "entityId_mock_FIP",
"id": "entityId_mock_FIP",
"entityhandle": "",
"Identifiers": [
{
"category": "STRONG",
"type": "MOBILE"
}
],
"baseurl": "",
"fitypes": [
""
],
"certificate": {
"alg": "RS256",
"e": "AQAB",
"kid": "4nEXdaiPFssssssIsssYsaslyf",
"kty": "RSA",
"n": "uh0fNzOYK2L2wGzixMLN-pOIHDH1tuA3rk6MmW39Q0VbAHWXmn0fZpS88hcIARmsPbbNXAW59VDCGEgPd49VVfiOeENI8PqliNml8gB1C1oGkpnAcda8O4v5kd_ZN4YZcLYqHyv9L8RnBidOzXzi-CxdgoFtM3pAnUYBERbbYi8LK5em8mBCixKuX_NszbrZiT14SY1AglNEWNPgibt3EMzGSxGyWyOgSEfsaQ4HGlppPU5lkWNx1GqktYelDxE7VQDNOGsoS1l03_JVr1oyYIA-1-M9ndq4Cjx3x9QFfaPts8MGw5yWSZCugbIeoBPzHmvlgm3CiGgqFQVrL1mJ2w",
"use": "sig"
},
"inboundports": [
""
],
"outboundports": [
""
],
"ips": [
""
]
}
}
{
"ver": "1.0.0",
"timestamp": "2024-09-25T10:01:19.942498808Z",
"txnId": "1fbb-11ed-861d-0242",
"message": "Entity successfully onboarded.",
"entity": {
"id": "test1",
"name": "test1",
"status": "ACTIVE"
}
}
Regenerate the User Token after creating the mock entity to enable access to the newly created entity.
Add a custom response simulation for a given entity, endpoint, response code, and scenario.
Bearer <user-token>
FIP-SIMULATOR
/Consent/Notification
400
FIP-SIMULATOR-400-Error
Successfully added the response simulation.
Bad request due to missing required fields.
Unauthorized due to missing or invalid authorization header.
Conflict due to an existing entity with the same endpoint and response code.
POST /simulate/v2/response/add HTTP/1.1
Host: api.sandbox.sahamati.org.in
Authorization: Bearer <user-token>
Content-Type: application/json
Accept: */*
Content-Length: 281
{
"entityId": "FIP-SIMULATOR",
"endpoint": "/Consent/Notification",
"responseCode": 400,
"response": {
"ver": "2.0.0",
"txnid": "0b811819-9044-4856-b0ee-8c88035f8858",
"timestamp": "2024-09-23T07:40:34.978Z",
"errorCode": "BadRequest",
"errorMsg": "BadRequest"
},
"scenario": "FIP-SIMULATOR-400-Error"
}
{
"version": "1.0.0",
"timestamp": "2024-09-25T06:52:19.750Z",
"entityId": "FIP-SIMULATOR",
"message": "FIP-SIMULATOR added successfully."
}
To list all the custom responses configured for the given entity
Bearer <User-Token>
FIP-SIMULATOR
Successfully retrieved response list
Bad Request - Missing required fields
Unauthorized - Missing authorization header
Not Found - No data for given entity ID
POST /simulate/v2/response/list HTTP/1.1
Host: api.sandbox.sahamati.org.in
Authorization: Bearer <User-Token>
Content-Type: application/json
Accept: */*
Content-Length: 28
{
"entityId": "FIP-SIMULATOR"
}
{
"ver": "1.0.0",
"timestamp": "2024-09-25T07:05:54.036Z",
"result": [
{
"entityId": "FIP-SIMULATOR",
"endpoint": "/Consent/Notification",
"scenario": "FIP-SIMULATOR-400-Error",
"response": {
"ver": "2.0.0",
"txnid": "0b811819-9044-4856-b0ee-8c88035f8858",
"timestamp": "2024-09-23T07:40:34.978Z",
"errorCode": "InvalidRequest",
"errorMsg": "InvalidRequest"
},
"responseCode": 400
}
]
}
Was this helpful?