Changes by review and merge fix
@@ -28,18 +28,19 @@ import com.artipie.RepoConfig;
import com.artipie.asto.Key;
import com.artipie.http.Headers;
import com.artipie.http.Slice;
+import com.artipie.http.auth.Permissions;
import com.artipie.http.hm.RsHasStatus;
import com.artipie.http.rq.RequestLine;
import com.artipie.http.rq.RqMethod;
import com.artipie.http.rs.RsStatus;
import io.reactivex.Flowable;
import java.io.IOException;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
import org.eclipse.jetty.client.HttpClient;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -51,33 +52,13 @@ import org.junit.jupiter.params.provider.MethodSource;
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
class DockerProxyTest {
- @Test
- void shouldBuildFromConfig() throws Exception {
- final Slice slice = dockerProxy(
- String.join(
- "\n",
- "repo:",
- " type: docker-proxy",
- " remotes:",
- " - url: registry-1.docker.io",
- " username: admin",
- " password: qwerty",
- " cache:",
- " storage:",
- " type: fs",
- " path: /var/artipie/data/cache",
- " - url: another-registry.org:54321",
- " - url: mcr.microsoft.com",
- " cache:",
- " storage: my-storage",
- " storage:",
- " type: fs",
- " path: /var/artipie/data/local"
- )
- );
+ @ParameterizedTest
+ @MethodSource("goodConfigs")
+ void shouldBuildFromConfig(final String yaml) throws Exception {
+ final Slice slice = dockerProxy(yaml);
MatcherAssert.assertThat(
slice.response(
- new RequestLine(RqMethod.GET, "/v2/").toString(),
+ new RequestLine(RqMethod.GET, "/").toString(),
Headers.EMPTY,
Flowable.empty()
),
@@ -92,7 +73,7 @@ class DockerProxyTest {
Assertions.assertThrows(
RuntimeException.class,
() -> slice.response(
- new RequestLine(RqMethod.GET, "/v2/").toString(),
+ new RequestLine(RqMethod.GET, "/").toString(),
Headers.EMPTY,
Flowable.empty()
).send(
@@ -110,6 +91,35 @@ class DockerProxyTest {
},
Key.ROOT,
Yaml.createYamlInput(yaml).readYamlMapping()
+ ),
+ Permissions.FREE,
+ (username, password) -> Optional.empty()
+ );
+ }
+
+ @SuppressWarnings("PMD.UnusedPrivateMethod")
+ private static Stream<String> goodConfigs() {
+ return Stream.of(
+ "repo:\n remotes:\n - url: registry-1.docker.io",
+ String.join(
+ "\n",
+ "repo:",
+ " type: docker-proxy",
+ " remotes:",
+ " - url: registry-1.docker.io",
+ " username: admin",
+ " password: qwerty",
+ " cache:",
+ " storage:",
+ " type: fs",
+ " path: /var/artipie/data/cache",
+ " - url: another-registry.org:54321",
+ " - url: mcr.microsoft.com",
+ " cache:",
+ " storage: my-storage",
+ " storage:",
+ " type: fs",
+ " path: /var/artipie/data/local"
)
);
}
