mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-30 07:58:51 +00:00
chore: fix login integration (#10318)
# Which Problems Are Solved Login integration tests are not executed in the pipeline # How the Problems Are Solved The login integration tests are fixed and added as a pipeline workflow. It tests against the built login docker image. On pipeline failures, developers are guided on how to fix them using a dev container configured for this purpose. # Additional Changes - email domains are replaced by example.com. In case the tests were accidentally run against a cloud instance, it wouldn't cause bounces. - pnpm is upgraded, because the --filter argument doesn't work for the install command on the old version. - The login Dockerfile is optimized for docker image builds # Additional Changes From Review for https://github.com/zitadel/zitadel/pull/10305 These changes were requested from @peintnermax - The base dev container starts without any services besides the database and the dev container itself - CONTRIBUTING.md is restructured - To reproduce pipeline checks, only the devcontainer CLI and Docker are needed. This is described in the CONTRIBUTING.md - The convenience npm script "generate" is added # Additional Context - Follow-up for PR https://github.com/zitadel/zitadel/pull/10305 - Base for https://github.com/zitadel/zitadel/issues/10277
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
FROM bufbuild/buf:1.54.0 AS proto-files
|
||||
RUN buf export https://github.com/envoyproxy/protoc-gen-validate.git --path validate --output /proto-files && \
|
||||
buf export https://github.com/grpc-ecosystem/grpc-gateway.git --path protoc-gen-openapiv2 --output /proto-files && \
|
||||
buf export https://github.com/googleapis/googleapis.git --path protos/zitadelgoogle/api/annotations.proto --path google/api/http.proto --path google/api/field_behavior.proto --output /proto-files && \
|
||||
buf export https://github.com/zitadel/zitadel.git --path ./proto/zitadel --output /proto-files
|
||||
FROM bufbuild/buf:1.54.0 AS dependencies
|
||||
RUN buf export https://github.com/envoyproxy/protoc-gen-validate.git --path validate --output /proto && \
|
||||
buf export https://github.com/grpc-ecosystem/grpc-gateway.git --path protoc-gen-openapiv2 --output /proto && \
|
||||
buf export https://github.com/googleapis/googleapis.git --path google/api/annotations.proto --path google/api/http.proto --path google/api/field_behavior.proto --output /proto
|
||||
|
||||
FROM bufbuild/buf:1.54.0 AS zitadel-protos
|
||||
RUN buf export https://github.com/zitadel/zitadel.git --path ./proto/zitadel --output /zitadel
|
||||
|
||||
FROM golang:1.20.5-alpine3.18 AS mock-zitadel
|
||||
|
||||
@@ -10,6 +12,7 @@ RUN go install github.com/eliobischof/grpc-mock/cmd/grpc-mock@01b09f60db1b501178
|
||||
|
||||
COPY mocked-services.cfg .
|
||||
COPY initial-stubs initial-stubs
|
||||
COPY --from=proto-files /proto-files/ ./
|
||||
COPY --from=dependencies /proto/ ./
|
||||
COPY --from=zitadel-protos /zitadel/ ./zitadel/
|
||||
|
||||
ENTRYPOINT [ "sh", "-c", "grpc-mock -v 1 -proto $(tr '\n' ',' < ./mocked-services.cfg) -stub-dir ./initial-stubs -mock-addr :22222" ]
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { defineConfig } from "cypress";
|
||||
|
||||
export default defineConfig({
|
||||
reporter: "list",
|
||||
|
||||
e2e: {
|
||||
baseUrl: process.env.LOGIN_BASE_URL || "http://localhost:3001/ui/v2/login",
|
||||
specPattern: "integration/**/*.cy.{js,jsx,ts,tsx}",
|
||||
supportFile: "support/e2e.{js,jsx,ts,tsx}",
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "[email protected]",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@@ -22,22 +22,22 @@ describe("verify invite", () => {
|
||||
user: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
human: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
avatarUrl: "https://example.com/avatar.jpg",
|
||||
},
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
email: "john@example.com",
|
||||
isVerified: false,
|
||||
},
|
||||
},
|
||||
@@ -68,7 +68,7 @@ describe("verify invite", () => {
|
||||
factors: {
|
||||
user: {
|
||||
id: "221394658884845598",
|
||||
loginName: "john@zitadel.com",
|
||||
loginName: "john@example.com",
|
||||
},
|
||||
password: undefined,
|
||||
webAuthN: undefined,
|
||||
@@ -93,7 +93,7 @@ describe("verify invite", () => {
|
||||
stub("zitadel.user.v2.UserService", "VerifyInviteCode");
|
||||
|
||||
cy.visit("/verify?userId=221394658884845598&code=abc&invite=true");
|
||||
cy.url({ timeout: 10_000 }).should("include", Cypress.config().baseUrl + "/authenticator/set");
|
||||
cy.url().should("include", Cypress.config().baseUrl + "/authenticator/set");
|
||||
});
|
||||
|
||||
it("shows an error if invite code validation failed", () => {
|
||||
|
||||
@@ -33,7 +33,7 @@ describe("login", () => {
|
||||
factors: {
|
||||
user: {
|
||||
id: "221394658884845598",
|
||||
loginName: "john@zitadel.com",
|
||||
loginName: "john@example.com",
|
||||
},
|
||||
password: undefined,
|
||||
webAuthN: undefined,
|
||||
@@ -64,22 +64,22 @@ describe("login", () => {
|
||||
{
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
human: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
avatarUrl: "https://example.com/avatar.jpg",
|
||||
},
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
email: "john@example.com",
|
||||
isVerified: true,
|
||||
},
|
||||
},
|
||||
@@ -94,8 +94,8 @@ describe("login", () => {
|
||||
});
|
||||
});
|
||||
it("should redirect a user with password authentication to /password", () => {
|
||||
cy.visit("/loginname?loginName=john%40zitadel.com&submit=true");
|
||||
cy.url({ timeout: 10_000 }).should("include", Cypress.config().baseUrl + "/password");
|
||||
cy.visit("/loginname?loginName=john%40example.com&submit=true");
|
||||
cy.url({ timeout: 5 * 60_000 }).should("include", Cypress.config().baseUrl + "/password");
|
||||
});
|
||||
describe("with passkey prompt", () => {
|
||||
beforeEach(() => {
|
||||
@@ -112,8 +112,8 @@ describe("login", () => {
|
||||
});
|
||||
});
|
||||
// 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.visit("/loginname?loginName=john%40example.com&submit=true");
|
||||
// cy.location("pathname", { timeout: 5 * 60_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(
|
||||
@@ -134,22 +134,22 @@ describe("login", () => {
|
||||
{
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
human: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
avatarUrl: "https://example.com/avatar.jpg",
|
||||
},
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
email: "john@example.com",
|
||||
isVerified: true,
|
||||
},
|
||||
},
|
||||
@@ -165,8 +165,8 @@ describe("login", () => {
|
||||
});
|
||||
|
||||
it("should redirect a user with passwordless authentication to /passkey", () => {
|
||||
cy.visit("/loginname?loginName=john%40zitadel.com&submit=true");
|
||||
cy.url({ timeout: 10_000 }).should("include", Cypress.config().baseUrl + "/passkey");
|
||||
cy.visit("/loginname?loginName=john%40example.com&submit=true");
|
||||
cy.url().should("include", Cypress.config().baseUrl + "/passkey");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe("register idps", () => {
|
||||
cy.visit("/idp");
|
||||
cy.get('button[e2e="google"]').click();
|
||||
cy.origin(IDP_URL, { args: IDP_URL }, (url) => {
|
||||
cy.location("href", { timeout: 10_000 }).should("eq", url);
|
||||
cy.location("href").should("eq", url);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ describe("register", () => {
|
||||
factors: {
|
||||
user: {
|
||||
id: "221394658884845598",
|
||||
loginName: "john@zitadel.com",
|
||||
loginName: "john@example.com",
|
||||
},
|
||||
password: undefined,
|
||||
webAuthN: undefined,
|
||||
@@ -64,10 +64,10 @@ describe("register", () => {
|
||||
cy.visit("/register");
|
||||
cy.get('input[data-testid="firstname-text-input"]').focus().type("John");
|
||||
cy.get('input[data-testid="lastname-text-input"]').focus().type("Doe");
|
||||
cy.get('input[data-testid="email-text-input"]').focus().type("john@zitadel.com");
|
||||
cy.get('input[data-testid="email-text-input"]').focus().type("john@example.com");
|
||||
cy.get('input[type="checkbox"][value="privacypolicy"]').check();
|
||||
cy.get('input[type="checkbox"][value="tos"]').check();
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.url({ timeout: 10_000 }).should("include", Cypress.config().baseUrl + "/passkey/set");
|
||||
cy.url().should("include", Cypress.config().baseUrl + "/passkey/set");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,22 +24,22 @@ describe("verify email", () => {
|
||||
user: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
human: {
|
||||
userId: "221394658884845598",
|
||||
state: 1,
|
||||
username: "john@zitadel.com",
|
||||
loginNames: ["john@zitadel.com"],
|
||||
preferredLoginName: "john@zitadel.com",
|
||||
username: "john@example.com",
|
||||
loginNames: ["john@example.com"],
|
||||
preferredLoginName: "john@example.com",
|
||||
profile: {
|
||||
givenName: "John",
|
||||
familyName: "Doe",
|
||||
avatarUrl: "https://zitadel.com/avatar.jpg",
|
||||
avatarUrl: "https://example.com/avatar.jpg",
|
||||
},
|
||||
email: {
|
||||
email: "john@zitadel.com",
|
||||
email: "john@example.com",
|
||||
isVerified: false, // email is not verified yet
|
||||
},
|
||||
},
|
||||
@@ -70,7 +70,7 @@ describe("verify email", () => {
|
||||
factors: {
|
||||
user: {
|
||||
id: "221394658884845598",
|
||||
loginName: "john@zitadel.com",
|
||||
loginName: "john@example.com",
|
||||
},
|
||||
password: undefined,
|
||||
webAuthN: undefined,
|
||||
@@ -90,6 +90,6 @@ describe("verify email", () => {
|
||||
// TODO: Avoid uncaught exception in application
|
||||
cy.once("uncaught:exception", () => false);
|
||||
cy.visit("/verify?userId=221394658884845598&code=abc");
|
||||
cy.contains("Could not verify email", { timeout: 10_000 });
|
||||
cy.contains("Could not verify email");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const url = Cypress.env("CORE_MOCK_STUBS_URL") || "http://mock-zitadel:22220/v1/stubs";
|
||||
const url = Cypress.env("CORE_MOCK_STUBS_URL") || "http://localhost:22220/v1/stubs";
|
||||
|
||||
function removeStub(service: string, method: string) {
|
||||
return cy.request({
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
"lib": ["es5", "dom"],
|
||||
"types": ["cypress", "node"]
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
"include": ["**/*.ts", "../cypress.config.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user