Skip to content

Commit

Permalink
chore: add unknown field tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed Jul 23, 2024
1 parent a31a1eb commit 151f7cc
Show file tree
Hide file tree
Showing 2 changed files with 300 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/FingerprintApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class FingerprintApiTest extends TestCase
protected $fingerprint_api;

const MOCK_REQUEST_ID = '1708102555327.NLOjmg';
const MOCK_REQUEST_ID_WITH_UNKNOWN = 'UNKNOWN_FIELD_REQUEST_ID';
const MOCK_EXTRA_FIELDS_REQUEST_ID = '0KSh65EnVoB85JBmloQK';
const MOCK_REQUEST_ALL_ERRORS = 'ALL_ERRORS';
const MOCK_REQUEST_EXTRA_FIELDS = 'EXTRA_FIELDS';
Expand Down Expand Up @@ -68,6 +69,9 @@ public function getEventMock($request_id)
case self::MOCK_REQUEST_EXTRA_FIELDS:
$mock_name = 'get_event_200_extra_fields.json';
break;
case self::MOCK_REQUEST_ID_WITH_UNKNOWN:
$mock_name = 'get_event_200_with_unknown_field.json';
break;
}
$events_mock_data = \GuzzleHttp\json_decode(file_get_contents(__DIR__ . "/mocks/$mock_name"));
/** @var EventResponse $serialized */
Expand Down Expand Up @@ -223,4 +227,15 @@ public function testGetVisitsRawResponse() {
$mockedResult = \GuzzleHttp\json_decode(file_get_contents(__DIR__ . "/mocks/get_visits_200_limit_500.json"));
$this->assertEquals($mockedResult, $visits->getRawResponse());
}

public function testGetEventParsedModelWithUnknownField() {
$event = $this->fingerprint_api->getEvent(self::MOCK_REQUEST_ID_WITH_UNKNOWN);
$this->assertEquals(false, $event->getProducts()->getIncognito()->getData()->getResult());
}

public function testGetUnknownFieldFromEvent() {
$event = $this->fingerprint_api->getEvent(self::MOCK_REQUEST_ID_WITH_UNKNOWN);
$decoded = $event->getRawResponse();
$this->assertEquals("field", $decoded->unknown);
}
}
285 changes: 285 additions & 0 deletions test/mocks/get_event_200_with_unknown_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"unknown": "field",
"products": {
"unknown": "field",
"identification": {
"unknown": "field",
"data": {
"unknown": "field",
"visitorId": "Ibk1527CUFmcnjLwIs4A9",
"requestId": "1708102555327.NLOjmg",
"incognito": true,
"linkedId": "somelinkedId",
"tag": {},
"time": "2019-05-21T16:40:13Z",
"timestamp": 1582299576512,
"url": "https://www.example.com/login?hope{this{works[!",
"ip": "61.127.217.15",
"ipLocation": {
"accuracyRadius": 10,
"latitude": 49.982,
"longitude": 36.2566,
"postalCode": "61202",
"timezone": "Europe/Dusseldorf",
"city": {
"name": "Dusseldorf"
},
"country": {
"code": "DE",
"name": "Germany"
},
"continent": {
"code": "EU",
"name": "Europe"
},
"subdivisions": [
{
"isoCode": "63",
"name": "North Rhine-Westphalia"
}
]
},
"browserDetails": {
"browserName": "Chrome",
"browserMajorVersion": "74",
"browserFullVersion": "74.0.3729",
"os": "Windows",
"osVersion": "7",
"device": "Other",
"userAgent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) ...."
},
"confidence": {
"score": 0.97
},
"visitorFound": false,
"firstSeenAt": {
"global": "2022-03-16T11:26:45.362Z",
"subscription": "2022-03-16T11:31:01.101Z"
},
"lastSeenAt": {
"global": null,
"subscription": null
}
}
},
"botd": {
"data": {
"bot": {
"result": "notDetected"
},
"url": "https://www.example.com/login?hope{this{works}[!",
"ip": "61.127.217.15",
"time": "2019-05-21T16:40:13Z",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 YaBrowser/24.1.0.0 Safari/537.36",
"requestId": "1708102555327.NLOjmg"
}
},
"rootApps": {
"data": {
"result": false
}
},
"emulator": {
"data": {
"result": false
}
},
"ipInfo": {
"data": {
"v4": {
"address": "94.142.239.124",
"geolocation": {
"accuracyRadius": 20,
"latitude": 50.05,
"longitude": 14.4,
"postalCode": "150 00",
"timezone": "Europe/Prague",
"city": {
"name": "Prague"
},
"country": {
"code": "CZ",
"name": "Czechia"
},
"continent": {
"code": "EU",
"name": "Europe"
},
"subdivisions": [
{
"isoCode": "10",
"name": "Hlavni mesto Praha"
}
]
},
"asn": {
"asn": "7922",
"name": "COMCAST-7922",
"network": "73.136.0.0/13"
},
"datacenter": {
"result": true,
"name": "DediPath"
}
},
"v6": {
"address": "2001:db8:3333:4444:5555:6666:7777:8888",
"geolocation": {
"accuracyRadius": 5,
"latitude": 49.982,
"longitude": 36.2566,
"postalCode": "10112",
"timezone": "Europe/Berlin",
"city": {
"name": "Berlin"
},
"country": {
"code": "DE",
"name": "Germany"
},
"continent": {
"code": "EU",
"name": "Europe"
},
"subdivisions": [
{
"isoCode": "BE",
"name": "Land Berlin"
}
]
},
"asn": {
"asn": "6805",
"name": "Telefonica Germany",
"network": "2a02:3100::/24"
},
"datacenter": {
"result": false,
"name": ""
}
}
}
},
"ipBlocklist": {
"data": {
"result": false,
"details": {
"emailSpam": false,
"attackSource": false
}
}
},
"tor": {
"data": {
"result": false
}
},
"vpn": {
"data": {
"result": false,
"originTimezone": "Europe/Berlin",
"originCountry": "unknown",
"methods": {
"timezoneMismatch": false,
"publicVPN": false,
"auxiliaryMobile": false
}
}
},
"proxy": {
"data": {
"result": false
}
},
"incognito": {
"data": {
"result": false
}
},
"tampering": {
"data": {
"result": false,
"anomalyScore": 0.1955
}
},
"clonedApp": {
"data": {
"result": false
}
},
"factoryReset": {
"data": {
"time": "1970-01-01T00:00:00Z",
"timestamp": 0
}
},
"jailbroken": {
"data": {
"result": false
}
},
"frida": {
"data": {
"result": false
}
},
"privacySettings": {
"data": {
"result": false
}
},
"virtualMachine": {
"data": {
"result": false
}
},
"rawDeviceAttributes": {
"data": {
"architecture": {
"value": 127
},
"audio": {
"value": 35.73832903057337
},
"canvas": {
"value": {
"Winding": true,
"Geometry": "4dce9d6017c3e0c052a77252f29f2b1c",
"Text": "dd2474a56ff78c1de3e7a07070ba3b7d"
}
},
"colorDepth": {
"value": 30
},
"colorGamut": {
"value": "p3"
},
"contrast": {
"value": 0
},
"cookiesEnabled": {
"value": true
},
"cpuClass": {},
"fonts": {
"value": [
"Arial Unicode MS",
"Gill Sans",
"Helvetica Neue",
"Menlo"
]
}
}
},
"highActivity": {
"data": {
"result": false
}
},
"locationSpoofing": {
"data": {
"result": false
}
}
}
}

0 comments on commit 151f7cc

Please sign in to comment.