# Testing
source: https://developer.mastercard.com/identity-insights-for-accounts/documentation/testing/index.md

This section provides the testing guides for your API integration in the sandbox environment.

## Test Cases {#test-cases}

This tutorial explains different test cases to verify positive and negative scenarios for the Identity Insights for Accounts API endpoints.  

| **Test Case ID** |        **Test Type**         |       **Test Type Details**        |   **Input**   | **Output** |                                   **Test Success Criteria**                                   |
|------------------|------------------------------|------------------------------------|---------------|------------|-----------------------------------------------------------------------------------------------|
| 1                | Customer input validation    | User account, device IP            | Customer Data | Variable   | All inputs are correctly formatted, 200 response is returned and match customer expectations. |
| 2                | Customer input validation    | User account, no device parameters | Customer Data | Variable   | All inputs are correctly formatted, 200 response is returned and match customer expectations. |
| 3                | Simulating 400 client errors | No user or device IP               | Customer Data | Variable   | Provided data input returns expected output, simulating the desired error message.            |

## Use Case Fields {#use-case-fields}

{#fnref:1}

| **Input Field** |                                                **Required?**                                                | **Format** |                          **Sample Request**                           |
|-----------------|-------------------------------------------------------------------------------------------------------------|------------|-----------------------------------------------------------------------|
| device:ip       | Y^[1](https://developer.mastercard.com/identity-insights-for-accounts/documentation/testing/index.md#fn:1)^ | string     | ipv4: '198.51.100.42' ipv6: '2001:0db8:5b96:0000:0000:426f:8e17:642a' |

## Sample Requests and Responses {#sample-requests-and-responses}

The following are the sample request, and responses for the Test cases validations for both positive and negative test scenarios.

Pre-requisites: Refer to the [Identity Insights for Accounts at Account Opening](https://developer.mastercard.com/identity-insights-for-accounts/documentation/use-cases/use-cases-1/index.md) details.  
The endpoint allows the client to obtain insights for a valid Account Opening request.

**Request**

```java
{
  "device":{
  "ip":"198.51.100.42"
  },
  "user":{
  "account":{
  "hashedAccountId":"3b5ed8ad6a408f42015254dd4b116080289038d41c311332e3c00be60f884370",
  "signupTime":"2000-01-23T04:56:07.000+00:00"
  },
  "name":"Waidong L Syrws",
  "email":"john.smith@mastercard.com",
  "phone":{
  "countryHint":"US",
  "number":"3143978691"
  },
  "address":{
  "streetLine1":"912 Uclan Dr",
  "streetLine2":"Apt 32",
  "city":"Houston",
  "state":"TX",
  "postalCode":"63124",
  "country":"US"
  }
  },
  "endCustomerRefId":1212
  }
```

**Response**

```java
{
  "requestRefId":"ac0f3eb9-055d-4b8e-86cf-273e820331e4",
  "insights":{
  "user":{
  "scores":{
  "identityRisk":372,
  "reasonCode":"RG"
  },
  "details":{
  "email":{
  "valid":true,
  "firstSeenDays":0,
  "mailboxVelocity":0,
  "isDisposable":false,
  "emailRiskScore":0.642,
  "matchToName":"NOT_FOUND"
  },
  "phone":{
  "valid":true,
  "lineType":"MOBILE",
  "carrier":"T-Mobile USA",
  "countryCode":"US",
  "lastSeenDays":0,
  "emailFirstSeenDays":0,
  "matchToName":"NO_MATCH"
  },
  "address":{
  "validityLevel":"VALID_TO_COUNTRY"
  }
  }
  },
  "ip":{
  "scores":{
  "ipRisk":0.017
  },
  "details":{
  "risk":false,
  "lastSeenDays":0,
  "phoneDistance":6234,
  "providerDetails": {
  "country": "australia",
  "ipCarrier": "cloudflare",
  "city": "melbourne",
  "state": "victoria"
  }
  }
  },
  "device":{
  "score":{

  },
  "details":{

  }
  }
  }
  }
```

The endpoint allows the client to obtain insights for a valid Account Opening request.

**Request**

```java
{
  "device":{
  "ip":"2001:0db8:5b96:0000:0000:426f:8e17:642a",
  "userAgent":"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  "plugins":[
  "Adobe Acrobat",
  "QuickTime"
  ],
  "webGl":"wg1-ce04533340ea94cf",
  "timeZone":600,
  "screenWidth":"1792",
  "screenHeight":"828",
  "localStorage":true,
  "language":"zh-TW",
  "colorDepth":24,
  "cookiesEnabled":true,
  "placement":"Registration",
  "androidBuildVersion":"12",
  "androidSdkInt":"31",
  "buildFingerprint":"samsung/a32xsq/a32x:12/SP1A.210812.016/A326USQS7BVF2:user/release-keys",
  "buildManufacturer":"Apple",
  "buildBrand":"Apple",
  "supportedFeatures":[
  "mhac",
  "mhtse",
  "mhcdma",
  "mhgy"
  ],
  "model":"iPhone",
  "sdkUserAgent":"14.3.1.7",
  "majorOsVersion":12,
  "minorOsVersion":0,
  "simCountryIso":"us",
  "simOperator":"T-Mobile",
  "primaryStorage":117027876864,
  "systemMemory":5847543808,
  "buildProduct":"beyond0qltesq",
  "vendorAppId":"64BAA4F0-9EBC-713E-5B5B-2AF40AB4123A",
  "storedDeviceId":"wyett276tuygey6r",
  "androidId":"38400000-8cf0-11bd-b23e-10b96e40000d"
  },
  "user":{
  "account":{
  "hashedAccountId":"3b5ed8ad6a408f42015254dd4b116080289038d41c311332e3c00be60f884370",
  "signupTime":"2020-12-31 13:45"
  },
  "name":"John Smith",
  "email":"john.smith@mastercard.com",
  "phone":{
  "countryHint":"US",
  "number":"7785732875"
  },
  "address":{
  "streetLine1":"912 Uclan Dr",
  "streetLine2":"Apt 32",
  "city":"Houston",
  "state":"tx",
  "postalCode":"63124"
  }
  },
  "endCustomerRefId":"12345"
  }
```

**Response**

```java
{
  "requestRefId":"d8b0db28-96b7-420d-9451-c12d4ac2fb94",
  "insights":{
  "user":{
  "scores":{
  "identityRisk":269,
  "reasonCode":"RB"
  },
  "details":{
  "email":{
  "valid":true,
  "firstSeenDays":576,
  "mailboxVelocity":0,
  "isDisposable":false,
  "emailRiskScore":0.241,
  "matchToName":"NOT_FOUND"
  },
  "phone":{
  "valid":true,
  "lineType":"LANDLINE",
  "carrier":"Navigata Communications Limited",
  "countryCode":"CA",
  "lastSeenDays":0,
  "emailFirstSeenDays":0,
  "matchToName":"NOT_FOUND"
  },
  "address":{
  "validityLevel":"INVALID"
  }
  }
  },
  "ip":{
  "scores":{
  "ipRisk":0.427
  },
  "details":{
  "risk":false,
  "lastSeenDays":35,
  "geolocationCountryCode":"US",
  "geolocationSubdivision":"Oregon",
  "phoneDistance":200,
  "addressDistance":210,
  "providerDetails": {
  "country": "australia",
  "ipCarrier": "cloudflare",
  "city": "melbourne",
  "state": "victoria"
  },
  "isProxy":true,
  "proxyRiskClass":"low"
  }
  },
  "device":{
  "score":{
  "deviceRisk":0.997
  },
  "details":{
  "browser":"IE",
  "platform":"Windows",
  "deviceType":"Other",
  "deviceBrowserIpTzDifference":600,
  "deviceIpEmailFirstSeen":0,
  "devicePhoneEmailFirstSeen":0
  }
  }
  }
  }
```

The endpoint allows the client to obtain insights for an account opening request, even without Device Input.

**Request**

```java
{
  "user":{
  "account":{
  "hashedAccountId":"3b5ed8ad6a408f42015254dd4b116080289038d41c311332e3c00be60f884370",
  "signupTime":"2000-01-23T04:56:07.000+00:00"
  },
  "name":"Waidong L Syrws",
  "email":"john.smith@mastercard.com",
  "phone":{
  "countryHint":"US",
  "number":"3143978691"
  },
  "address":{
  "streetLine1":"912 Uclan Dr",
  "streetLine2":"Apt 32",
  "city":"Houston",
  "state":"TX",
  "postalCode":"63124",
  "country":"US"
  }
  },
  "endCustomerRefId":1212
  }
```

**Response**

```java
{
  "requestRefId":"c9cf545c-1241-48ee-b8a4-987757df00ce",
  "insights":{
  "user":{
  "scores":{
  "identityRisk":392,
  "reasonCode":"RP"
  },
  "details":{
  "email":{
  "valid":true,
  "firstSeenDays":0,
  "mailboxVelocity":0,
  "isDisposable":false,
  "emailRiskScore":0.642,
  "matchToName":"NOT_FOUND"
  },
  "phone":{
  "valid":true,
  "lineType":"MOBILE",
  "carrier":"T-Mobile USA",
  "countryCode":"US",
  "lastSeenDays":0,
  "emailFirstSeenDays":0,
  "matchToName":"NO_MATCH"
  },
  "address":{
  "validityLevel":"VALID_TO_COUNTRY"
  }
  }
  },
  "ip":{
  "alerts":[
  "Unable to generate IP Insights"
  ]
  },
  "device":{
  "alerts":[
  "Unable to generate device Insights"
  ]
  }
  }
  }
```

The endpoint returns an error to the client for attempting to obtain insights for an account opening request missing all required fields.

**Request**

```java
{
  "device":{
  "ip":null
  },
  "user":{
  "account":{
  "hashedAccountId":null,
  "signupTime":null
  },
  "name":null,
  "email":null,
  "phone":{
  "countryHint":null,
  "number":null
  },
  "address":{
  "streetLine1":null,
  "streetLine2":null,
  "city":null,
  "state":null,
  "postalCode":null,
  "country":null
  }
  },
  "endCustomerRefId":1212
  }
```

**Response**

```java
{
  "Errors":{
  "Error":[
  {
  "Source":"IIA",
  "ReasonCode":"VALIDATION_ERROR",
  "Description":"Hashed Account ID is required",
  "Recoverable":false,
  "Details":"user.account.hashedAccountId"
  }
  ]
  }
  }
```

The endpoint returns an error to the client for attempting to obtain insights for an account opening request missing Device IP. If one or more optional device field values are provided, then an IP value and a UserAgent value must both be provided to obtain Device Insights.

**Request**

```java
{
  "device":{
  "ip":""
  },
  "user":{
  "account":{
  "hashedAccountId":"john.smith",
  "signupTime":"2000-01-23T04:56:07.000+00:00"
  },
  "name":"Waidong L Syrws",
  "email":"john.smith@mastercard.com",
  "phone":{
  "countryHint":"US",
  "number":"3143978691"
  },
  "address":{
  "streetLine1":"912 Uclan Dr",
  "streetLine2":"Apt 32",
  "city":"Houston",
  "state":"TX",
  "postalCode":"63124",
  "country":"US"
  }
  },
  "endCustomerRefId":null
  }
```

**Response**

```java
{
  "Errors":{
  "Error":[
  {
  "Source":"IIA",
  "ReasonCode":"Invalid Format",
  "Description":"device.ip: must be valid ipv4 or ipv6 address",
  "Recoverable":false,
  "Details":"device.ip"
  }
  ]
  }
  }
```

*** ** * ** ***

1. If only Device IP has a value, will only return IP insights.  
   [↩︎](https://developer.mastercard.com/identity-insights-for-accounts/documentation/testing/index.md#fnref:1)

   {#fn:1}
{#fn:1}
