@@ -70,10 +70,8 @@ void before() {
7070 void shouldListRepositories () {
7171
7272 // Setup
73- Registry registry = Registry .Builder .builder ()
74- .defaults ("myuser" , "mypass" )
75- .withRegistry (this .registry .getRegistry ())
76- .withInsecure (true )
73+ Registry registry = Registry .builder ()
74+ .insecure (this .registry .getRegistry (), "myuser" , "mypass" )
7775 .build ();
7876
7977 // Test
@@ -83,13 +81,11 @@ void shouldListRepositories() {
8381
8482 @ Test
8583 void shouldFailToPushBlobForInvalidDigest () {
86- Registry registry = Registry .Builder .builder ()
87- .defaults ("myuser" , "mypass" )
88- .withInsecure (true )
84+ Registry registry = Registry .builder ()
85+ .insecure (this .registry .getRegistry (), "myuser" , "mypass" )
8986 .build ();
9087 ContainerRef containerRef1 = ContainerRef .parse (
91- "%s/library/artifact-text@sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
92- .formatted (this .registry .getRegistry ()));
88+ "library/artifact-text@sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" );
9389 // Ensure the blob is deleted
9490 assertThrows (OrasException .class , () -> {
9591 registry .pushBlob (containerRef1 , "invalid" .getBytes ());
@@ -100,11 +96,11 @@ void shouldFailToPushBlobForInvalidDigest() {
10096 void shouldPushAndGetBlobThenDeleteWithSha256 () {
10197 Registry registry = Registry .Builder .builder ()
10298 .defaults ("myuser" , "mypass" )
99+ .withRegistry (this .registry .getRegistry ())
103100 .withInsecure (true )
104101 .build ();
105102 ContainerRef containerRef = ContainerRef .parse (
106- "%s/library/artifact-text@sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
107- .formatted (this .registry .getRegistry ()));
103+ "library/artifact-text@sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" );
108104 Layer layer = registry .pushBlob (containerRef , "hello" .getBytes ());
109105 assertEquals ("sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" , layer .getDigest ());
110106 byte [] blob = registry .getBlob (
@@ -156,12 +152,29 @@ void shouldFailWithoutAuthentication() {
156152 Registry registry = Registry .Builder .builder ().insecure ().build ();
157153 ContainerRef containerRef =
158154 ContainerRef .parse ("%s/library/artifact-text" .formatted (this .registry .getRegistry ()));
159- assertThrows (
160- OrasException .class ,
161- () -> {
162- registry .pushBlob (containerRef , "hello" .getBytes ());
163- },
164- "Response code: 401" );
155+ assertThrows (OrasException .class , () -> {
156+ registry .pushBlob (containerRef , "hello" .getBytes ());
157+ });
158+ }
159+
160+ @ Test
161+ void shouldFailWithoutAuthenticationAndRegistry () {
162+ Registry registry =
163+ Registry .Builder .builder ().insecure (this .registry .getRegistry ()).build ();
164+ ContainerRef containerRef = ContainerRef .parse ("library/artifact-text" );
165+ assertThrows (OrasException .class , () -> {
166+ registry .pushBlob (containerRef , "hello" .getBytes ());
167+ });
168+ }
169+
170+ @ Test
171+ void shouldFailWithSecureOnInsecure () {
172+ Registry registry =
173+ Registry .Builder .builder ().defaults (this .registry .getRegistry ()).build ();
174+ ContainerRef containerRef = ContainerRef .parse ("library/artifact-text" );
175+ assertThrows (OrasException .class , () -> {
176+ registry .pushBlob (containerRef , "hello" .getBytes ());
177+ });
165178 }
166179
167180 @ Test
0 commit comments