@Test @RunWithCustomExecutor public void should_fail_silently_when_update_request_with_classification_rules_not_allowed() throws Exception { List<String> allowedValues = new ArrayList<>(); allowedValues.add("Secret Défense"); allowedValues.add("Confidentiel Défense"); ClassificationLevel classificationLevel = new ClassificationLevel(); classificationLevel.setAllowList(allowedValues); classificationLevel.setAuthorizeNotDefined(true); VitamConfiguration.setClassificationLevel(classificationLevel); String updateClassificationLevel = "{\"$roots\":[\"aeaqaaaaaafyfdwnabt3salhtwrmdfqaaabq\"],\"$query\":[],\"$filter\":{},\"$action\":[{\"$set\":{\"#management.ClassificationRule.ClassificationLevel\":\"NotAllowedValue\"}}]}"; Assertions.assertThatCode( () -> accessModuleImpl.checkClassificationLevel(fromStringToJson(updateClassificationLevel))) .hasMessageContaining("Classification Level is not in the list of allowed values"); }
public void checkClassificationLevel(JsonNode query) throws InvalidParseOperationException { String classificationFieldName = VitamFieldsHelper.management() + "." + VitamConstants.TAG_RULE_CLASSIFICATION + "." + SedaConstants.TAG_RULE_CLASSIFICATION_LEVEL; JsonNode classificationLevel = getValueForUpdateDsl(query, classificationFieldName); String classificationLevelValue; if (classificationLevel == null) { return; } if (!classificationLevel.isTextual()) { throw new IllegalArgumentException("Illegal value for Classification Level. Expected string"); } classificationLevelValue = classificationLevel.asText(); if (!ClassificationLevelUtil.checkClassificationLevel(classificationLevelValue)) { throw new IllegalArgumentException("Classification Level is not in the list of allowed values"); } }
AccessInternalModuleImpl implements AccessInternalModule { public void checkClassificationLevel(JsonNode query) throws InvalidParseOperationException { String classificationFieldName = VitamFieldsHelper.management() + "." + VitamConstants.TAG_RULE_CLASSIFICATION + "." + SedaConstants.TAG_RULE_CLASSIFICATION_LEVEL; JsonNode classificationLevel = getValueForUpdateDsl(query, classificationFieldName); String classificationLevelValue; if (classificationLevel == null) { return; } if (!classificationLevel.isTextual()) { throw new IllegalArgumentException("Illegal value for Classification Level. Expected string"); } classificationLevelValue = classificationLevel.asText(); if (!ClassificationLevelUtil.checkClassificationLevel(classificationLevelValue)) { throw new IllegalArgumentException("Classification Level is not in the list of allowed values"); } } }
AccessInternalModuleImpl implements AccessInternalModule { public void checkClassificationLevel(JsonNode query) throws InvalidParseOperationException { String classificationFieldName = VitamFieldsHelper.management() + "." + VitamConstants.TAG_RULE_CLASSIFICATION + "." + SedaConstants.TAG_RULE_CLASSIFICATION_LEVEL; JsonNode classificationLevel = getValueForUpdateDsl(query, classificationFieldName); String classificationLevelValue; if (classificationLevel == null) { return; } if (!classificationLevel.isTextual()) { throw new IllegalArgumentException("Illegal value for Classification Level. Expected string"); } classificationLevelValue = classificationLevel.asText(); if (!ClassificationLevelUtil.checkClassificationLevel(classificationLevelValue)) { throw new IllegalArgumentException("Classification Level is not in the list of allowed values"); } } AccessInternalModuleImpl(); @VisibleForTesting  AccessInternalModuleImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory); }
AccessInternalModuleImpl implements AccessInternalModule { public void checkClassificationLevel(JsonNode query) throws InvalidParseOperationException { String classificationFieldName = VitamFieldsHelper.management() + "." + VitamConstants.TAG_RULE_CLASSIFICATION + "." + SedaConstants.TAG_RULE_CLASSIFICATION_LEVEL; JsonNode classificationLevel = getValueForUpdateDsl(query, classificationFieldName); String classificationLevelValue; if (classificationLevel == null) { return; } if (!classificationLevel.isTextual()) { throw new IllegalArgumentException("Illegal value for Classification Level. Expected string"); } classificationLevelValue = classificationLevel.asText(); if (!ClassificationLevelUtil.checkClassificationLevel(classificationLevelValue)) { throw new IllegalArgumentException("Classification Level is not in the list of allowed values"); } } AccessInternalModuleImpl(); @VisibleForTesting  AccessInternalModuleImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory); @Override JsonNode selectUnit(JsonNode jsonQuery); @Override JsonNode selectUnitbyId(JsonNode jsonQuery, String idUnit); @Override JsonNode selectObjectGroupById(JsonNode jsonQuery, String idObjectGroup); @Override Response getOneObjectFromObjectGroup(String idObjectGroup, String qualifier, int version, String idUnit); @Override Response getAccessLog(JsonNode params); void checkClassificationLevel(JsonNode query); @Override JsonNode updateUnitById(JsonNode queryJson, String idUnit, String requestId); @Override Response findDIPByOperationId(String id); @Override Response findTransferSIPByOperationId(String id); @Override JsonNode selectObjects(JsonNode jsonQuery); @Override JsonNode selectUnitsWithInheritedRules(JsonNode jsonQuery); }
AccessInternalModuleImpl implements AccessInternalModule { public void checkClassificationLevel(JsonNode query) throws InvalidParseOperationException { String classificationFieldName = VitamFieldsHelper.management() + "." + VitamConstants.TAG_RULE_CLASSIFICATION + "." + SedaConstants.TAG_RULE_CLASSIFICATION_LEVEL; JsonNode classificationLevel = getValueForUpdateDsl(query, classificationFieldName); String classificationLevelValue; if (classificationLevel == null) { return; } if (!classificationLevel.isTextual()) { throw new IllegalArgumentException("Illegal value for Classification Level. Expected string"); } classificationLevelValue = classificationLevel.asText(); if (!ClassificationLevelUtil.checkClassificationLevel(classificationLevelValue)) { throw new IllegalArgumentException("Classification Level is not in the list of allowed values"); } } AccessInternalModuleImpl(); @VisibleForTesting  AccessInternalModuleImpl(LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
        LogbookOperationsClientFactory logbookOperationsClientFactory, StorageClientFactory storageClientFactory,
        WorkspaceClientFactory workspaceClientFactory, AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory); @Override JsonNode selectUnit(JsonNode jsonQuery); @Override JsonNode selectUnitbyId(JsonNode jsonQuery, String idUnit); @Override JsonNode selectObjectGroupById(JsonNode jsonQuery, String idObjectGroup); @Override Response getOneObjectFromObjectGroup(String idObjectGroup, String qualifier, int version, String idUnit); @Override Response getAccessLog(JsonNode params); void checkClassificationLevel(JsonNode query); @Override JsonNode updateUnitById(JsonNode queryJson, String idUnit, String requestId); @Override Response findDIPByOperationId(String id); @Override Response findTransferSIPByOperationId(String id); @Override JsonNode selectObjects(JsonNode jsonQuery); @Override JsonNode selectUnitsWithInheritedRules(JsonNode jsonQuery);  }