我想使用pact測試來驗證提供者是否可以在響應中提供圖片。現在實際的響應看起來像這樣 server response body which contains the picture如何驗證映像中包含的響應通過協議測試
我的契約JSON文件看起來像這樣
"interactions": [
{
"providerState": "there's a user has a portrait tiger.png",
"description": "Get the user's portrait",
"request": {
"method": "GET",
"path": "/api/Employees/v1/Employee/106656048406528/Attachments",
"headers": {
"Content-Type": "application/json",
"X-Employee-ID": "106656048406528",
"X-Tenant-ID": "26663977872256",
"X-User-ID": "1333"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "image/jpeg;charset=UTF-8"
},
"body": "iVBORw0KGgoAAAANSU",
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
}
],
的協議測試總是失敗,並說身體不匹配。我可以理解實際的響應不是base64格式,也不是字符串。它應該有一些二進制文件。在這種情況下,如何編寫匹配規則來驗證它是二進制文件?
您正在使用哪種語言? JVM,Ruby,JS ...? –