use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class InputsResourceMaskingPasswordsTest method testMaskingOfFieldWithoutType.
@Test
public void testMaskingOfFieldWithoutType() {
final ConfigurationRequest configurationRequest = ConfigurationRequest.createWithFields();
final Map<String, Object> configuration = ImmutableMap.of("nopassword", "lasers in space");
final Map<String, Object> resultingAttributes = this.inputsResource.maskPasswordsInConfiguration(configuration, configurationRequest);
assertThat(resultingAttributes).hasSize(1);
assertThat(resultingAttributes).containsEntry("nopassword", "lasers in space");
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class ContainerMatrixMethodSelectorResolver method resolve.
private Resolution resolve(Context context, List<Class<?>> enclosingClasses, Class<?> testClass, Supplier<Method> methodSupplier) {
if (!testClassPredicate.test(testClass)) {
return unresolved();
}
Method method = methodSupplier.get();
// @formatter:off
Set<Match> matches = Arrays.stream(ContainerMatrixMethodSelectorResolver.MethodType.values()).map(methodType -> methodType.resolve(enclosingClasses, testClass, method, context, configuration)).filter(Optional::isPresent).map(Optional::get).map(testDescriptor -> Match.exact(testDescriptor, expansionCallback(testDescriptor))).collect(toSet());
// @formatter:on
if (matches.size() > 1) {
logger.warn(() -> {
Stream<TestDescriptor> testDescriptors = matches.stream().map(Match::getTestDescriptor);
return f("Possible configuration error: method [%s] resulted in multiple TestDescriptors %s. " + "This is typically the result of annotating a method with multiple competing annotations " + "such as @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, etc.", method.toGenericString(), testDescriptors.map(d -> d.getClass().getName()).collect(toList()));
});
}
return matches.isEmpty() ? unresolved() : matches(matches);
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class ConfigurationMapConverterTest method convertValuesThrowsIllegalArgumentExceptionOnUnknwonType.
@Test
public void convertValuesThrowsIllegalArgumentExceptionOnUnknwonType() throws Exception {
thrown.expect(ValidationException.class);
thrown.expectMessage("Unknown configuration field type \"dummy\"");
final ConfigurationRequest cr = new ConfigurationRequest();
cr.addField(new DummyField());
final Map<String, Object> data = new HashMap<>();
data.put("dummy", "foo");
ConfigurationMapConverter.convertValues(data, cr);
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class UserServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
this.mongoConnection = mongodb.mongoConnection();
this.configuration = new Configuration();
this.permissions = new Permissions(ImmutableSet.of(new RestPermissions()));
this.userFactory = new UserImplFactory(configuration, permissions);
this.userService = new UserServiceImpl(mongoConnection, configuration, roleService, accessTokenService, userFactory, permissionsResolver, serverEventBus, GRNRegistry.createWithBuiltinTypes(), permissionAndRoleResolver);
when(roleService.getAdminRoleObjectId()).thenReturn("deadbeef");
}
use of org.graylog2.Configuration in project batfish by batfish.
the class Version method getVersion.
/**
* Returns the version of the current build of Batfish, or {@link #UNKNOWN_VERSION} if the version
* could not be detected.
*/
public static String getVersion() {
try {
Configuration config = new Configurations().properties(PROPERTIES_PATH);
String version = config.getString("batfish_version");
if (version.contains("project.version")) {
// For whatever reason, resource filtering didn't work.
return UNKNOWN_VERSION;
}
return version;
} catch (Exception e) {
return UNKNOWN_VERSION;
}
}
Aggregations