Search in sources :

Example 6 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class NonEntityQueryTest method testIdentificationVariableDeniedSecurity.

@Test
public void testIdentificationVariableDeniedSecurity() throws Exception {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    configStorageService.setDbProperty("cuba.disableLoadValuesIfConstraints", "true");
    LoginWorker lw = AppBeans.get(LoginWorker.NAME);
    UserSession userSession = lw.login(USER_NAME_1, passwordEncryption.getPlainHash(USER_PASSWORD), Locale.getDefault());
    assertNotNull(userSession);
    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        ValueLoadContext context = ValueLoadContext.create();
        context.setQueryString("select s from sys$EntitySnapshot s");
        context.addProperty("snapshot");
        List result = dataManager.secure().loadValues(context);
        assertTrue(result.isEmpty());
    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
Also used : LoginWorker(com.haulmont.cuba.security.app.LoginWorker) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) UserSession(com.haulmont.cuba.security.global.UserSession) List(java.util.List) Test(org.junit.Test)

Aggregations

ConfigStorageService (com.haulmont.cuba.core.app.ConfigStorageService)6 LoginWorker (com.haulmont.cuba.security.app.LoginWorker)4 UserSession (com.haulmont.cuba.security.global.UserSession)4 TestUserSessionSource (com.haulmont.cuba.testsupport.TestUserSessionSource)4 Test (org.junit.Test)4 AppPropertyEntity (com.haulmont.cuba.core.config.AppPropertyEntity)2 ConfigurationClientImpl (com.haulmont.cuba.client.sys.ConfigurationClientImpl)1 AppPropertiesLocator (com.haulmont.cuba.core.config.AppPropertiesLocator)1 KeyValueEntity (com.haulmont.cuba.core.entity.KeyValueEntity)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 List (java.util.List)1