snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
70
test/e2e/cypress/helpers/webhook.ts
Normal file
70
test/e2e/cypress/helpers/webhook.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright © 2023 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { fail } from "assert"
|
||||
import { gen } from "."
|
||||
|
||||
const WEBHOOK_TARGET = "https://webhook-target-gsmwn5ab4a-uc.a.run.app"
|
||||
const documentUrl = (key: string) => `${WEBHOOK_TARGET}/documents/${key}`
|
||||
const jsonnet = Buffer.from("function(ctx) ctx").toString("base64")
|
||||
|
||||
export const testFlowWebhook = (
|
||||
configSetup: (
|
||||
hooks: Array<{ hook: string; config?: any }>,
|
||||
) => Cypress.Chainable<void>,
|
||||
act: () => Cypress.Chainable<void> | void,
|
||||
) => {
|
||||
const documentID = gen.password()
|
||||
configSetup([
|
||||
{
|
||||
hook: "web_hook",
|
||||
config: {
|
||||
body: "base64://" + jsonnet,
|
||||
url: documentUrl(documentID),
|
||||
method: "PUT",
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const transient_payload = {
|
||||
stuff: {
|
||||
blub: [42, 3.14152],
|
||||
fu: "bar",
|
||||
},
|
||||
consent: true,
|
||||
}
|
||||
cy.intercept(
|
||||
"POST",
|
||||
/.*\/self-service\/(registration|login|recovery|verification|settings).*/,
|
||||
(req) => {
|
||||
switch (typeof req.body) {
|
||||
case "string":
|
||||
req.body =
|
||||
req.body +
|
||||
"&transient_payload=" +
|
||||
encodeURIComponent(JSON.stringify(transient_payload))
|
||||
break
|
||||
case "object":
|
||||
req.body = {
|
||||
...req.body,
|
||||
transient_payload,
|
||||
}
|
||||
break
|
||||
|
||||
default:
|
||||
fail()
|
||||
break
|
||||
}
|
||||
req.continue()
|
||||
},
|
||||
)
|
||||
|
||||
act()
|
||||
|
||||
cy.request(documentUrl(documentID)).then(({ body, status }) => {
|
||||
const b = JSON.parse(body)
|
||||
expect(status).to.equal(200)
|
||||
expect(b.identity).is.not.undefined
|
||||
expect(b.flow.transient_payload).to.deep.equal(transient_payload)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user