-
-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from Dokploy/canary
v0.5.0
- Loading branch information
Showing
69 changed files
with
7,937 additions
and
972 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ yarn-error.log* | |
# otros | ||
/.data | ||
/.main | ||
.vscode | ||
|
||
*.lockb | ||
*.rdb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
import type { Domain } from "@/server/api/services/domain"; | ||
import type { Redirect } from "@/server/api/services/redirect"; | ||
import type { ApplicationNested } from "@/server/utils/builders"; | ||
import { createRouterConfig } from "@/server/utils/traefik/domain"; | ||
import { expect, test } from "vitest"; | ||
|
||
const baseApp: ApplicationNested = { | ||
applicationId: "", | ||
applicationStatus: "done", | ||
appName: "", | ||
autoDeploy: true, | ||
branch: null, | ||
buildArgs: null, | ||
buildPath: "/", | ||
buildType: "nixpacks", | ||
command: null, | ||
cpuLimit: null, | ||
cpuReservation: null, | ||
createdAt: "", | ||
customGitBranch: "", | ||
customGitBuildPath: "", | ||
customGitSSHKeyId: null, | ||
customGitUrl: "", | ||
description: "", | ||
dockerfile: null, | ||
dockerImage: null, | ||
dropBuildPath: null, | ||
enabled: null, | ||
env: null, | ||
healthCheckSwarm: null, | ||
labelsSwarm: null, | ||
memoryLimit: null, | ||
memoryReservation: null, | ||
modeSwarm: null, | ||
mounts: [], | ||
name: "", | ||
networkSwarm: null, | ||
owner: null, | ||
password: null, | ||
placementSwarm: null, | ||
ports: [], | ||
projectId: "", | ||
redirects: [], | ||
refreshToken: "", | ||
registry: null, | ||
registryId: null, | ||
replicas: 1, | ||
repository: null, | ||
restartPolicySwarm: null, | ||
rollbackConfigSwarm: null, | ||
security: [], | ||
sourceType: "git", | ||
subtitle: null, | ||
title: null, | ||
updateConfigSwarm: null, | ||
username: null, | ||
}; | ||
|
||
const baseDomain: Domain = { | ||
applicationId: "", | ||
certificateType: "none", | ||
createdAt: "", | ||
domainId: "", | ||
host: "", | ||
https: false, | ||
path: null, | ||
port: null, | ||
uniqueConfigKey: 1, | ||
}; | ||
|
||
const baseRedirect: Redirect = { | ||
redirectId: "", | ||
regex: "", | ||
replacement: "", | ||
permanent: false, | ||
uniqueConfigKey: 1, | ||
createdAt: "", | ||
applicationId: "", | ||
}; | ||
|
||
/** Middlewares */ | ||
|
||
test("Web entrypoint on http domain", async () => { | ||
const router = await createRouterConfig( | ||
baseApp, | ||
{ ...baseDomain, https: false }, | ||
"web", | ||
); | ||
|
||
expect(router.middlewares).not.toContain("redirect-to-https"); | ||
}); | ||
|
||
test("Web entrypoint on http domain with redirect", async () => { | ||
const router = await createRouterConfig( | ||
{ | ||
...baseApp, | ||
appName: "test", | ||
redirects: [{ ...baseRedirect, uniqueConfigKey: 1 }], | ||
}, | ||
{ ...baseDomain, https: false }, | ||
"web", | ||
); | ||
|
||
expect(router.middlewares).not.toContain("redirect-to-https"); | ||
expect(router.middlewares).toContain("redirect-test-1"); | ||
}); | ||
|
||
test("Web entrypoint on http domain with multiple redirect", async () => { | ||
const router = await createRouterConfig( | ||
{ | ||
...baseApp, | ||
appName: "test", | ||
redirects: [ | ||
{ ...baseRedirect, uniqueConfigKey: 1 }, | ||
{ ...baseRedirect, uniqueConfigKey: 2 }, | ||
], | ||
}, | ||
{ ...baseDomain, https: false }, | ||
"web", | ||
); | ||
|
||
expect(router.middlewares).not.toContain("redirect-to-https"); | ||
expect(router.middlewares).toContain("redirect-test-1"); | ||
expect(router.middlewares).toContain("redirect-test-2"); | ||
}); | ||
|
||
test("Web entrypoint on https domain", async () => { | ||
const router = await createRouterConfig( | ||
baseApp, | ||
{ ...baseDomain, https: true }, | ||
"web", | ||
); | ||
|
||
expect(router.middlewares).toContain("redirect-to-https"); | ||
}); | ||
|
||
test("Web entrypoint on https domain with redirect", async () => { | ||
const router = await createRouterConfig( | ||
{ | ||
...baseApp, | ||
appName: "test", | ||
redirects: [{ ...baseRedirect, uniqueConfigKey: 1 }], | ||
}, | ||
{ ...baseDomain, https: true }, | ||
"web", | ||
); | ||
|
||
expect(router.middlewares).toContain("redirect-to-https"); | ||
expect(router.middlewares).not.toContain("redirect-test-1"); | ||
}); | ||
|
||
test("Websecure entrypoint on https domain", async () => { | ||
const router = await createRouterConfig( | ||
baseApp, | ||
{ ...baseDomain, https: true }, | ||
"websecure", | ||
); | ||
|
||
expect(router.middlewares).not.toContain("redirect-to-https"); | ||
}); | ||
|
||
test("Websecure entrypoint on https domain with redirect", async () => { | ||
const router = await createRouterConfig( | ||
{ | ||
...baseApp, | ||
appName: "test", | ||
redirects: [{ ...baseRedirect, uniqueConfigKey: 1 }], | ||
}, | ||
{ ...baseDomain, https: true }, | ||
"websecure", | ||
); | ||
|
||
expect(router.middlewares).not.toContain("redirect-to-https"); | ||
expect(router.middlewares).toContain("redirect-test-1"); | ||
}); | ||
|
||
/** Certificates */ | ||
|
||
test("CertificateType on websecure entrypoint", async () => { | ||
const router = await createRouterConfig( | ||
baseApp, | ||
{ ...baseDomain, certificateType: "letsencrypt" }, | ||
"websecure", | ||
); | ||
|
||
expect(router.tls?.certResolver).toBe("letsencrypt"); | ||
}); |
Oops, something went wrong.