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