Search in sources :

Example 16 with TestResource

use of com.artipie.asto.test.TestResource 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 17 with TestResource

use of com.artipie.asto.test.TestResource 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 18 with TestResource

use of com.artipie.asto.test.TestResource 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 19 with TestResource

use of com.artipie.asto.test.TestResource in project artipie by artipie.

the class NpmITCase method npmInstall.

@Test
void npmInstall() throws Exception {
    this.containers.putBinaryToArtipie(new TestResource(String.format("npm/storage/%s/meta.json", NpmITCase.PROJ)).asBytes(), String.format("/var/artipie/data/my-npm/%s/meta.json", NpmITCase.PROJ));
    this.containers.putBinaryToArtipie(new TestResource(String.format("npm/storage/%s/-/%s-1.0.1.tgz", NpmITCase.PROJ, NpmITCase.PROJ)).asBytes(), String.format("/var/artipie/data/my-npm/%s/-/%s-1.0.1.tgz", NpmITCase.PROJ, NpmITCase.PROJ));
    this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(Arrays.asList(NpmITCase.ADDED_PROJ, "added 1 package"))), "npm", "install", NpmITCase.PROJ, "--registry", NpmITCase.REPO);
    this.containers.assertExec("Package was installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContains("@hello/simple-npm-project@1.0.1")), "npm", "list");
}
Also used : StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) TestResource(com.artipie.asto.test.TestResource) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 20 with TestResource

use of com.artipie.asto.test.TestResource in project artipie by artipie.

the class NpmITCase method npmPublish.

@Test
void npmPublish() throws Exception {
    final String tgz = String.format("%s/-/%s-1.0.1.tgz", NpmITCase.PROJ, NpmITCase.PROJ);
    this.containers.putBinaryToClient(new TestResource("npm/simple-npm-project/index.js").asBytes(), String.format("/w/%s/index.js", NpmITCase.PROJ));
    this.containers.putBinaryToClient(new TestResource("npm/simple-npm-project/package.json").asBytes(), String.format("/w/%s/package.json", NpmITCase.PROJ));
    this.containers.assertExec("Package was published", new ContainerResultMatcher(new IsEqual<>(0), new StringContains(NpmITCase.ADDED_PROJ)), "npm", "publish", NpmITCase.PROJ, "--registry", NpmITCase.REPO);
    this.containers.assertArtipieContent("Meta json is incorrect", String.format("/var/artipie/data/my-npm/%s/meta.json", NpmITCase.PROJ), new MatcherOf<>(bytes -> {
        return Json.createReader(new ByteArrayInputStream(bytes)).readObject().getJsonObject("versions").getJsonObject("1.0.1").getJsonObject("dist").getString("tarball").equals(String.format("/%s", tgz));
    }));
    this.containers.assertArtipieContent("Tarball should be added to storage", String.format("/var/artipie/data/my-npm/%s", tgz), new IsAnything<>());
}
Also used : ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) TestDeployment(com.artipie.test.TestDeployment) Arrays(java.util.Arrays) OS(org.junit.jupiter.api.condition.OS) StringContainsInOrder(org.hamcrest.text.StringContainsInOrder) Test(org.junit.jupiter.api.Test) StringContains(org.hamcrest.core.StringContains) ByteArrayInputStream(java.io.ByteArrayInputStream) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) IsAnything(org.hamcrest.core.IsAnything) IsEqual(org.hamcrest.core.IsEqual) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Json(javax.json.Json) MatcherOf(org.llorllale.cactoos.matchers.MatcherOf) TestResource(com.artipie.asto.test.TestResource) ByteArrayInputStream(java.io.ByteArrayInputStream) TestResource(com.artipie.asto.test.TestResource) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Aggregations

TestResource (com.artipie.asto.test.TestResource)20 Test (org.junit.jupiter.api.Test)16 IsEqual (org.hamcrest.core.IsEqual)10 Key (com.artipie.asto.Key)9 ContainerResultMatcher (com.artipie.test.ContainerResultMatcher)9 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)6 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)6 Storage (com.artipie.asto.Storage)5 StringContains (org.hamcrest.core.StringContains)5 StringContainsInOrder (org.hamcrest.text.StringContainsInOrder)5 Content (com.artipie.asto.Content)3 FileStorage (com.artipie.asto.fs.FileStorage)3 MatcherAssert (org.hamcrest.MatcherAssert)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 KeyLastPart (com.artipie.asto.ext.KeyLastPart)2 PublisherAs (com.artipie.asto.ext.PublisherAs)2 RepoSettings (com.artipie.front.settings.RepoSettings)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 MetadataXml (com.artipie.maven.MetadataXml)2