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));
}
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;
}
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))));
}
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);
}
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)));
}
Aggregations