Search in sources :

Example 1 with CachedCreds

use of com.artipie.cache.CachedCreds in project artipie by artipie.

the class UsersFromStorageYamlTest method readsCredentialsFromCache.

@Test
void readsCredentialsFromCache() {
    final CachedCreds cache = new CachedCreds();
    new TestResource("_credentials.yaml").saveTo(this.storage, this.key);
    final UsersFromStorageYaml creds = new UsersFromStorageYaml(this.storage, this.key, cache);
    creds.yaml().toCompletableFuture().join();
    this.saveCreds(Users.PasswordFormat.PLAIN, Pair.of(new Users.User("pol"), "newpswd"));
    MatcherAssert.assertThat(creds.yaml().toCompletableFuture().join().yamlMapping("credentials").keys().stream().map(YamlNode::asScalar).map(Scalar::value).toList(), Matchers.containsInAnyOrder("bob", "alice"));
}
Also used : TestResource(com.artipie.asto.test.TestResource) CachedCreds(com.artipie.cache.CachedCreds) Scalar(com.amihaiemil.eoyaml.Scalar) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CachedCreds

use of com.artipie.cache.CachedCreds in project artipie by artipie.

the class UsersFromStorageYamlTest method readsYamlWithEmailFromStorage.

@Test
void readsYamlWithEmailFromStorage() {
    final Users.User jane = new Users.User("jane", this.email("jane"), new SetOf<String>("readers"));
    final Users.User john = new Users.User("john", this.email("john"), new SetOf<String>("reviewers", "supporters"));
    final Users.PasswordFormat sha = Users.PasswordFormat.SHA256;
    final String pass = "111";
    this.saveCreds(sha, Pair.of(jane, pass), Pair.of(john, pass));
    MatcherAssert.assertThat(new UsersFromStorageYaml(this.storage, this.key, new CachedCreds()).list().toCompletableFuture().join(), Matchers.containsInAnyOrder(jane, john));
}
Also used : Users(com.artipie.auth.Users) CachedCreds(com.artipie.cache.CachedCreds) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CachedCreds

use of com.artipie.cache.CachedCreds in project artipie by artipie.

the class UsersFromStorageYamlTest method readsYamlFromStorage.

@ParameterizedTest
@ValueSource(strings = { ".yaml", ".yml", "" })
void readsYamlFromStorage(final String extension) {
    final Users.User jane = new Users.User("maria");
    final Users.User john = new Users.User("olga");
    new CredsConfigYaml().withUsers(jane.name(), john.name()).saveTo(this.storage, this.key);
    MatcherAssert.assertThat(new UsersFromStorageYaml(this.storage, new Key.From(String.format("_cred%s", extension)), new CachedCreds()).list().toCompletableFuture().join(), Matchers.containsInAnyOrder(jane, john));
}
Also used : Users(com.artipie.auth.Users) CachedCreds(com.artipie.cache.CachedCreds) Key(com.artipie.asto.Key) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CachedCreds (com.artipie.cache.CachedCreds)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Users (com.artipie.auth.Users)2 Test (org.junit.jupiter.api.Test)2 Scalar (com.amihaiemil.eoyaml.Scalar)1 Key (com.artipie.asto.Key)1 TestResource (com.artipie.asto.test.TestResource)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1