Search in sources :

Example 1 with SettingsCaches

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

the class YamlSettingsTest method getsCredentialsFromCache.

@Test
void getsCredentialsFromCache(@TempDir final Path tmp) throws IOException {
    final String fname = "_cred.yml";
    final SettingsCaches cache = new SettingsCaches.All();
    final YamlSettings settings = new YamlSettings(this.config(tmp.toString(), this.credentials("file", Optional.of(fname))), cache);
    Files.writeString(tmp.resolve(fname), this.credentials());
    settings.credentials().toCompletableFuture().join().list().toCompletableFuture().join();
    Files.writeString(tmp.resolve(fname), "not valid yaml file");
    MatcherAssert.assertThat("Storage configuration was not cached", cache.credsConfig().toString(), new StringContains("size=1"));
    MatcherAssert.assertThat("Invalid yaml file was used, although credentials from cache should be used", settings.credentials().toCompletableFuture().join().list().toCompletableFuture().join().size(), new IsEqual<>(1));
}
Also used : SettingsCaches(com.artipie.cache.SettingsCaches) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SettingsCaches (com.artipie.cache.SettingsCaches)1 StringContains (org.hamcrest.core.StringContains)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1