Search in sources :

Example 26 with ContainerResultMatcher

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

the class DockerLocalAuthIT method shouldFailPushIfNoWritePermission.

@Test
void shouldFailPushIfNoWritePermission() throws Exception {
    final String image = "artipie:8080/registry/alpine:3.11";
    List.of(Pair.of("Failed to login to Artipie", List.of("docker", "login", "--username", "bob", "--password", "qwerty", "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))).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("Push failed with unexpected status, should be 1", new ContainerResultMatcher(new IsEqual<>(1)), "docker", "push", 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)

Example 27 with ContainerResultMatcher

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

the class DebianGpgITCase method pushAndInstallWorks.

@Test
void pushAndInstallWorks() throws Exception {
    this.containers.assertExec("Failed to upload deb package", new ContainerResultMatcher(), "curl", "http://artipie:8080/my-debian/main/aglfn_1.7-3_amd64.deb", "--upload-file", "/w/aglfn_1.7-3_amd64.deb");
    this.containers.assertExec("Apt-get update failed", new ContainerResultMatcher(new IsEqual<>(0), new AllOf<String>(new ListOf<Matcher<? super String>>(new StringContains("Get:1 http://artipie:8080/my-debian my-debian InRelease"), new StringContains("Get:2 http://artipie:8080/my-debian my-debian/main amd64 Packages"), new IsNot<>(new StringContains("Get:3"))))), "apt-get", "update");
    this.containers.assertExec("Package was not downloaded and unpacked", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<>("Unpacking aglfn", "Setting up aglfn"))), "apt-get", "install", "-y", "aglfn");
}
Also used : IsNot(org.hamcrest.core.IsNot) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) Matcher(org.hamcrest.Matcher) StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) AllOf(org.hamcrest.core.AllOf) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 28 with ContainerResultMatcher

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

the class PypiProxyITCase method installFromProxy.

@Test
void installFromProxy() throws Exception {
    final byte[] data = new TestResource("pypi-repo/alarmtime-0.1.5.tar.gz").asBytes();
    this.containers.putBinaryToArtipie("artipie", data, "/var/artipie/data/my-pypi/alarmtime/alarmtime-0.1.5.tar.gz");
    this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), Matchers.containsString("Successfully installed alarmtime-0.1.5")), "pip", "install", "--no-deps", "--trusted-host", "artipie-proxy", "--index-url", "http://alice:123@artipie-proxy:8080/my-pypi-proxy/", "alarmtime");
    this.containers.assertArtipieContent("artipie-proxy", "/var/artipie/data/my-pypi-proxy/alarmtime/alarmtime-0.1.5.tar.gz", new IsEqual<>(data));
}
Also used : TestResource(com.artipie.asto.test.TestResource) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 29 with ContainerResultMatcher

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

the class NpmProxyITCase method installFromProxy.

@Test
void installFromProxy() throws Exception {
    this.containers.putBinaryToArtipie("artipie", new TestResource(String.format("npm/storage/%s/meta.json", NpmProxyITCase.PROJ)).asBytes(), String.format("/var/artipie/data/my-npm/%s/meta.json", NpmProxyITCase.PROJ));
    final byte[] tgz = new TestResource(String.format("npm/storage/%s/-/%s-1.0.1.tgz", NpmProxyITCase.PROJ, NpmProxyITCase.PROJ)).asBytes();
    this.containers.putBinaryToArtipie("artipie", tgz, String.format("/var/artipie/data/my-npm/%s/-/%s-1.0.1.tgz", NpmProxyITCase.PROJ, NpmProxyITCase.PROJ));
    this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(Arrays.asList(NpmProxyITCase.ADDED_PROJ, "added 1 package"))), "npm", "install", NpmProxyITCase.PROJ, "--registry", "http://artipie-proxy:8080/my-npm-proxy");
    this.containers.assertArtipieContent("artipie-proxy", "Package was not cached in proxy", String.format("/var/artipie/data/my-npm-proxy/%s/-/%s-1.0.1.tgz", NpmProxyITCase.PROJ, NpmProxyITCase.PROJ), new IsEqual<>(tgz));
}
Also used : StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) TestResource(com.artipie.asto.test.TestResource) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 30 with ContainerResultMatcher

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

the class PypiITCase method installPythonPackage.

@Test
void installPythonPackage() throws IOException {
    final String meta = "pypi-repo/example-pckg/dist/artipietestpkg-0.0.3.tar.gz";
    this.containers.putResourceToArtipie(meta, "/var/artipie/data/my-python/artipietestpkg/artipietestpkg-0.0.3.tar.gz");
    this.containers.assertExec("Failed to install package", new ContainerResultMatcher(Matchers.equalTo(0), new StringContainsInOrder(new ListOf<>("Looking in indexes: http://artipie:8080/my-python", "Collecting artipietestpkg", String.format("  Downloading http://artipie:8080/my-python/artipietestpkg/%s", "artipietestpkg-0.0.3.tar.gz"), "Building wheels for collected packages: artipietestpkg", "  Building wheel for artipietestpkg (setup.py): started", String.format("  Building wheel for artipietestpkg (setup.py): %s", "finished with status 'done'"), "Successfully built artipietestpkg", "Installing collected packages: artipietestpkg", "Successfully installed artipietestpkg-0.0.3"))), "python", "-m", "pip", "install", "--trusted-host", "artipie", "--index-url", "http://artipie:8080/my-python", "artipietestpkg");
}
Also used : StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) 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