Search in sources :

Example 1 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project front by artipie.

the class DeleteUserTest method init.

@BeforeEach
void init() {
    this.blsto = new BlockingStorage(new InMemoryStorage());
    this.users = new YamlUsers(DeleteUserTest.KEY, this.blsto);
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) YamlUsers(com.artipie.front.auth.YamlUsers) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project front by artipie.

the class RepositoriesTest method listsRepositories.

@Test
void listsRepositories() throws JSONException {
    final BlockingStorage blsto = new BlockingStorage(new InMemoryStorage());
    blsto.save(new Key.From("Jane", "maven.yaml"), new byte[] {});
    blsto.save(new Key.From("Jane", "python.yaml"), new byte[] {});
    blsto.save(new Key.From("Jane", "binary.yaml"), new byte[] {});
    blsto.save(new Key.From("John", "anaconda.yml"), new byte[] {});
    blsto.save(new Key.From("John", "maven.yml"), new byte[] {});
    blsto.save(new Key.From("rpm.yml"), new byte[] {});
    final var resp = Mockito.mock(Response.class);
    JSONAssert.assertEquals(new Repositories(new RepoSettings("org", blsto)).handle(Mockito.mock(Request.class), resp), String.join("\n", "[", "{\"fullName\":\"Jane/binary\"},", "{\"fullName\":\"Jane/maven\"},", "{\"fullName\":\"Jane/python\"},", "{\"fullName\":\"John/anaconda\"},", "{\"fullName\":\"John/maven\"},", "{\"fullName\":\"rpm\"}", "]"), true);
    Mockito.verify(resp).type("application/json");
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RepoSettings(com.artipie.front.settings.RepoSettings) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 3 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project front by artipie.

the class UsersTest method init.

@BeforeEach
void init() {
    this.blsto = new BlockingStorage(new InMemoryStorage());
    this.users = new YamlUsers(UsersTest.CREDS, this.blsto);
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) YamlUsers(com.artipie.front.auth.YamlUsers) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class ConfigFileTest method valueFromStorageReturnsYamlWhenBothExist.

@Test
void valueFromStorageReturnsYamlWhenBothExist() {
    final Storage storage = new InMemoryStorage();
    final String yaml = String.join("", Arrays.toString(ConfigFileTest.CONTENT), "some");
    this.saveByKey(storage, ".yml");
    this.saveByKey(storage, ".yaml", yaml.getBytes());
    MatcherAssert.assertThat(new PublisherAs(new ConfigFile(new Key.From(ConfigFileTest.NAME)).valueFrom(storage).toCompletableFuture().join()).asciiString().toCompletableFuture().join(), new IsEqual<>(yaml));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) PublisherAs(com.artipie.asto.ext.PublisherAs) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class CachedCredsTest method getsOriginForSameConfigurationButDifferentStorages.

@Test
void getsOriginForSameConfigurationButDifferentStorages() {
    final String path = "_credentials.yaml";
    final Key key = new Key.From(path);
    final CredsConfigCache configs = new CachedCreds(this.cache);
    final Storage another = new InMemoryStorage();
    new TestResource(path).saveTo(this.storage);
    new BlockingStorage(another).save(key, "credentials: another val".getBytes(StandardCharsets.UTF_8));
    final YamlMapping frst = configs.credentials(this.storage, key).toCompletableFuture().join();
    final YamlMapping scnd = configs.credentials(another, key).toCompletableFuture().join();
    MatcherAssert.assertThat("Obtained configurations were the same", frst.equals(scnd), new IsEqual<>(false));
    MatcherAssert.assertThat("Credentials configuration was not cached", this.cache.size(), new IsEqual<>(2L));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) TestResource(com.artipie.asto.test.TestResource) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Aggregations

InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)30 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)17 Key (com.artipie.asto.Key)16 Storage (com.artipie.asto.Storage)14 BeforeEach (org.junit.jupiter.api.BeforeEach)14 Test (org.junit.jupiter.api.Test)13 RsHasStatus (com.artipie.http.hm.RsHasStatus)6 LoggingSlice (com.artipie.http.slice.LoggingSlice)4 VertxSliceServer (com.artipie.vertx.VertxSliceServer)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 PublisherAs (com.artipie.asto.ext.PublisherAs)3 TestResource (com.artipie.asto.test.TestResource)3 YamlUsers (com.artipie.front.auth.YamlUsers)3 RepoSettings (com.artipie.front.settings.RepoSettings)3 RsHasBody (com.artipie.http.hm.RsHasBody)3 Content (com.artipie.asto.Content)2 FromStorageCache (com.artipie.asto.cache.FromStorageCache)2 Authentication (com.artipie.http.auth.Authentication)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 RequestLine (com.artipie.http.rq.RequestLine)2