use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class PaginationImplTest method testClassLevelOverride.
@Test
public void testClassLevelOverride() {
@Paginate(maxLimit = 100000, defaultLimit = 10)
class PaginationOverrideTest {
}
MultivaluedMap<String, String> queryParams = new MultivaluedStringMap();
PaginationImpl pageData = PaginationImpl.parseQueryParams(ClassType.of(PaginationOverrideTest.class), queryParams, new ElideSettingsBuilder(null).withEntityDictionary(EntityDictionary.builder().build()).withDefaultPageSize(1).withDefaultMaxPageSize(1).build());
assertEquals(0, pageData.getOffset());
assertEquals(10, pageData.getLimit());
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class AggregationStorePermissionExecutorTest method setup.
@BeforeAll
public void setup() {
Map<String, Class<? extends Check>> checks = new HashMap<>();
checks.put("user all", Role.ALL.class);
checks.put("user none", Role.NONE.class);
checks.put("filter check", FilterCheck.class);
dictionary = TestDictionary.getTestDictionary(checks);
elideSettings = new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build();
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class ElideCustomSerdeRegistrationTest method testRegisterCustomSerde.
@Test
public void testRegisterCustomSerde() {
// Create a fake Elide. Don't actually bind any entities.
HashMapDataStore wrapped = new HashMapDataStore(DefaultClassScanner.getInstance(), String.class.getPackage());
InMemoryDataStore store = new InMemoryDataStore(wrapped);
ElideSettings elideSettings = new ElideSettingsBuilder(store).withEntityDictionary(EntityDictionary.builder().build()).build();
Elide elide = new Elide(elideSettings);
elide.doScans();
assertNotNull(CoerceUtil.lookup(Dummy.class));
assertNotNull(CoerceUtil.lookup(DummyTwo.class));
assertNotNull(CoerceUtil.lookup(DummyThree.class));
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class PermissionExpressionBuilderTest method setupEntityDictionary.
@BeforeEach
public void setupEntityDictionary() {
Map<String, Class<? extends Check>> checks = new HashMap<>();
checks.put("user has all access", Role.ALL.class);
checks.put("user has no access", Role.NONE.class);
dictionary = TestDictionary.getTestDictionary(checks);
ExpressionResultCache cache = new ExpressionResultCache();
builder = new PermissionExpressionBuilder(cache, dictionary);
elideSettings = new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build();
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class TableExportIT method tableExportModelAdminReadPermissions.
/**
* Tests Read Permissions on TableExport Model for Admin Role.
* @throws IOException IOException
*/
@Test
public void tableExportModelAdminReadPermissions() throws IOException {
ElideResponse response = null;
String id = "edc4a871-dff2-4054-804e-d80075c08959";
String query = "test-query";
com.yahoo.elide.async.models.TableExport queryObj = new com.yahoo.elide.async.models.TableExport();
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setResultType(ResultType.CSV);
queryObj.setQueryType(QueryType.JSONAPI_V1_0);
queryObj.setPrincipalName("owner-user");
EntityDictionary dictionary = EntityDictionary.builder().checks(AsyncIntegrationTestApplicationResourceConfig.MAPPINGS).build();
dataStore.populateEntityDictionary(dictionary);
DataStoreTransaction tx = dataStore.beginTransaction();
tx.createObject(queryObj, null);
tx.commit(null);
tx.close();
Elide elide = new Elide(new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withAuditLogger(new TestAuditLogger()).build());
User ownerUser = new User(() -> "owner-user");
SecurityContextUser securityContextAdminUser = new SecurityContextUser(new SecurityContext() {
@Override
public Principal getUserPrincipal() {
return () -> "1";
}
@Override
public boolean isUserInRole(String s) {
return true;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public String getAuthenticationScheme() {
return null;
}
});
SecurityContextUser securityContextNonAdminUser = new SecurityContextUser(new SecurityContext() {
@Override
public Principal getUserPrincipal() {
return () -> "2";
}
@Override
public boolean isUserInRole(String s) {
return false;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public String getAuthenticationScheme() {
return null;
}
});
String baseUrl = "/";
// Principal is Owner
response = elide.get(baseUrl, "/tableExport/" + id, new MultivaluedHashMap<>(), ownerUser, NO_VERSION);
assertEquals(HttpStatus.SC_OK, response.getResponseCode());
// Principal has Admin Role
response = elide.get(baseUrl, "/tableExport/" + id, new MultivaluedHashMap<>(), securityContextAdminUser, NO_VERSION);
assertEquals(HttpStatus.SC_OK, response.getResponseCode());
// Principal without Admin Role
response = elide.get(baseUrl, "/tableExport/" + id, new MultivaluedHashMap<>(), securityContextNonAdminUser, NO_VERSION);
assertEquals(HttpStatus.SC_NOT_FOUND, response.getResponseCode());
}
Aggregations