mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:53:13 +00:00
fix integration tests
This commit is contained in:
@@ -1,96 +1,46 @@
|
||||
import { addStub, removeStub } from "../support/mock";
|
||||
|
||||
describe("/passkey/login", () => {
|
||||
it("should redirect a user with password authentication to /password", () => {
|
||||
beforeEach(() => {
|
||||
removeStub("zitadel.session.v2alpha.SessionService", "CreateSession");
|
||||
addStub("zitadel.session.v2alpha.SessionService", "CreateSession", {
|
||||
details: {
|
||||
sequence: 859,
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
resourceOwner: "220516472055706145",
|
||||
data: {
|
||||
details: {
|
||||
sequence: 859,
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
resourceOwner: "220516472055706145",
|
||||
},
|
||||
sessionId: "221394658884845598",
|
||||
sessionToken:
|
||||
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||
challenges: undefined,
|
||||
},
|
||||
sessionId: "221394658884845598",
|
||||
sessionToken:
|
||||
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||
challenges: undefined,
|
||||
});
|
||||
|
||||
removeStub("zitadel.session.v2alpha.SessionService", "GetSession");
|
||||
addStub("zitadel.session.v2alpha.SessionService", "GetSession", {
|
||||
session: {
|
||||
id: "221394658884845598",
|
||||
creationDate: "2023-07-04T07:58:20.026Z",
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
sequence: 859,
|
||||
factors: {
|
||||
user: {
|
||||
id: "123",
|
||||
loginName: "zitadel-admin@zitadel.localhost",
|
||||
data: {
|
||||
session: {
|
||||
id: "221394658884845598",
|
||||
creationDate: "2023-07-04T07:58:20.026Z",
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
sequence: 859,
|
||||
factors: {
|
||||
user: {
|
||||
id: "123",
|
||||
loginName: "john@zitadel.com",
|
||||
},
|
||||
password: undefined,
|
||||
passkey: undefined,
|
||||
intent: undefined,
|
||||
},
|
||||
password: undefined,
|
||||
passkey: undefined,
|
||||
intent: undefined,
|
||||
metadata: {},
|
||||
domain: "localhost",
|
||||
},
|
||||
metadata: {},
|
||||
domain: "localhost",
|
||||
},
|
||||
});
|
||||
|
||||
removeStub(
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes"
|
||||
);
|
||||
addStub(
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes",
|
||||
{
|
||||
authMethodTypes: [1], // 1 for password authentication
|
||||
}
|
||||
);
|
||||
|
||||
cy.visit(
|
||||
"/loginname?loginName=zitadel-admin%40zitadel.localhost&submit=true"
|
||||
);
|
||||
cy.location("pathname", { timeout: 10_000 }).should(
|
||||
"eq",
|
||||
"/password?loginName=zitadel-admin%40zitadel.localhost&promptPasswordless=true"
|
||||
);
|
||||
});
|
||||
it("should redirect a user with passwordless authentication to /passkey/login", () => {
|
||||
removeStub("zitadel.session.v2alpha.SessionService", "CreateSession");
|
||||
addStub("zitadel.session.v2alpha.SessionService", "CreateSession", {
|
||||
details: {
|
||||
sequence: 859,
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
resourceOwner: "220516472055706145",
|
||||
},
|
||||
sessionId: "221394658884845598",
|
||||
sessionToken:
|
||||
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||
challenges: undefined,
|
||||
});
|
||||
|
||||
removeStub("zitadel.session.v2alpha.SessionService", "GetSession");
|
||||
addStub("zitadel.session.v2alpha.SessionService", "GetSession", {
|
||||
session: {
|
||||
id: "221394658884845598",
|
||||
creationDate: "2023-07-04T07:58:20.026Z",
|
||||
changeDate: "2023-07-04T07:58:20.126Z",
|
||||
sequence: 859,
|
||||
factors: {
|
||||
user: {
|
||||
id: "123",
|
||||
loginName: "johndoe@zitadel.com",
|
||||
},
|
||||
password: undefined,
|
||||
passkey: undefined,
|
||||
intent: undefined,
|
||||
},
|
||||
metadata: {},
|
||||
domain: "localhost",
|
||||
},
|
||||
});
|
||||
|
||||
it("should redirect a user with password authentication to /password", () => {
|
||||
removeStub(
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes"
|
||||
@@ -99,15 +49,32 @@ describe("/passkey/login", () => {
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes",
|
||||
{
|
||||
authMethodTypes: [2], // 2 for passwordless authentication
|
||||
data: {
|
||||
authMethodTypes: [1], // 1 for password authentication
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
cy.visit("/loginname?loginName=johndoe%40zitadel.com&submit=true");
|
||||
cy.location("pathname", { timeout: 10_000 }).should(
|
||||
"eq",
|
||||
"/passkey/login?loginName=zitadel-admin%40zitadel.localhost"
|
||||
cy.location("pathname", { timeout: 10_000 }).should("eq", "/password");
|
||||
});
|
||||
it("should redirect a user with passwordless authentication to /passkey/login", () => {
|
||||
removeStub(
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes"
|
||||
);
|
||||
addStub(
|
||||
"zitadel.user.v2alpha.UserService",
|
||||
"ListAuthenticationMethodTypes",
|
||||
{
|
||||
data: {
|
||||
authMethodTypes: [2], // 2 for passwordless authentication
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
cy.visit("/loginname?loginName=johndoe%40zitadel.com&submit=true");
|
||||
cy.location("pathname", { timeout: 10_000 }).should("eq", "/passkey/login");
|
||||
});
|
||||
|
||||
// it("should prompt a user to setup passwordless authentication if passkey is allowed in the login settings", () => {
|
||||
|
||||
@@ -3,8 +3,8 @@ export function removeStub(service: string, method: string) {
|
||||
url: "http://localhost:22220/v1/stubs",
|
||||
method: "DELETE",
|
||||
qs: {
|
||||
service: service,
|
||||
method: method,
|
||||
service,
|
||||
method,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -16,9 +16,9 @@ export function addStub(service: string, method: string, out?: any) {
|
||||
body: {
|
||||
stubs: [
|
||||
{
|
||||
service: service,
|
||||
method: method,
|
||||
out: out,
|
||||
service,
|
||||
method,
|
||||
out,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user