2121package land .oras ;
2222
2323import static org .junit .jupiter .api .Assertions .assertNotNull ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
2425
25- import java .io .IOException ;
2626import java .nio .file .Path ;
27+ import land .oras .utils .ZotUnsecureContainer ;
2728import org .junit .jupiter .api .Test ;
2829import org .junit .jupiter .api .io .TempDir ;
2930import org .junit .jupiter .api .parallel .Execution ;
3031import org .junit .jupiter .api .parallel .ExecutionMode ;
32+ import org .testcontainers .junit .jupiter .Container ;
33+ import org .testcontainers .junit .jupiter .Testcontainers ;
3134
35+ @ Testcontainers
3236@ Execution (ExecutionMode .CONCURRENT )
3337class JFrogArtifactoryITCase {
3438
3539 @ TempDir
3640 Path tempDir ;
3741
42+ @ Container
43+ private final ZotUnsecureContainer unsecureRegistry = new ZotUnsecureContainer ().withStartupAttempts (3 );
44+
3845 @ Test
3946 void shouldPull () {
4047 Registry registry = Registry .builder ().build ();
@@ -44,12 +51,32 @@ void shouldPull() {
4451 }
4552
4653 @ Test
47- void shouldPullOneBlob () throws IOException {
54+ void shouldPullOneBlob () {
4855 Registry registry = Registry .builder ().build ();
4956 ContainerRef containerRef1 = ContainerRef .parse ("releases-docker.jfrog.io/jfrog/jfrog-cli-v2-jf" );
5057 Manifest manifest = registry .getManifest (containerRef1 );
5158 Layer oneLayer = manifest .getLayers ().get (0 );
5259 registry .fetchBlob (containerRef1 .withDigest (oneLayer .getDigest ()), tempDir .resolve ("my-blob" ));
5360 assertNotNull (tempDir .resolve ("my-blob" ));
5461 }
62+
63+ @ Test
64+ void shouldCopyTagToInternalRegistry () {
65+
66+ // Source registry
67+ Registry sourceRegistry = Registry .Builder .builder ().defaults ().build ();
68+
69+ // Copy to this internal registry
70+ Registry targetRegistry = Registry .Builder .builder ()
71+ .defaults ("myuser" , "mypass" )
72+ .withInsecure (true )
73+ .build ();
74+
75+ ContainerRef containerSource = ContainerRef .parse ("releases-docker.jfrog.io/jfrog/jfrog-cli-v2-jf" );
76+ ContainerRef containerTarget =
77+ ContainerRef .parse ("%s/jfrog/jfrog-cli-v2-jf" .formatted (unsecureRegistry .getRegistry ()));
78+
79+ CopyUtils .copy (sourceRegistry , containerSource , targetRegistry , containerTarget , true );
80+ assertTrue (targetRegistry .exists (containerTarget ));
81+ }
5582}
0 commit comments