|
40 | 40 | import land.oras.utils.ZotUnsecureContainer; |
41 | 41 | import org.junit.jupiter.api.Assertions; |
42 | 42 | import org.junit.jupiter.api.BeforeEach; |
| 43 | +import org.junit.jupiter.api.Disabled; |
43 | 44 | import org.junit.jupiter.api.Test; |
44 | 45 | import org.junit.jupiter.api.io.TempDir; |
45 | 46 | import org.junit.jupiter.api.parallel.Execution; |
@@ -862,6 +863,64 @@ void testShouldCopySingleArtifactFromRegistryIntoRegistry() throws IOException { |
862 | 863 | } |
863 | 864 | } |
864 | 865 |
|
| 866 | + @Test |
| 867 | + @Execution(ExecutionMode.SAME_THREAD) |
| 868 | + @Disabled("#") |
| 869 | + void testShouldCopyFromAliasToAlias(@TempDir Path homeDir) throws Exception { |
| 870 | + |
| 871 | + try (RegistryContainer otherRegistryContainer = new RegistryContainer()) { |
| 872 | + |
| 873 | + otherRegistryContainer.start(); |
| 874 | + |
| 875 | + // language=toml |
| 876 | + String config = |
| 877 | + """ |
| 878 | + [aliases] |
| 879 | + "the-source" = "%s/test/artifact-source" |
| 880 | + "the-target" = "%s/test/artifact-target" |
| 881 | +
|
| 882 | + [[registry]] |
| 883 | + location = "%s" |
| 884 | + insecure = true |
| 885 | +
|
| 886 | + [[registry]] |
| 887 | + location = "%s" |
| 888 | + insecure = true |
| 889 | + """ |
| 890 | + .formatted( |
| 891 | + this.registry.getRegistry(), |
| 892 | + otherRegistryContainer.getRegistry(), |
| 893 | + this.registry.getRegistry(), |
| 894 | + otherRegistryContainer.getRegistry()); |
| 895 | + TestUtils.createRegistriesConfFile(homeDir, config); |
| 896 | + |
| 897 | + // Copy to same registry |
| 898 | + TestUtils.withHome(homeDir, () -> { |
| 899 | + try { |
| 900 | + Registry registry = Registry.Builder.builder() |
| 901 | + .defaults("myuser", "mypass") |
| 902 | + .build(); |
| 903 | + |
| 904 | + ContainerRef containerSource = ContainerRef.parse("the-source"); |
| 905 | + Path file1 = blobDir.resolve("source.txt"); |
| 906 | + Files.writeString(file1, "foobar"); |
| 907 | + |
| 908 | + // Push |
| 909 | + Manifest manifest = registry.pushArtifact(containerSource, LocalPath.of(file1)); |
| 910 | + assertNotNull(manifest); |
| 911 | + |
| 912 | + // Copy to other registry |
| 913 | + ContainerRef containerTarget = ContainerRef.parse("the-target"); |
| 914 | + CopyUtils.copy(registry, containerSource, registry, containerTarget, false); |
| 915 | + registry.pullArtifact(containerTarget, artifactDir, true); |
| 916 | + assertEquals("foobar", Files.readString(artifactDir.resolve("source.txt"))); |
| 917 | + } catch (Exception e) { |
| 918 | + throw new RuntimeException(e); |
| 919 | + } |
| 920 | + }); |
| 921 | + } |
| 922 | + } |
| 923 | + |
865 | 924 | @Test |
866 | 925 | void testShouldCopyFromOciLayoutToRegistryNonRecursive() throws IOException { |
867 | 926 |
|
|
0 commit comments