create, get session mock

This commit is contained in:
Max Peintner
2023-07-04 10:00:42 +02:00
parent 50c07536f5
commit 57e7efea88

View File

@@ -2,24 +2,35 @@ import { addStub, removeStub } from "../support/mock";
describe("/passkey/login", () => {
it("should redirect a user with password authentication to /password", () => {
removeStub("zitadel.user.v2alpha.SessionService", "SetSession");
addStub("zitadel.user.v2alpha.SessionService", "SetSession", {
// authMethodTypes: [2, 1],
id: "221390781972217886",
creationDate: new Date("2023-07-04T07:19:49.178Z"),
changeDate: new Date("2023-07-04T07:19:54.617Z"),
sequence: 854,
factors: {
user: {
displayName: "John Doe",
id: "221256020561756190",
loginName: "johndoe@zitadel.com",
verifiedAt: "2023-07-04T07:19:49.168Z",
sessionId: "221390781972217886",
removeStub("zitadel.user.v2alpha.SessionService", "CreateSession");
addStub("zitadel.user.v2alpha.SessionService", "CreateSession", {
details: {
sequence: 859,
changeDate: new Date("2023-07-04T07:58:20.126Z"),
resourceOwner: "220516472055706145",
},
sessionId: "221394658884845598",
sessionToken:
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
challenges: undefined,
});
removeStub("zitadel.user.v2alpha.SessionService", "GetSession");
addStub("zitadel.user.v2alpha.SessionService", "GetSession", {
session: {
id: "221394658884845598",
creationDate: new Date("2023-07-04T07:58:20.026Z"),
changeDate: new Date("2023-07-04T07:58:20.126Z"),
sequence: 859,
factors: {
user: [Object],
password: undefined,
passkey: undefined,
intent: undefined,
},
metadata: {},
domain: "localhost",
},
});
removeStub(
@@ -41,24 +52,35 @@ describe("/passkey/login", () => {
);
});
it("should redirect a user with passwordless authentication to /passkey/login", () => {
removeStub("zitadel.user.v2alpha.SessionService", "SetSession");
addStub("zitadel.user.v2alpha.SessionService", "SetSession", {
// authMethodTypes: [2, 1],
id: "221390781972217886",
creationDate: new Date("2023-07-04T07:19:49.178Z"),
changeDate: new Date("2023-07-04T07:19:54.617Z"),
sequence: 854,
factors: {
user: {
displayName: "John Doe",
id: "221256020561756190",
loginName: "johndoe@zitadel.com",
verifiedAt: "2023-07-04T07:19:49.168Z",
sessionId: "221390781972217886",
removeStub("zitadel.user.v2alpha.SessionService", "CreateSession");
addStub("zitadel.user.v2alpha.SessionService", "CreateSession", {
details: {
sequence: 859,
changeDate: new Date("2023-07-04T07:58:20.126Z"),
resourceOwner: "220516472055706145",
},
sessionId: "221394658884845598",
sessionToken:
"SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
challenges: undefined,
});
removeStub("zitadel.user.v2alpha.SessionService", "GetSession");
addStub("zitadel.user.v2alpha.SessionService", "GetSession", {
session: {
id: "221394658884845598",
creationDate: new Date("2023-07-04T07:58:20.026Z"),
changeDate: new Date("2023-07-04T07:58:20.126Z"),
sequence: 859,
factors: {
user: [Object],
password: undefined,
passkey: undefined,
intent: undefined,
},
metadata: {},
domain: "localhost",
},
});
removeStub(
@@ -93,3 +115,22 @@ describe("/passkey/login", () => {
// cy.location("pathname", { timeout: 10_000 }).should("eq", "/accounts");
// });
});
// removeStub("zitadel.user.v2alpha.SessionService", "SetSession");
// addStub("zitadel.user.v2alpha.SessionService", "SetSession", {
// id: "221390781972217886",
// creationDate: new Date("2023-07-04T07:19:49.178Z"),
// changeDate: new Date("2023-07-04T07:19:54.617Z"),
// sequence: 854,
// factors: {
// user: {
// displayName: "John Doe",
// id: "221256020561756190",
// loginName: "johndoe@zitadel.com",
// verifiedAt: "2023-07-04T07:19:49.168Z",
// sessionId: "221390781972217886",
// },
// },
// metadata: {},
// domain: "localhost",
// });