Skip to content

Commit

Permalink
example(e2e): fix provider verification (auth)
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Feb 23, 2019
1 parent 03cfe5c commit c33b100
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions examples/e2e/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ server.use((req, res, next) => {
server.use((req, res, next) => {
const token = req.headers["authorization"] || ""

if (token == "1234") {
console.log("ERRRR")
if (token !== "Bearer 1234") {
res.sendStatus(401).send()
} else {
next()
Expand Down
3 changes: 0 additions & 3 deletions examples/e2e/test/consumer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ describe("Pact", () => {
},
willRespondWith: {
status: 401,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
},
})
)
Expand Down
8 changes: 5 additions & 3 deletions examples/e2e/test/provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ describe("Pact Verification", () => {
req.headers["MY_SPECIAL_HEADER"] = "my special value"

// e.g. ADD Bearer token
req.headers["Authorization"] = `Bearer: ${token}`
req.headers["authorization"] = `Bearer ${token}`
next()
},

stateHandlers: {
"Has no animals": () => {
animalRepository.clear()
token = "1234"
return Promise.resolve(`Animals removed to the db`)
},
"Has some animals": () => {
token = "1234"
importData()
return Promise.resolve(`Animals added to the db`)
},
"Has an animal with ID 1": () => {
token = "1234"
importData()
return Promise.resolve(`Animals added to the db`)
},
"is authenticated": () => {
token = "generate a valid token for this state"
"is not authenticated": () => {
Promise.resolve(`Valid bearer token generated`)
},
},
Expand Down

0 comments on commit c33b100

Please sign in to comment.