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