mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-21 12:28:46 +00:00
Merge commit from fork
* fix: Improve host header handling and deployment mode detection * ZITADEL_CLOUD env * refactor service config * service config * cleanup * cleanup * util for original and public host * instanceHost, publicHost * cleanup constructUrl * cleanup middleware * add x-zitadel-forward-host as fallback for current cloud setup * fix build * fix: lint * fix: update test mocks * fix: provide basepath to unit tests * host handling * unit tests * imports * fix: getPublicHost instead of getInstanceHost * unit tests * update nextjs, implement jwt verify for logout_token * pass logout information in jwt to login v2 * handle hosts in jwks url * point idp callbacks to the api and not the login UI * logout_hint out of logout token, typecheck * rm unused imports * fix oidc integration test --------- Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
f9e3871bb3
commit
df75be96ff
@@ -12,7 +12,7 @@ vi.mock("@zitadel/client", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("../service-url", () => ({
|
||||
getServiceUrlFromHeaders: vi.fn(),
|
||||
getServiceConfig: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../zitadel", () => ({
|
||||
@@ -111,7 +111,7 @@ describe("processIDPCallback", () => {
|
||||
|
||||
// Import mocked modules
|
||||
const { headers } = await import("next/headers");
|
||||
const { getServiceUrlFromHeaders } = await import("../service-url");
|
||||
const { getServiceConfig } = await import("../service-url");
|
||||
const {
|
||||
retrieveIDPIntent,
|
||||
getIDPByID,
|
||||
@@ -129,7 +129,7 @@ describe("processIDPCallback", () => {
|
||||
|
||||
// Setup mocks
|
||||
mockHeaders = vi.mocked(headers);
|
||||
mockGetServiceUrlFromHeaders = vi.mocked(getServiceUrlFromHeaders);
|
||||
mockGetServiceUrlFromHeaders = vi.mocked(getServiceConfig);
|
||||
mockRetrieveIDPIntent = vi.mocked(retrieveIDPIntent);
|
||||
mockGetIDPByID = vi.mocked(getIDPByID);
|
||||
mockUpdateHuman = vi.mocked(updateHuman);
|
||||
@@ -146,7 +146,7 @@ describe("processIDPCallback", () => {
|
||||
// Default mock implementations
|
||||
mockHeaders.mockResolvedValue({} as any);
|
||||
mockGetServiceUrlFromHeaders.mockReturnValue({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
});
|
||||
mockRetrieveIDPIntent.mockResolvedValue(defaultIntent);
|
||||
mockGetIDPByID.mockResolvedValue(defaultIdp);
|
||||
@@ -257,7 +257,7 @@ describe("processIDPCallback", () => {
|
||||
const result = await processIDPCallback(defaultParams);
|
||||
|
||||
expect(mockRetrieveIDPIntent).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
id: "intent123",
|
||||
token: "token123",
|
||||
});
|
||||
@@ -287,7 +287,7 @@ describe("processIDPCallback", () => {
|
||||
await processIDPCallback(defaultParams);
|
||||
|
||||
expect(mockUpdateHuman).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
request: expect.objectContaining({
|
||||
userId: "user123",
|
||||
profile: defaultIntent.updateHumanUser.profile,
|
||||
@@ -353,7 +353,7 @@ describe("processIDPCallback", () => {
|
||||
const result = await processIDPCallback(linkParams);
|
||||
|
||||
expect(mockAddIDPLink).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
idp: {
|
||||
id: "idp123",
|
||||
userId: "user123",
|
||||
@@ -442,12 +442,12 @@ describe("processIDPCallback", () => {
|
||||
const result = await processIDPCallback(defaultParams);
|
||||
|
||||
expect(mockListUsers).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
email: "[email protected]",
|
||||
organizationId: "org123",
|
||||
});
|
||||
expect(mockAddIDPLink).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
idp: {
|
||||
id: "idp123",
|
||||
userId: "user123",
|
||||
@@ -523,7 +523,7 @@ describe("processIDPCallback", () => {
|
||||
const result = await processIDPCallback(defaultParams);
|
||||
|
||||
expect(mockListUsers).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userName: "testuser",
|
||||
organizationId: "org123",
|
||||
});
|
||||
@@ -557,7 +557,7 @@ describe("processIDPCallback", () => {
|
||||
const result = await processIDPCallback(defaultParams);
|
||||
|
||||
expect(mockAddHuman).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
request: expect.objectContaining({
|
||||
username: "testuser",
|
||||
profile: defaultIntent.addHumanUser.profile,
|
||||
@@ -602,11 +602,11 @@ describe("processIDPCallback", () => {
|
||||
});
|
||||
|
||||
expect(mockGetOrgsByDomain).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
domain: "example.com",
|
||||
});
|
||||
expect(mockAddHuman).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
request: expect.objectContaining({
|
||||
organization: expect.objectContaining({
|
||||
org: { case: "orgId", value: "org-from-domain" },
|
||||
@@ -625,10 +625,10 @@ describe("processIDPCallback", () => {
|
||||
});
|
||||
|
||||
expect(mockGetDefaultOrg).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
});
|
||||
expect(mockAddHuman).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
request: expect.objectContaining({
|
||||
organization: expect.objectContaining({
|
||||
org: { case: "orgId", value: "default-org" },
|
||||
@@ -901,14 +901,14 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(mockGetLoginSettings).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
organization: "org123",
|
||||
});
|
||||
expect(mockGetActiveIdentityProviders).not.toHaveBeenCalled();
|
||||
@@ -918,7 +918,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
mockGetLoginSettings.mockResolvedValue(undefined);
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
@@ -930,7 +930,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
mockGetLoginSettings.mockResolvedValue({});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
@@ -952,14 +952,14 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(mockGetActiveIdentityProviders).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
orgId: "org123",
|
||||
linking_allowed: true,
|
||||
});
|
||||
@@ -974,7 +974,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
@@ -989,7 +989,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
mockGetActiveIdentityProviders.mockResolvedValue({});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
@@ -1011,18 +1011,18 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
|
||||
expect(result).toBe(true);
|
||||
expect(mockGetLoginSettings).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
organization: "org123",
|
||||
});
|
||||
expect(mockGetActiveIdentityProviders).toHaveBeenCalledWith({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
orgId: "org123",
|
||||
linking_allowed: true,
|
||||
});
|
||||
@@ -1042,7 +1042,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
@@ -1057,7 +1057,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
|
||||
await expect(
|
||||
validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
}),
|
||||
@@ -1072,7 +1072,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
|
||||
await expect(
|
||||
validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
}),
|
||||
@@ -1088,7 +1088,7 @@ describe("validateIDPLinkingPermissions", () => {
|
||||
});
|
||||
|
||||
const result = await validateIDPLinkingPermissions({
|
||||
serviceUrl: "https://api.example.com",
|
||||
serviceConfig: { baseUrl: "https://api.example.com" },
|
||||
userOrganizationId: "org123",
|
||||
idpId: "idp123",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user