Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions apps/dokploy/__test__/cluster/upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ describe("getRegistryTag", () => {
registryName: "Test Registry",
username: "myuser",
password: "test-password",
authType: "credentials",
credentialHelper: null,
credentialHelperUrls: null,
registryUrl: "docker.io",
registryType: "cloud",
imagePrefix: null,
Expand Down Expand Up @@ -240,4 +243,62 @@ describe("getRegistryTag", () => {
expect(result).toBe("docker.io/robot+test-user/nginx:latest");
});
});

describe("credential helper registries (no username)", () => {
it("should use registryUrl and imagePrefix when no username", () => {
const registry = createMockRegistry({
authType: "credential-helper",
credentialHelper: "ecr-login",
username: null,
password: null,
registryUrl: "123456789.dkr.ecr.us-west-2.amazonaws.com",
imagePrefix: "myproject",
});
const result = getRegistryTag(registry, "myapp:latest");
expect(result).toBe(
"123456789.dkr.ecr.us-west-2.amazonaws.com/myproject/myapp:latest",
);
});

it("should use registryUrl only when no username and no imagePrefix", () => {
const registry = createMockRegistry({
authType: "credential-helper",
credentialHelper: "ecr-login",
username: null,
password: null,
registryUrl: "123456789.dkr.ecr.us-west-2.amazonaws.com",
imagePrefix: null,
});
const result = getRegistryTag(registry, "myapp:latest");
expect(result).toBe(
"123456789.dkr.ecr.us-west-2.amazonaws.com/myapp:latest",
);
});

it("should handle credential helper with gcr registry", () => {
const registry = createMockRegistry({
authType: "credential-helper",
credentialHelper: "gcr",
username: null,
password: null,
registryUrl: "gcr.io",
imagePrefix: "my-gcp-project",
});
const result = getRegistryTag(registry, "nginx:latest");
expect(result).toBe("gcr.io/my-gcp-project/nginx:latest");
});

it("should handle credential helper with no registryUrl and imagePrefix only", () => {
const registry = createMockRegistry({
authType: "credential-helper",
credentialHelper: "ecr-login",
username: null,
password: null,
registryUrl: "",
imagePrefix: "myprefix",
});
const result = getRegistryTag(registry, "myapp:latest");
expect(result).toBe("myprefix/myapp:latest");
});
});
});
Loading