Search in sources :

Example 96 with Configuration

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");
}
Also used : ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) Test(org.junit.Test)

Example 97 with Configuration

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);
}
Also used : IsContainerMatrixTest(org.junit.jupiter.engine.discovery.predicates.IsContainerMatrixTest) Arrays(java.util.Arrays) IsContainerMatrixTestClass(org.graylog.testing.containermatrix.discovery.IsContainerMatrixTestClass) ContainerMatrixTestsDescriptor(org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor) UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) JupiterConfiguration(org.junit.jupiter.engine.config.JupiterConfiguration) Supplier(java.util.function.Supplier) LoggerFactory(org.junit.platform.commons.logging.LoggerFactory) IsNestedTestClass(org.junit.jupiter.engine.discovery.predicates.IsNestedTestClass) Filterable(org.junit.jupiter.engine.descriptor.Filterable) MethodSelector(org.junit.platform.engine.discovery.MethodSelector) Resolution.unresolved(org.junit.platform.engine.support.discovery.SelectorResolver.Resolution.unresolved) DiscoverySelectors(org.junit.platform.engine.discovery.DiscoverySelectors) Method(java.lang.reflect.Method) LinkedHashSet(java.util.LinkedHashSet) Collectors.toSet(java.util.stream.Collectors.toSet) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) Collections.emptySet(java.util.Collections.emptySet) StringUtils.f(org.graylog2.shared.utilities.StringUtils.f) TestMethodTestDescriptor(org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor) Logger(org.junit.platform.commons.logging.Logger) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Set(java.util.Set) UniqueId(org.junit.platform.engine.UniqueId) ClassBasedTestDescriptor(org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor) ClassUtils(org.junit.platform.commons.util.ClassUtils) NestedMethodSelector(org.junit.platform.engine.discovery.NestedMethodSelector) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) Resolution.matches(org.junit.platform.engine.support.discovery.SelectorResolver.Resolution.matches) Optional(java.util.Optional) TestDescriptor(org.junit.platform.engine.TestDescriptor) SelectorResolver(org.junit.platform.engine.support.discovery.SelectorResolver) Optional(java.util.Optional) Method(java.lang.reflect.Method) TestMethodTestDescriptor(org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor) ClassBasedTestDescriptor(org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 98 with Configuration

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);
}
Also used : HashMap(java.util.HashMap) ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) Test(org.junit.Test)

Example 99 with Configuration

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");
}
Also used : RestPermissions(org.graylog2.shared.security.RestPermissions) Configuration(org.graylog2.Configuration) RestPermissions(org.graylog2.shared.security.RestPermissions) Permissions(org.graylog2.shared.security.Permissions) Before(org.junit.Before)

Example 100 with Configuration

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;
    }
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) Configurations(org.apache.commons.configuration2.builder.fluent.Configurations)

Aggregations

Test (org.junit.Test)67 Configuration (org.graylog2.plugin.configuration.Configuration)46 Configuration (org.apache.commons.configuration2.Configuration)35 ApiOperation (io.swagger.annotations.ApiOperation)31 Timed (com.codahale.metrics.annotation.Timed)23 AuditEvent (org.graylog2.audit.jersey.AuditEvent)23 Path (javax.ws.rs.Path)22 BadRequestException (javax.ws.rs.BadRequestException)21 MessageInput (org.graylog2.plugin.inputs.MessageInput)18 ConfigurationRequest (org.graylog2.plugin.configuration.ConfigurationRequest)17 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)15 Stream (org.graylog2.plugin.streams.Stream)15 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)14 File (java.io.File)14 Consumes (javax.ws.rs.Consumes)14 DateTime (org.joda.time.DateTime)14 POST (javax.ws.rs.POST)13 Produces (javax.ws.rs.Produces)13 Configuration (org.graylog2.Configuration)13 ApiResponses (io.swagger.annotations.ApiResponses)12