@Override public void execute(CommandContext context) { entityManager.savePii(); }
@Test public void testDeploySearchOptionsWithFlowRunnerUser() throws IOException, SAXException { getDataHub().clearUserModules(); installEntities(); Path dir = Paths.get(PROJECT_PATH, HubConfig.ENTITY_CONFIG_DIR); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); //Deploy with flow runner getHubFlowRunnerConfig(); HashMap<Enum, Boolean> deployed = entityManager.deployQueryOptions(); //Change to admin config getHubAdminConfig(); //Search options files not written to modules db but created. assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertTrue(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); }
@Test public void testSaveDbIndexes() throws IOException { installEntities(); Path dir = getHubAdminConfig().getEntityDatabaseDir(); assertFalse(dir.resolve("final-database.json").toFile().exists()); assertFalse(dir.resolve("staging-database.json").toFile().exists()); assertTrue(entityManager.saveDbIndexes()); assertTrue(dir.resolve("final-database.json").toFile().exists()); assertTrue(dir.resolve("staging-database.json").toFile().exists()); assertJsonEqual(getResource("entity-manager-test/db-config.json"), FileUtils.readFileToString(dir.resolve("final-database.json").toFile()), true); assertJsonEqual(getResource("entity-manager-test/db-config.json"), FileUtils.readFileToString(dir.resolve("staging-database.json").toFile()), true); updateManagerEntity(); assertTrue(entityManager.saveDbIndexes()); assertJsonEqual(getResource("entity-manager-test/db-config2.json"), FileUtils.readFileToString(dir.resolve("final-database.json").toFile()), true); assertJsonEqual(getResource("entity-manager-test/db-config2.json"), FileUtils.readFileToString(dir.resolve("staging-database.json").toFile()), true); // try a deploy too /* this section causes a state change in the db that's hard to tear down/ so it's excluded from our automated testing for the time being try { getDataHub().updateIndexes(); // pass } catch (Exception e) { throw (e); } */ }
entityManager.deployQueryOptions();
@Test @Tag("NoAWS") public void testDeployPiiConfigurations() throws IOException { installEntities(); ObjectMapper mapper = new ObjectMapper(); Path dir = getHubAdminConfig().getHubEntitiesDir(); // deploy is separate entityManager.savePii(); File protectedPathConfig = getHubAdminConfig().getUserSecurityDir().resolve("protected-paths/01_" + HubConfig.PII_PROTECTED_PATHS_FILE).toFile(); File secondProtectedPathConfig = getHubAdminConfig().getUserSecurityDir().resolve("protected-paths/02_" + HubConfig.PII_PROTECTED_PATHS_FILE).toFile(); File queryRolesetsConfig = getHubAdminConfig().getUserSecurityDir().resolve("query-rolesets/" + HubConfig.PII_QUERY_ROLESET_FILE).toFile(); // assert that ELS configuation is in project JsonNode protectedPaths = mapper.readTree(protectedPathConfig); assertTrue(protectedPaths.get("path-expression").isTextual(), "Protected Path Config should have path expression."); protectedPaths = mapper.readTree(secondProtectedPathConfig); assertTrue(protectedPaths.get("path-expression").isTextual(), "Protected Path Config should have path expression."); JsonNode rolesets = mapper.readTree(queryRolesetsConfig); assertEquals( "pii-reader", rolesets.get("role-name").get(0).asText(), "Config should have one roleset, pii-reader."); } }
@Test public void testDeploySearchOptionsWithNoEntities() { getDataHub().clearUserModules(); Path dir = project.getEntityConfigDir(); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); // this should be true regardless assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); HashMap<Enum, Boolean> deployed = entityManager.deployQueryOptions(); assertEquals(0, deployed.size()); assertFalse(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertFalse(Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); assertEquals(0, getStagingDocCount()); assertEquals(0, getFinalDocCount()); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_STAGING_NAME + "/rest-api/options/" + HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE)); assertNull(getModulesFile("/Default/" + HubConfig.DEFAULT_FINAL_NAME + "/rest-api/options/" + HubConfig.FINAL_ENTITY_QUERY_OPTIONS_FILE)); }
@Test public void testSavePii() throws Exception { installEntities(); entityManager.savePii(); verifyResults(getHubAdminConfig().getUserSecurityDir()); }
assertEquals(0, getFinalDocCount()); HashMap<Enum, Boolean> deployed = entityManager.deployQueryOptions(); deployed = entityManager.deployQueryOptions(); assertEquals(2, deployed.size()); assertTrue(Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_QUERY_OPTIONS_FILE).toFile().exists()); deployed = entityManager.deployQueryOptions(); assertEquals(0, deployed.size());
entityManager.savePii();