mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 14:54:33 +00:00
restructure tests
This commit is contained in:
@@ -39,77 +39,99 @@ describe("login", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
|
||||||
it("should redirect a user with password authentication to /password", () => {
|
|
||||||
removeStub(
|
|
||||||
"zitadel.user.v2alpha.UserService",
|
|
||||||
"ListAuthenticationMethodTypes"
|
|
||||||
);
|
|
||||||
addStub(
|
|
||||||
"zitadel.user.v2alpha.UserService",
|
|
||||||
"ListAuthenticationMethodTypes",
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
authMethodTypes: [1], // 1 for password authentication
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.visit("/loginname?loginName=johndoe%40zitadel.com&submit=true");
|
removeStub("zitadel.settings.v2alpha.SessionService", "GetLoginSettings");
|
||||||
cy.location("pathname", { timeout: 10_000 }).should("eq", "/password");
|
addStub("zitadel.settings.v2alpha.SettingsService", "GetLoginSettings", {
|
||||||
});
|
|
||||||
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", () => {
|
|
||||||
removeStub(
|
|
||||||
"zitadel.user.v2alpha.UserService",
|
|
||||||
"ListAuthenticationMethodTypes"
|
|
||||||
);
|
|
||||||
addStub(
|
|
||||||
"zitadel.user.v2alpha.UserService",
|
|
||||||
"ListAuthenticationMethodTypes",
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
authMethodTypes: [1], // 1 for password authentication
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
removeStub("zitadel.session.v2alpha.SessionService", "SetSession");
|
|
||||||
addStub("zitadel.session.v2alpha.SessionService", "SetSession", {
|
|
||||||
data: {
|
data: {
|
||||||
details: {
|
settings: {
|
||||||
sequence: 859,
|
passkeysType: 1,
|
||||||
changeDate: "2023-07-04T07:58:20.126Z",
|
|
||||||
resourceOwner: "220516472055706145",
|
|
||||||
},
|
},
|
||||||
sessionToken:
|
|
||||||
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
|
||||||
challenges: undefined,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
describe("password login", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
removeStub(
|
||||||
|
"zitadel.user.v2alpha.UserService",
|
||||||
|
"ListAuthenticationMethodTypes"
|
||||||
|
);
|
||||||
|
addStub(
|
||||||
|
"zitadel.user.v2alpha.UserService",
|
||||||
|
"ListAuthenticationMethodTypes",
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
authMethodTypes: [1], // 1 for password authentication
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("should redirect a user with password authentication to /password", () => {
|
||||||
|
cy.visit("/loginname?loginName=johndoe%40zitadel.com&submit=true");
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should("eq", "/password");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
cy.visit("/loginname?loginName=john%40zitadel.com&submit=true");
|
describe("passkey login", () => {
|
||||||
cy.location("pathname", { timeout: 10_000 }).should("eq", "/password");
|
beforeEach(() => {
|
||||||
cy.get('input[type="password"]').focus().type("MyStrongPassword!1");
|
removeStub(
|
||||||
cy.get('button[type="submit"]').click();
|
"zitadel.user.v2alpha.UserService",
|
||||||
cy.location("pathname", { timeout: 10_000 }).should("eq", "/passkey/add");
|
"ListAuthenticationMethodTypes"
|
||||||
|
);
|
||||||
|
addStub(
|
||||||
|
"zitadel.user.v2alpha.UserService",
|
||||||
|
"ListAuthenticationMethodTypes",
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
authMethodTypes: [2], // 2 for passwordless authentication
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("should redirect a user with passwordless authentication to /passkey/login", () => {
|
||||||
|
cy.visit("/loginname?loginName=johndoe%40zitadel.com&submit=true");
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should(
|
||||||
|
"eq",
|
||||||
|
"/passkey/login"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("password login with passkey prompt", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
removeStub(
|
||||||
|
"zitadel.user.v2alpha.UserService",
|
||||||
|
"ListAuthenticationMethodTypes"
|
||||||
|
);
|
||||||
|
addStub(
|
||||||
|
"zitadel.user.v2alpha.UserService",
|
||||||
|
"ListAuthenticationMethodTypes",
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
authMethodTypes: [1], // 1 for password authentication
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
removeStub("zitadel.session.v2alpha.SessionService", "SetSession");
|
||||||
|
addStub("zitadel.session.v2alpha.SessionService", "SetSession", {
|
||||||
|
data: {
|
||||||
|
details: {
|
||||||
|
sequence: 859,
|
||||||
|
changeDate: "2023-07-04T07:58:20.126Z",
|
||||||
|
resourceOwner: "220516472055706145",
|
||||||
|
},
|
||||||
|
sessionToken:
|
||||||
|
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
||||||
|
challenges: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should prompt a user to setup passwordless authentication if passkey is allowed in the login settings", () => {
|
||||||
|
cy.visit("/loginname?loginName=john%40zitadel.com&submit=true");
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should("eq", "/password");
|
||||||
|
cy.get('input[type="password"]').focus().type("MyStrongPassword!1");
|
||||||
|
cy.get('button[type="submit"]').click();
|
||||||
|
cy.location("pathname", { timeout: 10_000 }).should("eq", "/passkey/add");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,16 +31,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"service": "zitadel.settings.v2alpha.SettingsService",
|
|
||||||
"method": "GetLoginSettings",
|
|
||||||
"out": {
|
|
||||||
"data": {
|
|
||||||
"settings": {
|
|
||||||
"passkeysType": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user