Search in sources :

Example 6 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project artipie by artipie.

the class RepositoriesFromStorageCacheTest method readAliasesFromCache.

@Test
void readAliasesFromCache() {
    final Key alias = new Key.From("_storages.yaml");
    final Key config = new Key.From("bin.yaml");
    new TestResource(alias.string()).saveTo(this.storage);
    new BlockingStorage(this.storage).save(config, "repo:\n  storage: default".getBytes());
    final ClientSlices http = new JettyClientSlices();
    new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join();
    this.storage.save(alias, Content.EMPTY).join();
    MatcherAssert.assertThat(new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join().storageOpt().isPresent(), new IsEqual<>(true));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) ClientSlices(com.artipie.http.client.ClientSlices) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) Test(org.junit.jupiter.api.Test)

Example 7 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project artipie by artipie.

the class SettingsFromPath method find.

/**
 * Searches settings by the provided path, if no settings are found,
 * example setting set is used.
 * @param port Port for info logging
 * @return Artipie settings
 * @throws IOException On IO error
 */
public Settings find(final int port) throws IOException {
    boolean initialize = Boolean.parseBoolean(System.getenv("ARTIPIE_INIT"));
    if (!Files.exists(this.path)) {
        new JavaResource("example/artipie.yaml").copy(this.path);
        initialize = true;
    }
    final Settings settings = new YamlSettings(Yaml.createYamlInput(this.path.toFile()).readYamlMapping(), new SettingsCaches.All());
    final BlockingStorage bsto = new BlockingStorage(settings.storage());
    final Key init = new Key.From(".artipie", "initialized");
    if (initialize && !bsto.exists(init)) {
        final List<String> resources = Arrays.asList("_credentials.yaml", StorageAliases.FILE_NAME, "_permissions.yaml");
        for (final String res : resources) {
            final Path tmp = Files.createTempFile(res, ".tmp");
            new JavaResource(String.format("example/repo/%s", res)).copy(tmp);
            bsto.save(new Key.From(res), Files.readAllBytes(tmp));
            Files.delete(tmp);
        }
        bsto.save(init, "true".getBytes());
        Logger.info(VertxMain.class, String.join("\n", "", "", "\t+===============================================================+", "\t\t\t\t\tHello!", "\t\tArtipie configuration was not found, created default.", "\t\t\tDefault username/password: `artipie`/`artipie`. ", "\t\t\t\t   Check the dashboard at:", String.format("\t\t\thttp://localhost:%d/dashboard/artipie", port), "\t-===============================================================-", ""));
    }
    return settings;
}
Also used : Path(java.nio.file.Path) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) SettingsCaches(com.artipie.cache.SettingsCaches) Key(com.artipie.asto.Key)

Example 8 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class AstoMavenTest method addFilesToStorage.

private void addFilesToStorage(final Predicate<String> condition, final Key base) {
    final Storage resources = new FileStorage(new TestResource("com/artipie/asto").asPath());
    final BlockingStorage bsto = new BlockingStorage(resources);
    bsto.list(Key.ROOT).stream().map(Key::string).filter(condition).forEach(item -> new BlockingStorage(this.storage).save(new Key.From(base, item), bsto.value(new Key.From(item))));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) FileStorage(com.artipie.asto.fs.FileStorage) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key)

Example 9 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class AstoValidUploadTest method init.

@BeforeEach
void init() {
    this.storage = new InMemoryStorage();
    this.bsto = new BlockingStorage(this.storage);
    this.validupload = new AstoValidUpload(this.storage);
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class RepositoryChecksumsTest method findsArtifactChecksums.

@Test
void findsArtifactChecksums() throws Exception {
    // @checkstyle LocalFinalVariableNameCheck (20 lines)
    final Storage storage = new InMemoryStorage();
    final BlockingStorage bsto = new BlockingStorage(storage);
    final Key.From artifact = new Key.From("com/test/1.0/my-package.jar");
    bsto.save(artifact, "artifact".getBytes());
    final String sha1 = "c71de136f9377eca14b4218cc7001c8060c6974f";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha1"), sha1.getBytes(StandardCharsets.UTF_8));
    final String sha256 = "62090f2241986a8361242e47cf541657099fdccc0c08e34cd694922bdcf31893";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha256"), sha256.getBytes(StandardCharsets.UTF_8));
    // @checkstyle LineLengthCheck (1 line)
    final String sha512 = "cf713dd3f077719375e646a23dee1375725652f5f275b0bf25d326062b3a64535575acde6d27b547fcd735c870cf94badc4b2215aba9c3af5085567b4561ac28";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha512"), sha512.getBytes(StandardCharsets.UTF_8));
    final String mdfive = "dc829bf0d79e690c59cee708b527e6b7";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.md5"), mdfive.getBytes(StandardCharsets.UTF_8));
    MatcherAssert.assertThat(new RepositoryChecksums(storage).checksums(artifact).toCompletableFuture().get(), Matchers.allOf(Matchers.hasEntry("sha1", sha1), Matchers.hasEntry("sha256", sha256), Matchers.hasEntry("sha512", sha512), Matchers.hasEntry("md5", mdfive)));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Aggregations

BlockingStorage (com.artipie.asto.blocking.BlockingStorage)19 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)15 Key (com.artipie.asto.Key)13 Test (org.junit.jupiter.api.Test)10 Storage (com.artipie.asto.Storage)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 TestResource (com.artipie.asto.test.TestResource)4 YamlUsers (com.artipie.front.auth.YamlUsers)3 RepoSettings (com.artipie.front.settings.RepoSettings)3 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)2 ClientSlices (com.artipie.http.client.ClientSlices)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 RsHasBody (com.artipie.http.hm.RsHasBody)2 RsHasStatus (com.artipie.http.hm.RsHasStatus)2 FileStorage (com.artipie.asto.fs.FileStorage)1 SettingsCaches (com.artipie.cache.SettingsCaches)1 Path (java.nio.file.Path)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1