Search in sources :

Example 1 with RepoPerms

use of com.artipie.repo.RepoPerms in project artipie by artipie.

the class YamlPermissionsTest method checksGroups.

@ParameterizedTest
@CsvSource(value = { "mark,read,readers,true", "olga,write,group-a;group-b,true", "john,read,abc;def,false", "jane,manage,readers;leaders,false", "ann,read,'',false" }, nullValues = "''")
void checksGroups(final String name, final String action, final String groups, final boolean res) {
    final YamlMapping settings = new RepoPerms(new ListOf<>(new RepoPermissions.PermissionItem(name, "write"), new RepoPermissions.PermissionItem("/readers", "read"))).permsYaml();
    MatcherAssert.assertThat(new YamlPermissions(settings).allowed(new Authentication.User(name, new ListOf<String>(groups.split(";"))), action), new IsEqual<>(res));
}
Also used : ListOf(org.cactoos.list.ListOf) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) RepoPerms(com.artipie.repo.RepoPerms) RepoPermissions(com.artipie.repo.RepoPermissions) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

YamlMapping (com.amihaiemil.eoyaml.YamlMapping)1 RepoPermissions (com.artipie.repo.RepoPermissions)1 RepoPerms (com.artipie.repo.RepoPerms)1 ListOf (org.cactoos.list.ListOf)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1