Skip to content

Instantly share code, notes, and snippets.

@gerryster
Created November 8, 2023 16:00
Show Gist options
  • Save gerryster/66faec3abc001835c5d2eb989274ebb6 to your computer and use it in GitHub Desktop.
Save gerryster/66faec3abc001835c5d2eb989274ebb6 to your computer and use it in GitHub Desktop.
Pact Specification from the PactJS Workshop https://github.com/pact-foundation/pact-workshop-js/
{
"consumer": {
"name": "FrontendWebsite"
},
"interactions": [
{
"description": "get all products",
"providerStates": [
{
"name": "no products exist"
}
],
"request": {
"headers": {
"Authorization": "Bearer 2019-01-14T11:34:18.045Z"
},
"matchingRules": {
"header": {
"$.Authorization[0]": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
"method": "GET",
"path": "/products"
},
"response": {
"body": [],
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"status": 200
}
},
{
"description": "get product by ID 10 with no auth token",
"providerStates": [
{
"name": "product with ID 10 exists"
}
],
"request": {
"method": "GET",
"path": "/product/10"
},
"response": {
"status": 401
}
},
{
"description": "get product with ID 10",
"providerStates": [
{
"name": "product with ID 10 exists"
}
],
"request": {
"headers": {
"Authorization": "Bearer 2019-01-14T11:34:18.045Z"
},
"matchingRules": {
"header": {
"$.Authorization[0]": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
"method": "GET",
"path": "/product/10"
},
"response": {
"body": {
"id": "10",
"name": "28 Degrees",
"type": "CREDIT_CARD"
},
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
}
},
{
"description": "get product with ID 11",
"providerStates": [
{
"name": "product with ID 11 does not exist"
}
],
"request": {
"headers": {
"Authorization": "Bearer 2019-01-14T11:34:18.045Z"
},
"matchingRules": {
"header": {
"$.Authorization[0]": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
"method": "GET",
"path": "/product/11"
},
"response": {
"status": 404
}
},
{
"description": "get all products",
"providerStates": [
{
"name": "products exist"
}
],
"request": {
"method": "GET",
"path": "/products"
},
"response": {
"status": 401
}
}
],
"metadata": {
"pact-js": {
"version": "12.1.0"
},
"pactRust": {
"ffi": "0.4.9",
"models": "1.1.11"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "ProductService"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment