use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class UdpTransportTest method launchTransportForBootStrapTest.
private UdpTransport launchTransportForBootStrapTest(final ChannelInboundHandler channelHandler) throws MisfireException {
final UdpTransport transport = new UdpTransport(CONFIGURATION, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, new LocalMetricRegistry()) {
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getChannelHandlers(MessageInput input) {
final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
handlers.put("logging", () -> new LoggingHandler(LogLevel.INFO));
handlers.put("counter", () -> channelHandler);
handlers.putAll(super.getChannelHandlers(input));
return handlers;
}
};
final MessageInput messageInput = mock(MessageInput.class);
when(messageInput.getId()).thenReturn("TEST");
when(messageInput.getName()).thenReturn("TEST");
transport.launch(messageInput);
return transport;
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class UdpTransportTest method receiveBufferSizeIsNotLimited.
@Test
public void receiveBufferSizeIsNotLimited() {
final int recvBufferSize = Ints.saturatedCast(Size.megabytes(1L).toBytes());
ImmutableMap<String, Object> source = ImmutableMap.of(NettyTransport.CK_BIND_ADDRESS, BIND_ADDRESS, NettyTransport.CK_PORT, PORT, NettyTransport.CK_RECV_BUFFER_SIZE, recvBufferSize);
Configuration config = new Configuration(source);
UdpTransport udpTransport = new UdpTransport(config, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, new LocalMetricRegistry());
assertThat(udpTransport.getBootstrap(mock(MessageInput.class)).config().options().get(ChannelOption.SO_RCVBUF)).isEqualTo(recvBufferSize);
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class InputsResourceMaskingPasswordsTest method testMaskingOfPasswordFields.
@Test
public void testMaskingOfPasswordFields() {
final ConfigurationField fooInput = mock(ConfigurationField.class);
final TextField passwordInput = mock(TextField.class);
when(fooInput.getName()).thenReturn("foo");
when(passwordInput.getName()).thenReturn("password");
when(passwordInput.getAttributes()).thenReturn(ImmutableList.of(TextField.Attribute.IS_PASSWORD.toString().toLowerCase(Locale.ENGLISH)));
final ConfigurationRequest configurationRequest = ConfigurationRequest.createWithFields(fooInput, passwordInput);
final Map<String, Object> configuration = ImmutableMap.of("foo", 42, "password", "verysecret");
final Map<String, Object> resultingAttributes = this.inputsResource.maskPasswordsInConfiguration(configuration, configurationRequest);
assertThat(resultingAttributes).hasSize(2);
assertThat(resultingAttributes).containsEntry("password", "<password set>");
assertThat(resultingAttributes).containsEntry("foo", 42);
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class InputsResourceMaskingPasswordsTest method testRetrievalOfInputWithPasswordFieldIfUserIsNotAllowedToEditInput.
@Test
public void testRetrievalOfInputWithPasswordFieldIfUserIsNotAllowedToEditInput() throws NotFoundException {
final String inputId = "myinput";
final String inputType = "dummyinput";
final Input input = getInput(inputId, inputType);
when(inputService.find(inputId)).thenReturn(input);
final ConfigurationField fooInput = mock(ConfigurationField.class);
when(fooInput.getName()).thenReturn("foo");
final TextField passwordInput = getPasswordField("password");
final ConfigurationRequest configurationRequest = ConfigurationRequest.createWithFields(fooInput, passwordInput);
final InputDescription inputDescription = getInputDescription(configurationRequest);
this.availableInputs.put(inputType, inputDescription);
when(currentSubject.isPermitted(RestPermissions.INPUTS_READ + ":" + inputId)).thenReturn(true);
when(currentSubject.isPermitted(RestPermissions.INPUTS_EDIT + ":" + inputId)).thenReturn(false);
final Map<String, Object> configuration = ImmutableMap.of("foo", 42, "password", "verysecret");
when(input.getConfiguration()).thenReturn(configuration);
final InputSummary summary = this.inputsResource.get(inputId);
assertThat(summary.attributes()).hasSize(2);
assertThat(summary.attributes()).containsEntry("password", "<password set>");
assertThat(summary.attributes()).containsEntry("foo", 42);
}
use of org.graylog2.Configuration in project graylog2-server by Graylog2.
the class InputsResourceMaskingPasswordsTest method testMaskingOfEmptyMap.
@Test
public void testMaskingOfEmptyMap() {
final ConfigurationRequest configurationRequest = ConfigurationRequest.createWithFields();
final Map<String, Object> configuration = Collections.emptyMap();
final Map<String, Object> resultingAttributes = this.inputsResource.maskPasswordsInConfiguration(configuration, configurationRequest);
assertThat(resultingAttributes).isEmpty();
}
Aggregations