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 Management

We recommend to use below postman collection for quicker access

Create Mock Entity

post

Register a new custom mock entity using user token.

Header parameters
AuthorizationstringRequiredExample: Bearer <UserToken>
Body
verstringRequiredExample: 1.0
timestampstring · date-timeRequiredExample: 2024-08-28T01:58:50.505Z
txnidstringRequiredExample: 1fbb-11ed-861d-0242
typestringRequiredExample: FIP
Responses
200
Successful onboarding of the entity
application/json
post
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.

Configure a custom response for a mock entity

post

Add a custom response simulation for a given entity, endpoint, response code, and scenario.

Authorizations
Header parameters
AuthorizationstringRequiredExample: Bearer <user-token>
Body
entityIdstringRequiredExample: FIP-SIMULATOR
endpointstringRequiredExample: /Consent/Notification
responseCodeintegerRequiredExample: 400
scenariostringRequiredExample: FIP-SIMULATOR-400-Error
Responses
200
Successfully added the response simulation.
application/json
post
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."
}

List all configured responses

post

To list all the custom responses configured for the given entity

Authorizations
Header parameters
AuthorizationstringRequiredExample: Bearer <User-Token>
Body
entityIdstringRequiredExample: FIP-SIMULATOR
Responses
200
Successfully retrieved response list
application/json
post
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?