|
| 1 | +import archiver from "archiver"; |
1 | 2 | import getPort from "get-port"; |
2 | 3 | import path from "path"; |
3 | 4 | import { RandomUuid } from "../common"; |
@@ -509,6 +510,53 @@ describe("GenericContainer", { timeout: 180_000 }, () => { |
509 | 510 | expect((await container.exec(["cat", target])).output).toEqual(expect.stringContaining(content)); |
510 | 511 | }); |
511 | 512 |
|
| 513 | + // https://github.com/containers/podman/issues/27538 |
| 514 | + if (!process.env.CI_PODMAN) { |
| 515 | + it("should copy archive to started container with ownership when copyUIDGID is enabled", async () => { |
| 516 | + const uid = 4242; |
| 517 | + const gid = 4343; |
| 518 | + const targetWithCopyOwnership = "/tmp/copy-archive-copyuidgid.txt"; |
| 519 | + |
| 520 | + await using container = await new GenericContainer("cristianrgreco/testcontainer:1.1.14") |
| 521 | + .withExposedPorts(8080) |
| 522 | + .start(); |
| 523 | + |
| 524 | + const tar = archiver("tar"); |
| 525 | + tar.append("hello world", { name: targetWithCopyOwnership.slice(1), uid, gid } as archiver.EntryData); |
| 526 | + tar.finalize(); |
| 527 | + |
| 528 | + await container.copyArchiveToContainer(tar, "/", { copyUIDGID: true }); |
| 529 | + |
| 530 | + expect((await container.exec(["stat", "-c", "%u:%g", targetWithCopyOwnership])).output.trim()).toEqual( |
| 531 | + `${uid}:${gid}` |
| 532 | + ); |
| 533 | + }); |
| 534 | + |
| 535 | + it("should copy archives before start with ownership when copyUIDGID is enabled", async () => { |
| 536 | + const uid = 4242; |
| 537 | + const gid = 4343; |
| 538 | + const targetWithCopyOwnership = "/tmp/with-copy-archives-copyuidgid.txt"; |
| 539 | + const tar = archiver("tar"); |
| 540 | + tar.append("hello world", { name: targetWithCopyOwnership.slice(1), uid, gid } as archiver.EntryData); |
| 541 | + tar.finalize(); |
| 542 | + |
| 543 | + await using containerWithCopyOwnership = await new GenericContainer("cristianrgreco/testcontainer:1.1.14") |
| 544 | + .withCopyArchivesToContainer([ |
| 545 | + { |
| 546 | + tar, |
| 547 | + target: "/", |
| 548 | + }, |
| 549 | + ]) |
| 550 | + .withCopyToContainerOptions({ copyUIDGID: true }) |
| 551 | + .withExposedPorts(8080) |
| 552 | + .start(); |
| 553 | + |
| 554 | + expect( |
| 555 | + (await containerWithCopyOwnership.exec(["stat", "-c", "%u:%g", targetWithCopyOwnership])).output.trim() |
| 556 | + ).toEqual(`${uid}:${gid}`); |
| 557 | + }); |
| 558 | + } |
| 559 | + |
512 | 560 | it("should honour .dockerignore file", async () => { |
513 | 561 | const context = path.resolve(fixtures, "docker-with-dockerignore"); |
514 | 562 | const container = await GenericContainer.fromDockerfile(context).build(); |
|
0 commit comments