Search in sources :

Example 1 with RemoveAuthorizationPkgRuleRequest

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();
    }
}
Also used : User(org.haiku.haikudepotserver.dataobjects.User) RemoveAuthorizationPkgRuleRequest(org.haiku.haikudepotserver.api1.model.authorization.RemoveAuthorizationPkgRuleRequest) ObjectContext(org.apache.cayenne.ObjectContext) PermissionUserPkg(org.haiku.haikudepotserver.dataobjects.PermissionUserPkg) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectContext (org.apache.cayenne.ObjectContext)1 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 RemoveAuthorizationPkgRuleRequest (org.haiku.haikudepotserver.api1.model.authorization.RemoveAuthorizationPkgRuleRequest)1 PermissionUserPkg (org.haiku.haikudepotserver.dataobjects.PermissionUserPkg)1 User (org.haiku.haikudepotserver.dataobjects.User)1 Test (org.junit.jupiter.api.Test)1