@@ -1090,7 +1090,7 @@ void testShouldCopyIndexOfIndexAndUseMounting() throws IOException {
10901090 assertNotNull (index1 .getDescriptor (), "Index 1 descriptor should not be null" );
10911091
10921092 Index index2 = Index .fromManifests (List .of (manifest2 .getDescriptor (), index1 .getDescriptor ()));
1093- index2 = registry .pushIndex (containerSource .withTag ("index2" ), index2 );
1093+ registry .pushIndex (containerSource .withTag ("index2" ), index2 );
10941094
10951095 // Copy to other registry
10961096 ContainerRef containerTarget =
@@ -1163,7 +1163,7 @@ void testShouldCopySingleArtifactFromRegistryIntoRegistry() throws IOException {
11631163 .build ();
11641164
11651165 ContainerRef containerSource =
1166- ContainerRef .parse ("%s/library/artifact-source" .formatted (this .registry .getRegistry ()));
1166+ ContainerRef .parse ("%s/library/artifact-source:foo " .formatted (this .registry .getRegistry ()));
11671167 Path file1 = blobDir .resolve ("source.txt" );
11681168 Files .writeString (file1 , "foobar" );
11691169
@@ -1174,11 +1174,48 @@ void testShouldCopySingleArtifactFromRegistryIntoRegistry() throws IOException {
11741174 // Copy to other registry
11751175 try (RegistryContainer otherRegistryContainer = new RegistryContainer ()) {
11761176 otherRegistryContainer .start ();
1177- ContainerRef containerTarget =
1178- ContainerRef . parse ( "%s/library/artifact-target" .formatted (otherRegistryContainer .getRegistry ()));
1177+ ContainerRef containerTarget = ContainerRef . parse (
1178+ "%s/library/artifact-target:bar " .formatted (otherRegistryContainer .getRegistry ()));
11791179 CopyUtils .copy (registry , containerSource , registry , containerTarget , CopyUtils .CopyOptions .shallow ());
11801180 registry .pullArtifact (containerTarget , artifactDir , true );
11811181 assertEquals ("foobar" , Files .readString (artifactDir .resolve ("source.txt" )));
1182+ Manifest manifest2 = registry .getManifest (containerTarget );
1183+ assertNotNull (manifest2 .getDescriptor (), "Manifest descriptor should not be null" );
1184+ }
1185+ }
1186+
1187+ @ Test
1188+ void testShouldCopySingleFromDigest () throws IOException {
1189+ // Copy to same registry
1190+ Registry registry = Registry .Builder .builder ()
1191+ .defaults ("myuser" , "mypass" )
1192+ .withInsecure (true )
1193+ .build ();
1194+
1195+ ContainerRef containerSource =
1196+ ContainerRef .parse ("%s/library/artifact-source:foo" .formatted (this .registry .getRegistry ()));
1197+ Path file1 = blobDir .resolve ("source.txt" );
1198+ Files .writeString (file1 , "foobar" );
1199+
1200+ // Push
1201+ Manifest manifest = registry .pushArtifact (containerSource , LocalPath .of (file1 ));
1202+ assertNotNull (manifest );
1203+
1204+ // Copy to other registry
1205+ try (RegistryContainer otherRegistryContainer = new RegistryContainer ()) {
1206+ otherRegistryContainer .start ();
1207+ ContainerRef containerTarget =
1208+ ContainerRef .parse ("%s/library/artifact-target" .formatted (otherRegistryContainer .getRegistry ()));
1209+ CopyUtils .copy (
1210+ registry ,
1211+ containerSource .withDigest (manifest .getDigest ()),
1212+ registry ,
1213+ containerTarget .withDigest (manifest .getDigest ()),
1214+ CopyUtils .CopyOptions .shallow ());
1215+ registry .pullArtifact (containerTarget .withDigest (manifest .getDigest ()), artifactDir , true );
1216+ assertEquals ("foobar" , Files .readString (artifactDir .resolve ("source.txt" )));
1217+ Manifest manifest2 = registry .getManifest (containerTarget .withDigest (manifest .getDigest ()));
1218+ assertNotNull (manifest2 .getDescriptor (), "Manifest descriptor should not be null" );
11821219 }
11831220 }
11841221
@@ -1321,12 +1358,9 @@ void testShouldCopyFromOciLayoutToRegistryNonRecursive() throws IOException {
13211358 void testShouldCopyFromOciLayoutToRegistryRecursive () throws IOException {
13221359
13231360 // Registry to copy
1324- Registry registry = Registry .builder ()
1325- .defaults ("myuser" , "mypass" )
1326- .withInsecure (true )
1327- .build ();
1361+ Registry registry = Registry .builder ().withInsecure (true ).build ();
13281362 ContainerRef targetRef = ContainerRef .parse (
1329- "%s/library/copied-from-oci-layout-recursive" .formatted (this .registry .getRegistry ()));
1363+ "%s/library/copied-from-oci-layout-recursive" .formatted (this .unsecureRegistry .getRegistry ()));
13301364
13311365 LayoutRef layoutRef = LayoutRef .parse ("src/test/resources/oci/subject:latest" );
13321366 OCILayout ociLayout =
0 commit comments