use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class GelfCodecTest method decodeFailsWithEmptyShortMessage.
@Test
public void decodeFailsWithEmptyShortMessage() throws Exception {
final String json = "{" + "\"version\": \"1.1\"," + "\"host\": \"example.org\"," + "\"short_message\": \"\"" + "}";
final RawMessage rawMessage = new RawMessage(json.getBytes(StandardCharsets.UTF_8));
assertThatIllegalArgumentException().isThrownBy(() -> codec.decode(rawMessage)).withNoCause().withMessageMatching("GELF message <[0-9a-f-]+> has empty mandatory \"short_message\" field.");
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class GelfCodecTest method decodeSucceedsWithoutShortMessageButWithMessage.
@Test
public void decodeSucceedsWithoutShortMessageButWithMessage() throws Exception {
final String json = "{" + "\"version\": \"1.1\"," + "\"host\": \"example.org\"," + "\"message\": \"A short message that helps you identify what is going on\"" + "}";
final RawMessage rawMessage = new RawMessage(json.getBytes(StandardCharsets.UTF_8));
final Message message = codec.decode(rawMessage);
assertThat(message).isNotNull();
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class SyslogCodecTest method testDecodeStructuredIssue845WithExpandStructuredData.
@Test
public void testDecodeStructuredIssue845WithExpandStructuredData() throws Exception {
when(configuration.getBoolean(SyslogCodec.CK_EXPAND_STRUCTURED_DATA)).thenReturn(true);
final SyslogCodec codec = new SyslogCodec(configuration, metricRegistry);
final Message message = codec.decode(buildRawMessage(STRUCTURED_ISSUE_845));
assertNotNull(message);
assertEquals("User page 13 requested", message.getMessage());
assertEquals(new DateTime("2015-01-06T20:56:33.287Z", DateTimeZone.UTC), ((DateTime) message.getField("timestamp")).withZone(DateTimeZone.UTC));
assertEquals("app-1", message.getField("source"));
assertEquals(6, message.getField("level"));
assertEquals("local7", message.getField("facility"));
assertEquals("::ffff:132.123.15.30", message.getField("mdc@18060_ip"));
assertEquals("{c.corp.Handler}", message.getField("mdc@18060_logger"));
assertEquals("4ot7", message.getField("mdc@18060_session"));
assertEquals("user@example.com", message.getField("mdc@18060_user"));
assertEquals("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11", message.getField("mdc@18060_user-agent"));
assertEquals("app", message.getField("application_name"));
assertEquals(23, message.getField("facility_num"));
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class IndexMappingTest method createsValidMappingTemplates.
@ParameterizedTest
@ValueSource(strings = { "5.0.0", "6.0.0", "7.0.0" })
void createsValidMappingTemplates(String versionString) throws Exception {
final SearchVersion version = SearchVersion.elasticsearch(versionString);
final IndexMappingTemplate mapping = new MessageIndexTemplateProvider().create(version, null);
final Map<String, Object> template = mapping.toTemplate(indexSetConfig, "sampleIndexTemplate");
final String fixture = fixtureFor(version);
JSONAssert.assertEquals(json(template), fixture, true);
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class MajorVersionConverterTest method convertEncodedValue.
@Test
void convertEncodedValue() {
final SearchVersion version = converter.convertFrom("OPENSEARCH:1.2.0");
assertThat(version).isEqualTo(SearchVersion.create(SearchVersion.Distribution.OPENSEARCH, Version.valueOf("1.2.0")));
}
Aggregations