Search in sources :

Example 21 with ContainerResultMatcher

use of com.artipie.test.ContainerResultMatcher in project artipie by artipie.

the class FileProxyAuthIT method shouldGetAndCacheFile.

@Test
void shouldGetAndCacheFile() throws Exception {
    final byte[] data = "Hello world!".getBytes();
    this.containers.putBinaryToArtipie("artipie", data, "/var/artipie/data/my-bin/foo/bar.txt");
    this.containers.assertExec("File was not downloaded", new ContainerResultMatcher(new IsEqual<>(0), new StringContains("HTTP/1.1 200 OK")), "curl", "-i", "-X", "GET", "http://artipie-proxy:8080/my-bin-proxy/foo/bar.txt");
}
Also used : ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 22 with ContainerResultMatcher

use of com.artipie.test.ContainerResultMatcher in project artipie by artipie.

the class GemITCase method gemPushAndInstallWorks.

@Test
void gemPushAndInstallWorks() throws IOException {
    this.containers.assertExec("Packages was not pushed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>("POST http://artipie:8080/my-gem/api/v1/gems", "201 Created"))), "env", String.format("GEM_HOST_API_KEY=%s", new Base64Encoded("any:any").asString()), "gem", "push", "-v", "/w/rails-6.0.2.2.gem", "--host", "http://artipie:8080/my-gem");
    this.containers.assertArtipieContent("Package was not added to storage", String.format("/var/artipie/data/my-gem/gems/%s", GemITCase.RAILS), new IsEqual<>(new TestResource(String.format("gem/%s", GemITCase.RAILS)).asBytes()));
    this.containers.assertExec("rubygems.org was not removed from sources", new ContainerResultMatcher(), "gem", "sources", "--remove", "https://rubygems.org/");
    this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>(String.format("GET http://artipie:8080/my-gem/quick/Marshal.4.8/%sspec.rz", GemITCase.RAILS), "200 OK", "Successfully installed rails-6.0.2.2", "1 gem installed"))), "gem", "install", GemITCase.RAILS, "--source", "http://artipie:8080/my-gem", "--ignore-dependencies", "-V");
}
Also used : StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) TestResource(com.artipie.asto.test.TestResource) Base64Encoded(org.cactoos.text.Base64Encoded) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 23 with ContainerResultMatcher

use of com.artipie.test.ContainerResultMatcher in project artipie by artipie.

the class VertxMainITCase method worksWhenRepoConfigsKeyIsPresent.

@Test
void worksWhenRepoConfigsKeyIsPresent() throws IOException {
    this.deployment.putBinaryToArtipie("artipie-config-key-present", "Hello world".getBytes(), "/var/artipie/data/my-file/item.txt");
    this.deployment.assertExec("Artipie isn't started or not responding 200", new ContainerResultMatcher(ContainerResultMatcher.SUCCESS, new StringContains("HTTP/1.1 200 OK")), "curl", "-i", "-X", "GET", "http://artipie-config-key-present:8080/my-file/item.txt");
}
Also used : ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 24 with ContainerResultMatcher

use of com.artipie.test.ContainerResultMatcher in project artipie by artipie.

the class MavenProxyAuthIT method shouldGetDependency.

@Test
void shouldGetDependency() throws Exception {
    this.containers.putResourceToArtipie("artipie", "com/artipie/helloworld/maven-metadata.xml", "/var/artipie/data/my-maven/com/artipie/helloworld/maven-metadata.xml");
    MavenITCase.getResourceFiles("com/artipie/helloworld/0.1").stream().map(item -> String.join("/", "com/artipie/helloworld/0.1", item)).forEach(item -> this.containers.putResourceToArtipie(item, String.join("/", "/var/artipie/data/my-maven", item)));
    this.containers.assertExec("Helloworld was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContains("BUILD SUCCESS")), "mvn", "-s", "settings.xml", "dependency:get", "-Dartifact=com.artipie:helloworld:0.1:jar");
    this.containers.assertArtipieContent("artipie-proxy", "Artifact was not cached in proxy", "/var/artipie/data/my-maven-proxy/com/artipie/helloworld/0.1/helloworld-0.1.jar", new IsEqual<>(new TestResource("com/artipie/helloworld/0.1/helloworld-0.1.jar").asBytes()));
}
Also used : ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) Test(org.junit.jupiter.api.Test) TestDeployment(com.artipie.test.TestDeployment) BindMode(org.testcontainers.containers.BindMode) StringContains(org.hamcrest.core.StringContains) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) OS(org.junit.jupiter.api.condition.OS) MapOf(org.cactoos.map.MapOf) IsEqual(org.hamcrest.core.IsEqual) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) TestResource(com.artipie.asto.test.TestResource) MapEntry(org.cactoos.map.MapEntry) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) TestResource(com.artipie.asto.test.TestResource) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 25 with ContainerResultMatcher

use of com.artipie.test.ContainerResultMatcher in project artipie by artipie.

the class DockerLocalAuthIT method shouldFailPullIfAnonymous.

@Test
void shouldFailPullIfAnonymous() throws IOException {
    final String image = "artipie:8080/registry/alpine:3.11";
    List.of(Pair.of("Failed to login to Artipie", List.of("docker", "login", "--username", "alice", "--password", "123", "artipie:8080")), Pair.of("Failed to pull origin image", List.of("docker", "pull", "alpine:3.11")), Pair.of("Failed to tag origin image", List.of("docker", "tag", "alpine:3.11", image)), Pair.of("Failed to push image to Artipie", List.of("docker", "push", image)), Pair.of("Failed to remove local image", List.of("docker", "image", "rm", image)), Pair.of("Failed to logout", List.of("docker", "logout", "artipie:8080"))).forEach(pair -> pair.accept((msg, cmds) -> {
        try {
            this.deployment.assertExec(msg, new ContainerResultMatcher(), cmds);
        } catch (final IOException err) {
            throw new UncheckedIOException(err);
        }
    }));
    this.deployment.assertExec("Pull failed with unexpected status, should be 1", new ContainerResultMatcher(new IsEqual<>(1)), "docker", "pull", image);
}
Also used : ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) UncheckedIOException(java.io.UncheckedIOException) Test(org.junit.jupiter.api.Test) TestDeployment(com.artipie.test.TestDeployment) BeforeEach(org.junit.jupiter.api.BeforeEach) List(java.util.List) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) OS(org.junit.jupiter.api.condition.OS) IsEqual(org.hamcrest.core.IsEqual) Pair(wtf.g4s8.tuples.Pair) IOException(java.io.IOException) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) UncheckedIOException(java.io.UncheckedIOException) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Aggregations

ContainerResultMatcher (com.artipie.test.ContainerResultMatcher)34 Test (org.junit.jupiter.api.Test)27 IsEqual (org.hamcrest.core.IsEqual)20 StringContains (org.hamcrest.core.StringContains)14 TestResource (com.artipie.asto.test.TestResource)10 StringContainsInOrder (org.hamcrest.text.StringContainsInOrder)10 BeforeEach (org.junit.jupiter.api.BeforeEach)8 TestDeployment (com.artipie.test.TestDeployment)7 OS (org.junit.jupiter.api.condition.OS)7 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)7 DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)6 IOException (java.io.IOException)4 UncheckedIOException (java.io.UncheckedIOException)4 List (java.util.List)4 BindMode (org.testcontainers.containers.BindMode)3 Pair (wtf.g4s8.tuples.Pair)3 MapEntry (org.cactoos.map.MapEntry)2 MapOf (org.cactoos.map.MapOf)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 CsvSource (org.junit.jupiter.params.provider.CsvSource)2