use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.
the class ResolvableInetSocketAddressTest method testReverseLookup.
@Test
@SuppressForbidden("Intentional invocation of InetSocketAddress#getHostName()")
public void testReverseLookup() throws Exception {
final InetSocketAddress inetSocketAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 12345);
final ResolvableInetSocketAddress address = new ResolvableInetSocketAddress(inetSocketAddress);
assertThat(address.isReverseLookedUp()).isFalse();
assertThat(address.reverseLookup()).isEqualTo(inetSocketAddress.getHostName());
assertThat(address.isReverseLookedUp()).isTrue();
}
use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.
the class ResolvableInetSocketAddressTest method testGetHostName.
@Test
@SuppressForbidden("Intentional invocation of InetSocketAddress#getHostName()")
public void testGetHostName() throws Exception {
final InetSocketAddress inetSocketAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 12345);
final ResolvableInetSocketAddress address = new ResolvableInetSocketAddress(inetSocketAddress);
assertThat(address.getHostName()).isNull();
address.reverseLookup();
assertThat(address.getHostName()).isEqualTo(inetSocketAddress.getHostName());
}
use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.
the class StaticFieldFilterTest method testFilter.
@Test
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void testFilter() throws Exception {
Message msg = new Message("hello", "junit", Tools.nowUTC());
msg.setSourceInputId("someid");
when(input.getId()).thenReturn("someid");
when(inputService.all()).thenReturn(Collections.singletonList(input));
when(inputService.find(eq("someid"))).thenReturn(input);
when(inputService.getStaticFields(eq(input))).thenReturn(Collections.singletonList(Maps.immutableEntry("foo", "bar")));
final StaticFieldFilter filter = new StaticFieldFilter(inputService, new EventBus(), Executors.newSingleThreadScheduledExecutor());
filter.filter(msg);
assertEquals("hello", msg.getMessage());
assertEquals("junit", msg.getSource());
assertEquals("bar", msg.getField("foo"));
}
use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.
the class MongoDbSession method getAttributes.
@SuppressForbidden("Deliberate use of ObjectInputStream")
public Map<Object, Object> getAttributes() {
final Object attributes = fields.get("attributes");
if (attributes == null) {
return null;
}
final ByteArrayInputStream bis = new ByteArrayInputStream((byte[]) attributes);
try {
// FIXME: This could break backward compatibility if different Java versions are being used.
final ObjectInputStream ois = new ObjectInputStream(bis);
final Object o = ois.readObject();
return (Map<Object, Object>) o;
} catch (IOException e) {
LOG.error("little io. wow.", e);
} catch (ClassNotFoundException e) {
LOG.error("wrong thingy in db", e);
}
return null;
}
use of org.graylog2.shared.SuppressForbidden in project graylog2-server by Graylog2.
the class SyslogCodecTest method rfc5424_section6_5_messages.
@Test
@SuppressForbidden("Deliberate invocation")
public void rfc5424_section6_5_messages() {
// See https://tools.ietf.org/html/rfc5424#section-6.5
final Map<String, Map<String, Object>> rfc3164messages = ImmutableMap.of("<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8", ImmutableMap.<String, Object>builder().put("timestamp", new DateTime("2003-10-11T22:14:15.003", DateTimeZone.UTC).withZone(DateTimeZone.getDefault())).put("source", "mymachine.example.com").put("level", 2).put("facility", "security/authorization").put("application_name", "su").put("message", "ID47 - BOM'su root' failed for lonvick on /dev/pts/8").build(), "<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts.", ImmutableMap.<String, Object>builder().put("timestamp", new DateTime("2003-08-24T05:14:15.000", DateTimeZone.forOffsetHours(-7)).withZone(DateTimeZone.getDefault())).put("source", "192.0.2.1").put("level", 5).put("facility", "local4").put("application_name", "myproc").put("process_id", "8710").put("message", "%% It's time to make the do-nuts.").build(), "<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"] An application event log entry...", ImmutableMap.<String, Object>builder().put("timestamp", new DateTime("2003-10-11T22:14:15.003", DateTimeZone.UTC).withZone(DateTimeZone.getDefault())).put("source", "mymachine.example.com").put("level", 5).put("facility", "local4").put("application_name", "evntslog").put("message", "An application event log entry...").put("iut", "3").put("eventID", "1011").put("eventSource", "Application").build(), "<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@32473 class=\"high\"]", ImmutableMap.<String, Object>builder().put("timestamp", new DateTime("2003-10-11T22:14:15.003", DateTimeZone.UTC).withZone(DateTimeZone.getDefault())).put("source", "mymachine.example.com").put("level", 5).put("facility", "local4").put("application_name", "evntslog").put("iut", "3").put("eventID", "1011").put("eventSource", "Application").build());
for (Map.Entry<String, Map<String, Object>> entry : rfc3164messages.entrySet()) {
final Message message = codec.decode(buildRawMessage(entry.getKey()));
assertThat(message).isNotNull();
assertThat(message.getFields()).containsAllEntriesOf(entry.getValue());
}
}
Aggregations