use of org.haiku.haikudepotserver.api1.model.authorization.RemoveAuthorizationPkgRuleRequest in project haikudepotserver by haiku.
the class AuthorizationApiIT method testRemoveAuthorizationRule_permissionUserPkg.
@Test
public void testRemoveAuthorizationRule_permissionUserPkg() {
integrationTestSupportService.createStandardTestData();
setAuthenticatedUserToRoot();
{
ObjectContext context = serverRuntime.newContext();
User user = integrationTestSupportService.createBasicUser(context, "testuser", "fakepassword");
PermissionUserPkg permissionUserPkg = context.newObject(PermissionUserPkg.class);
permissionUserPkg.setPermission(org.haiku.haikudepotserver.dataobjects.Permission.getByCode(context, Permission.PKG_EDITICON.name().toLowerCase()).get());
permissionUserPkg.setUser(user);
permissionUserPkg.setPkg(Pkg.tryGetByName(context, "pkg1").get());
context.commitChanges();
}
RemoveAuthorizationPkgRuleRequest request = new RemoveAuthorizationPkgRuleRequest();
request.userNickname = "testuser";
request.permissionCode = Permission.PKG_EDITICON.name().toLowerCase();
request.pkgName = "pkg1";
// ------------------------------------
authorizationApi.removeAuthorizationPkgRule(request);
// ------------------------------------
{
ObjectContext context = serverRuntime.newContext();
Assertions.assertThat(PermissionUserPkg.getByPermissionUserAndPkg(context, org.haiku.haikudepotserver.dataobjects.Permission.getByCode(context, Permission.PKG_EDITICON.name().toLowerCase()).get(), User.tryGetByNickname(context, "testuser").get(), Pkg.tryGetByName(context, "pkg1").get()).isPresent()).isFalse();
}
}
Aggregations