mirror of
https://github.com/elastic/logstash.git
synced 2025-06-28 09:46:03 -04:00
Update junit 4 13 (#16138)
* test-deps: update junit to latest 4.13 * test-deps: address deprecation of ExpectedException * test-deps: use org.junit.Assert.assertThrows
This commit is contained in:
parent
973c2ba3aa
commit
9e452d2e54
33 changed files with 134 additions and 130 deletions
|
@ -224,7 +224,7 @@ dependencies {
|
||||||
testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}:tests"
|
testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}:tests"
|
||||||
testImplementation 'org.hamcrest:hamcrest:2.2'
|
testImplementation 'org.hamcrest:hamcrest:2.2'
|
||||||
testImplementation 'org.hamcrest:hamcrest-library:2.2'
|
testImplementation 'org.hamcrest:hamcrest-library:2.2'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'net.javacrumbs.json-unit:json-unit:2.3.0'
|
testImplementation 'net.javacrumbs.json-unit:json-unit:2.3.0'
|
||||||
testImplementation 'org.elasticsearch:securemock:1.2'
|
testImplementation 'org.elasticsearch:securemock:1.2'
|
||||||
testImplementation 'org.assertj:assertj-core:3.11.1'
|
testImplementation 'org.assertj:assertj-core:3.11.1'
|
||||||
|
|
|
@ -31,10 +31,10 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
|
|
|
@ -38,12 +38,13 @@ import org.jruby.java.proxies.ConcreteJavaProxy;
|
||||||
import org.jruby.java.proxies.MapJavaProxy;
|
import org.jruby.java.proxies.MapJavaProxy;
|
||||||
import org.jruby.javasupport.Java;
|
import org.jruby.javasupport.Java;
|
||||||
import org.jruby.runtime.builtin.IRubyObject;
|
import org.jruby.runtime.builtin.IRubyObject;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.logstash.ext.JrubyTimestampExtLibrary;
|
import org.logstash.ext.JrubyTimestampExtLibrary;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
public class ValuefierTest extends RubyTestBase {
|
public class ValuefierTest extends RubyTestBase {
|
||||||
|
|
||||||
|
@ -120,15 +121,12 @@ public class ValuefierTest extends RubyTestBase {
|
||||||
assertEquals(zdt.toInstant().toEpochMilli(), result.getTimestamp().toEpochMilli());
|
assertEquals(zdt.toInstant().toEpochMilli(), result.getTimestamp().toEpochMilli());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnhandledObject() {
|
public void testUnhandledObject() {
|
||||||
RubyMatchData md = new RubyMatchData(RubyUtil.RUBY);
|
RubyMatchData md = new RubyMatchData(RubyUtil.RUBY);
|
||||||
exception.expect(MissingConverterException.class);
|
|
||||||
exception.expectMessage("Missing Converter handling for full class name=org.jruby.RubyMatchData, simple name=RubyMatchData");
|
MissingConverterException missingConverterException = assertThrows(MissingConverterException.class, () -> Valuefier.convert(md));
|
||||||
Valuefier.convert(md);
|
assertThat(missingConverterException.getMessage(), containsString("Missing Converter handling for full class name=org.jruby.RubyMatchData, simple name=RubyMatchData"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -58,7 +58,7 @@ import static org.hamcrest.Matchers.greaterThan;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.logstash.ackedqueue.QueueTestHelpers.computeCapacityForMmapPageIO;
|
import static org.logstash.ackedqueue.QueueTestHelpers.computeCapacityForMmapPageIO;
|
||||||
import static org.logstash.util.ExceptionMatcher.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
public class QueueTest {
|
public class QueueTest {
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package org.logstash.common;
|
package org.logstash.common;
|
||||||
|
|
||||||
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.logstash.plugins.ConfigVariableExpander;
|
import org.logstash.plugins.ConfigVariableExpander;
|
||||||
|
@ -110,7 +111,7 @@ public class ConfigVariableExpanderTest {
|
||||||
Collections.singletonMap(key, evVal));
|
Collections.singletonMap(key, evVal));
|
||||||
|
|
||||||
Object expandedValue = cve.expand("${" + key + ":" + defaultValue + "}", true);
|
Object expandedValue = cve.expand("${" + key + ":" + defaultValue + "}", true);
|
||||||
Assert.assertThat(expandedValue, instanceOf(SecretVariable.class));
|
MatcherAssert.assertThat(expandedValue, instanceOf(SecretVariable.class));
|
||||||
Assert.assertEquals(ssVal, ((SecretVariable) expandedValue).getSecretValue());
|
Assert.assertEquals(ssVal, ((SecretVariable) expandedValue).getSecretValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,12 @@ import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PipelineConfigTest extends RubyEnvTestCase {
|
public class PipelineConfigTest extends RubyEnvTestCase {
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@ import org.logstash.config.ir.graph.Graph;
|
||||||
import org.logstash.plugins.ConfigVariableExpander;
|
import org.logstash.plugins.ConfigVariableExpander;
|
||||||
import org.logstash.config.ir.graph.QueueVertex;
|
import org.logstash.config.ir.graph.QueueVertex;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.any;
|
import static org.hamcrest.Matchers.any;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.hasItem;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.logstash.config.ir.DSL.*;
|
import static org.logstash.config.ir.DSL.*;
|
||||||
import static org.logstash.config.ir.PluginDefinition.Type.*;
|
import static org.logstash.config.ir.PluginDefinition.Type.*;
|
||||||
import static org.logstash.config.ir.IRHelpers.randMeta;
|
import static org.logstash.config.ir.IRHelpers.randMeta;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.junit.runner.RunWith;
|
||||||
import org.logstash.config.ir.InvalidIRException;
|
import org.logstash.config.ir.InvalidIRException;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.logstash.config.ir.IRHelpers.*;
|
import static org.logstash.config.ir.IRHelpers.*;
|
||||||
|
|
||||||
@RunWith(Theories.class)
|
@RunWith(Theories.class)
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
||||||
import org.logstash.config.ir.IRHelpers;
|
import org.logstash.config.ir.IRHelpers;
|
||||||
import org.logstash.config.ir.InvalidIRException;
|
import org.logstash.config.ir.InvalidIRException;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
|
||||||
public class EdgeTest {
|
public class EdgeTest {
|
||||||
|
|
|
@ -30,7 +30,10 @@ import java.util.Collections;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.logstash.config.ir.IRHelpers.createTestExpression;
|
import static org.logstash.config.ir.IRHelpers.createTestExpression;
|
||||||
import static org.logstash.config.ir.IRHelpers.createTestVertex;
|
import static org.logstash.config.ir.IRHelpers.createTestVertex;
|
||||||
import static org.logstash.config.ir.IRHelpers.randMeta;
|
import static org.logstash.config.ir.IRHelpers.randMeta;
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.logstash.plugins.ConfigVariableExpander;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.logstash.config.ir.IRHelpers.*;
|
import static org.logstash.config.ir.IRHelpers.*;
|
||||||
|
|
||||||
public class IfVertexTest {
|
public class IfVertexTest {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.logstash.config.ir.IRHelpers.*;
|
import static org.logstash.config.ir.IRHelpers.*;
|
||||||
|
|
||||||
public class PluginVertexTest {
|
public class PluginVertexTest {
|
||||||
|
|
|
@ -22,8 +22,8 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class ObservedExecutionTest extends RubyEnvTestCase {
|
public class ObservedExecutionTest extends RubyEnvTestCase {
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.jruby.RubyBoolean;
|
import org.jruby.RubyBoolean;
|
||||||
import org.jruby.RubyHash;
|
import org.jruby.RubyHash;
|
||||||
import org.jruby.RubyString;
|
import org.jruby.RubyString;
|
||||||
|
@ -93,7 +94,7 @@ public final class JrubyEventExtLibraryTest extends RubyTestBase {
|
||||||
try {
|
try {
|
||||||
event.ruby_set_field(context, key, value);
|
event.ruby_set_field(context, key, value);
|
||||||
} catch (RuntimeError rubyRuntimeError) {
|
} catch (RuntimeError rubyRuntimeError) {
|
||||||
Assert.assertThat(rubyRuntimeError.getLocalizedMessage(), CoreMatchers.containsString("Invalid FieldReference"));
|
MatcherAssert.assertThat(rubyRuntimeError.getLocalizedMessage(), CoreMatchers.containsString("Invalid FieldReference"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert.fail("expected ruby RuntimeError was not thrown.");
|
Assert.fail("expected ruby RuntimeError was not thrown.");
|
||||||
|
@ -109,7 +110,7 @@ public final class JrubyEventExtLibraryTest extends RubyTestBase {
|
||||||
|
|
||||||
event.ruby_set_field(context, key, value);
|
event.ruby_set_field(context, key, value);
|
||||||
IRubyObject retrievedValue = event.ruby_get_field(context, key);
|
IRubyObject retrievedValue = event.ruby_get_field(context, key);
|
||||||
Assert.assertThat(retrievedValue, CoreMatchers.equalTo(value));
|
MatcherAssert.assertThat(retrievedValue, CoreMatchers.equalTo(value));
|
||||||
|
|
||||||
RubyHash eventHash = (RubyHash) event.ruby_to_hash_with_metadata(context);
|
RubyHash eventHash = (RubyHash) event.ruby_to_hash_with_metadata(context);
|
||||||
IRubyObject nestedValue = eventHash.dig(context, rubyString("foo"), rubyString("il[[]]]legal"));
|
IRubyObject nestedValue = eventHash.dig(context, rubyString("foo"), rubyString("il[[]]]legal"));
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.time.Instant;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.anEmptyMap;
|
import static org.hamcrest.Matchers.anEmptyMap;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
|
@ -17,7 +18,6 @@ import static org.hamcrest.Matchers.hasKey;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.lessThan;
|
import static org.hamcrest.Matchers.lessThan;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
public class ExtendedFlowMetricTest {
|
public class ExtendedFlowMetricTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -8,12 +8,12 @@ import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.anEmptyMap;
|
import static org.hamcrest.Matchers.anEmptyMap;
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.logstash.instrument.metrics.SimpleFlowMetric.LIFETIME_KEY;
|
import static org.logstash.instrument.metrics.SimpleFlowMetric.LIFETIME_KEY;
|
||||||
import static org.logstash.instrument.metrics.SimpleFlowMetric.CURRENT_KEY;
|
import static org.logstash.instrument.metrics.SimpleFlowMetric.CURRENT_KEY;
|
||||||
|
|
|
@ -10,10 +10,10 @@ import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,6 @@ package org.logstash.secret.store;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.logstash.secret.SecretIdentifier;
|
import org.logstash.secret.SecretIdentifier;
|
||||||
import org.logstash.secret.store.backend.JavaKeyStore;
|
import org.logstash.secret.store.backend.JavaKeyStore;
|
||||||
|
@ -36,6 +35,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.logstash.secret.store.SecretStoreFactory.ENVIRONMENT_PASS_KEY;
|
import static org.logstash.secret.store.SecretStoreFactory.ENVIRONMENT_PASS_KEY;
|
||||||
import static org.logstash.secret.store.SecretStoreFactory.KEYSTORE_ACCESS_KEY;
|
import static org.logstash.secret.store.SecretStoreFactory.KEYSTORE_ACCESS_KEY;
|
||||||
import static org.logstash.secret.store.SecretStoreFactory.LOGSTASH_MARKER;
|
import static org.logstash.secret.store.SecretStoreFactory.LOGSTASH_MARKER;
|
||||||
|
@ -49,9 +49,6 @@ public class SecretStoreFactoryTest {
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
|
||||||
|
|
||||||
private static final SecretStoreFactory secretStoreFactory = SecretStoreFactory.fromEnvironment();
|
private static final SecretStoreFactory secretStoreFactory = SecretStoreFactory.fromEnvironment();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -65,12 +62,12 @@ public class SecretStoreFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAlternativeImplementationInvalid() {
|
public void testAlternativeImplementationInvalid() {
|
||||||
thrown.expect(SecretStoreException.ImplementationNotFoundException.class);
|
|
||||||
SecureConfig secureConfig = new SecureConfig();
|
SecureConfig secureConfig = new SecureConfig();
|
||||||
secureConfig.add("keystore.classname", "junk".toCharArray());
|
secureConfig.add("keystore.classname", "junk".toCharArray());
|
||||||
SecretStore secretStore = secretStoreFactory.load(secureConfig);
|
|
||||||
assertThat(secretStore).isInstanceOf(MemoryStore.class);
|
assertThrows(SecretStoreException.ImplementationNotFoundException.class, () -> {
|
||||||
validateMarker(secretStore);
|
secretStoreFactory.load(secureConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -140,9 +137,10 @@ public class SecretStoreFactoryTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testErrorLoading() {
|
public void testErrorLoading() {
|
||||||
thrown.expect(SecretStoreException.LoadException.class);
|
assertThrows(SecretStoreException.LoadException.class, () -> {
|
||||||
//default implementation requires a path
|
//default implementation requires a path
|
||||||
secretStoreFactory.load(new SecureConfig());
|
secretStoreFactory.load(new SecureConfig());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMarker(SecretStore secretStore) {
|
private void validateMarker(SecretStore secretStore) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.logstash.secret.SecretIdentifier;
|
import org.logstash.secret.SecretIdentifier;
|
||||||
import org.logstash.secret.store.SecretStore;
|
import org.logstash.secret.store.SecretStore;
|
||||||
|
@ -57,6 +56,7 @@ import java.util.stream.IntStream;
|
||||||
import static java.nio.file.attribute.PosixFilePermission.*;
|
import static java.nio.file.attribute.PosixFilePermission.*;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Fail.fail;
|
import static org.assertj.core.api.Fail.fail;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.logstash.secret.store.SecretStoreFactory.LOGSTASH_MARKER;
|
import static org.logstash.secret.store.SecretStoreFactory.LOGSTASH_MARKER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +68,6 @@ public class JavaKeyStoreTest {
|
||||||
private final static String EXTERNAL_TEST_WRITE = "test_external_write";
|
private final static String EXTERNAL_TEST_WRITE = "test_external_write";
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
@Rule
|
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
|
||||||
private JavaKeyStore keyStore;
|
private JavaKeyStore keyStore;
|
||||||
private char[] keyStorePath;
|
private char[] keyStorePath;
|
||||||
private SecureConfig withDefaultPassConfig;
|
private SecureConfig withDefaultPassConfig;
|
||||||
|
@ -210,7 +208,6 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void notLogstashKeystore() throws Exception {
|
public void notLogstashKeystore() throws Exception {
|
||||||
thrown.expect(SecretStoreException.class);
|
|
||||||
SecureConfig altConfig = new SecureConfig();
|
SecureConfig altConfig = new SecureConfig();
|
||||||
Path altPath = folder.newFolder().toPath().resolve("alt.not.a.logstash.keystore");
|
Path altPath = folder.newFolder().toPath().resolve("alt.not.a.logstash.keystore");
|
||||||
try (OutputStream out = Files.newOutputStream(altPath)) {
|
try (OutputStream out = Files.newOutputStream(altPath)) {
|
||||||
|
@ -219,7 +216,10 @@ public class JavaKeyStoreTest {
|
||||||
out.write(randomBytes);
|
out.write(randomBytes);
|
||||||
}
|
}
|
||||||
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.class, () -> {
|
||||||
new JavaKeyStore().load(altConfig);
|
new JavaKeyStore().load(altConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,9 +229,11 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void notLogstashKeystoreNoMarker() throws Exception {
|
public void notLogstashKeystoreNoMarker() throws Exception {
|
||||||
thrown.expect(SecretStoreException.LoadException.class);
|
|
||||||
withDefinedPassConfig.add("keystore.file", Paths.get(this.getClass().getClassLoader().getResource("not.a.logstash.keystore").toURI()).toString().toCharArray().clone());
|
withDefinedPassConfig.add("keystore.file", Paths.get(this.getClass().getClassLoader().getResource("not.a.logstash.keystore").toURI()).toString().toCharArray().clone());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.LoadException.class, () -> {
|
||||||
new JavaKeyStore().load(withDefinedPassConfig);
|
new JavaKeyStore().load(withDefinedPassConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,7 +315,6 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void tamperedKeystore() throws Exception {
|
public void tamperedKeystore() throws Exception {
|
||||||
thrown.expect(SecretStoreException.class);
|
|
||||||
byte[] keyStoreAsBytes = Files.readAllBytes(Paths.get(new String(keyStorePath)));
|
byte[] keyStoreAsBytes = Files.readAllBytes(Paths.get(new String(keyStorePath)));
|
||||||
//bump the middle byte by 1
|
//bump the middle byte by 1
|
||||||
int tamperLocation = keyStoreAsBytes.length / 2;
|
int tamperLocation = keyStoreAsBytes.length / 2;
|
||||||
|
@ -322,7 +323,10 @@ public class JavaKeyStoreTest {
|
||||||
Files.write(tamperedPath, keyStoreAsBytes);
|
Files.write(tamperedPath, keyStoreAsBytes);
|
||||||
SecureConfig sc = new SecureConfig();
|
SecureConfig sc = new SecureConfig();
|
||||||
sc.add("keystore.file", tamperedPath.toString().toCharArray());
|
sc.add("keystore.file", tamperedPath.toString().toCharArray());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.class, () -> {
|
||||||
new JavaKeyStore().load(sc);
|
new JavaKeyStore().load(sc);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,10 +336,12 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAlreadyCreated() throws IOException {
|
public void testAlreadyCreated() throws IOException {
|
||||||
thrown.expect(SecretStoreException.AlreadyExistsException.class);
|
|
||||||
SecureConfig secureConfig = new SecureConfig();
|
SecureConfig secureConfig = new SecureConfig();
|
||||||
secureConfig.add("keystore.file", keyStorePath.clone());
|
secureConfig.add("keystore.file", keyStorePath.clone());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.AlreadyExistsException.class, () -> {
|
||||||
new JavaKeyStore().create(secureConfig);
|
new JavaKeyStore().create(secureConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -362,7 +368,6 @@ public class JavaKeyStoreTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws IOException {
|
public void testDelete() throws IOException {
|
||||||
thrown.expect(SecretStoreException.LoadException.class);
|
|
||||||
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
||||||
SecureConfig altConfig = new SecureConfig();
|
SecureConfig altConfig = new SecureConfig();
|
||||||
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
||||||
|
@ -372,8 +377,10 @@ public class JavaKeyStoreTest {
|
||||||
assertThat(new String(marker, StandardCharsets.UTF_8)).isEqualTo(LOGSTASH_MARKER.getKey());
|
assertThat(new String(marker, StandardCharsets.UTF_8)).isEqualTo(LOGSTASH_MARKER.getKey());
|
||||||
secretStore.delete(altConfig.clone());
|
secretStore.delete(altConfig.clone());
|
||||||
assertThat(secretStore.exists(altConfig.clone())).isFalse();
|
assertThat(secretStore.exists(altConfig.clone())).isFalse();
|
||||||
new JavaKeyStore().load(altConfig.clone());
|
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.LoadException.class, () -> {
|
||||||
|
new JavaKeyStore().load(altConfig.clone());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,12 +390,14 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyNotAllowedOnCreate() throws IOException {
|
public void testEmptyNotAllowedOnCreate() throws IOException {
|
||||||
thrown.expect(SecretStoreException.CreateException.class);
|
|
||||||
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
||||||
SecureConfig altConfig = new SecureConfig();
|
SecureConfig altConfig = new SecureConfig();
|
||||||
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
||||||
altConfig.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "".toCharArray());
|
altConfig.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "".toCharArray());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.CreateException.class, () -> {
|
||||||
new JavaKeyStore().create(altConfig);
|
new JavaKeyStore().create(altConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -398,7 +407,6 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyNotAllowedOnExisting() throws Exception {
|
public void testEmptyNotAllowedOnExisting() throws Exception {
|
||||||
thrown.expect(SecretStoreException.AccessException.class);
|
|
||||||
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
||||||
SecureConfig altConfig = new SecureConfig();
|
SecureConfig altConfig = new SecureConfig();
|
||||||
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
altConfig.add("keystore.file", altPath.toString().toCharArray());
|
||||||
|
@ -406,7 +414,10 @@ public class JavaKeyStoreTest {
|
||||||
altConfig2.add("keystore.file", altPath.toString().toCharArray());
|
altConfig2.add("keystore.file", altPath.toString().toCharArray());
|
||||||
altConfig2.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "".toCharArray());
|
altConfig2.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "".toCharArray());
|
||||||
new JavaKeyStore().create(altConfig);
|
new JavaKeyStore().create(altConfig);
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.AccessException.class, () -> {
|
||||||
new JavaKeyStore().load(altConfig2);
|
new JavaKeyStore().load(altConfig2);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -583,17 +594,20 @@ public class JavaKeyStoreTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadNotCreated() throws IOException {
|
public void testLoadNotCreated() throws IOException {
|
||||||
thrown.expect(SecretStoreException.LoadException.class);
|
|
||||||
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
Path altPath = folder.newFolder().toPath().resolve("alt.logstash.keystore");
|
||||||
SecureConfig secureConfig = new SecureConfig();
|
SecureConfig secureConfig = new SecureConfig();
|
||||||
secureConfig.add("keystore.file", altPath.toString().toCharArray());
|
secureConfig.add("keystore.file", altPath.toString().toCharArray());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.LoadException.class, () -> {
|
||||||
new JavaKeyStore().load(secureConfig.clone());
|
new JavaKeyStore().load(secureConfig.clone());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoPathDefined() {
|
public void testNoPathDefined() {
|
||||||
thrown.expect(SecretStoreException.LoadException.class);
|
assertThrows(SecretStoreException.LoadException.class, () -> {
|
||||||
new JavaKeyStore().load(new SecureConfig());
|
new JavaKeyStore().load(new SecureConfig());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -687,9 +701,11 @@ public class JavaKeyStoreTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void wrongPassword() throws Exception {
|
public void wrongPassword() throws Exception {
|
||||||
thrown.expect(SecretStoreException.AccessException.class);
|
|
||||||
withDefinedPassConfig.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "wrongpassword".toCharArray());
|
withDefinedPassConfig.add(SecretStoreFactory.KEYSTORE_ACCESS_KEY, "wrongpassword".toCharArray());
|
||||||
|
|
||||||
|
assertThrows(SecretStoreException.AccessException.class, () -> {
|
||||||
new JavaKeyStore().load(withDefinedPassConfig);
|
new JavaKeyStore().load(withDefinedPassConfig);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 40_000)
|
@Test(timeout = 40_000)
|
||||||
|
|
|
@ -19,49 +19,46 @@
|
||||||
|
|
||||||
package org.logstash.util;
|
package org.logstash.util;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import org.logstash.RubyTestBase;
|
import org.logstash.RubyTestBase;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class CloudSettingAuthTest extends RubyTestBase {
|
public class CloudSettingAuthTest extends RubyTestBase {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exceptionRule = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenGivenStringWithoutSeparatorOrPassword() {
|
public void testThrowExceptionWhenGivenStringWithoutSeparatorOrPassword() {
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
exceptionRule.expectMessage("Cloud Auth username and password format should be");
|
|
||||||
|
|
||||||
new CloudSettingAuth("foobarbaz");
|
new CloudSettingAuth("foobarbaz");
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Auth username and password format should be"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenGivenStringWithoutPassword() {
|
public void testThrowExceptionWhenGivenStringWithoutPassword() {
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
exceptionRule.expectMessage("Cloud Auth username and password format should be");
|
|
||||||
|
|
||||||
new CloudSettingAuth("foo:");
|
new CloudSettingAuth("foo:");
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Auth username and password format should be"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenGivenStringWithoutUsername() {
|
public void testThrowExceptionWhenGivenStringWithoutUsername() {
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
exceptionRule.expectMessage("Cloud Auth username and password format should be");
|
|
||||||
|
|
||||||
new CloudSettingAuth(":bar");
|
new CloudSettingAuth(":bar");
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Auth username and password format should be"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenGivenStringWhichIsEmpty() {
|
public void testThrowExceptionWhenGivenStringWhichIsEmpty() {
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
exceptionRule.expectMessage("Cloud Auth username and password format should be");
|
|
||||||
|
|
||||||
new CloudSettingAuth("");
|
new CloudSettingAuth("");
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Auth username and password format should be"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,22 +20,22 @@
|
||||||
package org.logstash.util;
|
package org.logstash.util;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import org.logstash.RubyTestBase;
|
import org.logstash.RubyTestBase;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
public class CloudSettingIdTest extends RubyTestBase {
|
public class CloudSettingIdTest extends RubyTestBase {
|
||||||
|
|
||||||
private String input = "foobar:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRub3RhcmVhbCRpZGVudGlmaWVy";
|
private String input = "foobar:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRub3RhcmVhbCRpZGVudGlmaWVy";
|
||||||
private CloudSettingId sut;
|
private CloudSettingId sut;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exceptionRule = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
sut = new CloudSettingId(input);
|
sut = new CloudSettingId(input);
|
||||||
|
@ -63,40 +63,45 @@ public class CloudSettingIdTest extends RubyTestBase {
|
||||||
public void testThrowExceptionWhenMalformedValueIsGiven() {
|
public void testThrowExceptionWhenMalformedValueIsGiven() {
|
||||||
String[] raw = new String[] {"first", "second"};
|
String[] raw = new String[] {"first", "second"};
|
||||||
String encoded = CloudSettingId.cloudIdEncode(raw);
|
String encoded = CloudSettingId.cloudIdEncode(raw);
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
|
||||||
exceptionRule.expectMessage("Cloud Id, after decoding, is invalid. Format: '<segment1>$<segment2>$<segment3>'. Received: \"" + String.join("$", raw) + "\".");
|
|
||||||
|
|
||||||
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
new CloudSettingId(encoded);
|
new CloudSettingId(encoded);
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Id, after decoding, is invalid. Format: '<segment1>$<segment2>$<segment3>'. Received: \"" + String.join("$", raw) + "\"."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenAtLeatOneSegmentIsEmpty() {
|
public void testThrowExceptionWhenAtLeatOneSegmentIsEmpty() {
|
||||||
String[] raw = new String[] {"first", "", "third"};
|
String[] raw = new String[] {"first", "", "third"};
|
||||||
String encoded = CloudSettingId.cloudIdEncode(raw);
|
String encoded = CloudSettingId.cloudIdEncode(raw);
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
|
||||||
exceptionRule.expectMessage("Cloud Id, after decoding, is invalid. Format: '<segment1>$<segment2>$<segment3>'. Received: \"" + String.join("$", raw) + "\".");
|
|
||||||
|
|
||||||
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
new CloudSettingId(encoded);
|
new CloudSettingId(encoded);
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Id, after decoding, is invalid. Format: '<segment1>$<segment2>$<segment3>'. Received: \"" + String.join("$", raw) + "\"."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenElasticSegmentSegmentIsUndefined() {
|
public void testThrowExceptionWhenElasticSegmentSegmentIsUndefined() {
|
||||||
String[] raw = new String[] {"us-east-1.aws.found.io", "undefined", "my-kibana"};
|
String[] raw = new String[] {"us-east-1.aws.found.io", "undefined", "my-kibana"};
|
||||||
String encoded = CloudSettingId.cloudIdEncode(raw);
|
String encoded = CloudSettingId.cloudIdEncode(raw);
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
|
||||||
exceptionRule.expectMessage("Cloud Id, after decoding, elasticsearch segment is 'undefined', literally.");
|
|
||||||
|
|
||||||
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
new CloudSettingId(encoded);
|
new CloudSettingId(encoded);
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Id, after decoding, elasticsearch segment is 'undefined', literally."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowExceptionWhenKibanaSegmentSegmentIsUndefined() {
|
public void testThrowExceptionWhenKibanaSegmentSegmentIsUndefined() {
|
||||||
String[] raw = new String[] {"us-east-1.aws.found.io", "my-elastic-cluster", "undefined"};
|
String[] raw = new String[] {"us-east-1.aws.found.io", "my-elastic-cluster", "undefined"};
|
||||||
String encoded = CloudSettingId.cloudIdEncode(raw);
|
String encoded = CloudSettingId.cloudIdEncode(raw);
|
||||||
exceptionRule.expect(org.jruby.exceptions.ArgumentError.class);
|
|
||||||
exceptionRule.expectMessage("Cloud Id, after decoding, the kibana segment is 'undefined', literally. You may need to enable Kibana in the Cloud UI.");
|
|
||||||
|
|
||||||
|
Exception thrownException = assertThrows(org.jruby.exceptions.ArgumentError.class, () -> {
|
||||||
new CloudSettingId(encoded);
|
new CloudSettingId(encoded);
|
||||||
|
});
|
||||||
|
assertThat(thrownException.getMessage(), containsString("Cloud Id, after decoding, the kibana segment is 'undefined', literally. You may need to enable Kibana in the Cloud UI."));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// without a label
|
// without a label
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package org.logstash.util;
|
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ExceptionMatcher {
|
|
||||||
void execute() throws Throwable;
|
|
||||||
|
|
||||||
static <T extends Throwable> T assertThrows(Class<T> expectedType, ExceptionMatcher executable) {
|
|
||||||
try {
|
|
||||||
executable.execute();
|
|
||||||
} catch (Throwable actual) {
|
|
||||||
Assert.assertThat(actual, Matchers.instanceOf(expectedType));
|
|
||||||
return expectedType.cast(actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AssertionError(String.format("Expected %s to be thrown, but nothing was thrown.", expectedType.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,8 +12,8 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.hamcrest.Matchers.sameInstance;
|
import static org.hamcrest.Matchers.sameInstance;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.logstash.util.ExceptionMatcher.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
public class SetOnceReferenceTest {
|
public class SetOnceReferenceTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,7 +32,7 @@ buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation project(':logstash-core')
|
testImplementation project(':logstash-core')
|
||||||
testImplementation 'org.assertj:assertj-core:3.8.0'
|
testImplementation 'org.assertj:assertj-core:3.8.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|
|
@ -60,7 +60,7 @@ dependencies {
|
||||||
implementation group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: elasticsearch
|
implementation group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: elasticsearch
|
||||||
implementation "org.openjdk.jmh:jmh-core:$jmh"
|
implementation "org.openjdk.jmh:jmh-core:$jmh"
|
||||||
testImplementation group: 'com.github.tomakehurst', name: 'wiremock-standalone', version: '2.27.0'
|
testImplementation group: 'com.github.tomakehurst', name: 'wiremock-standalone', version: '2.27.0'
|
||||||
testImplementation "junit:junit:4.12"
|
testImplementation "junit:junit:4.13.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
|
|
|
@ -47,7 +47,7 @@ dependencies {
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
|
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
|
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
|
|
|
@ -34,9 +34,9 @@ import java.util.regex.Pattern;
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.logstash.dependencies.Main.ACCEPTABLE_LICENSES_PATH;
|
import static org.logstash.dependencies.Main.ACCEPTABLE_LICENSES_PATH;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ Notice for: json-parser-
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
==========
|
==========
|
||||||
Notice for: junit:junit-4.12
|
Notice for: junit:junit-4.13.2
|
||||||
----------
|
----------
|
||||||
|
|
||||||
TEST
|
TEST
|
||||||
|
|
|
@ -12,6 +12,6 @@ jruby-openssl,0.9.21,,https://rubygems.org/gems/jruby-openssl/versions/0.9.20-ja
|
||||||
jruby-readline,1.1.1,,https://rubygems.org/gems/jruby-readline/versions/1.1.1-java,Apache-2.0,,
|
jruby-readline,1.1.1,,https://rubygems.org/gems/jruby-readline/versions/1.1.1-java,Apache-2.0,,
|
||||||
json-generator,,,https://github.com/flori/json,Ruby,,
|
json-generator,,,https://github.com/flori/json,Ruby,,
|
||||||
json-parser,,,https://rubygems.org/gems/json-parser/versions/0.0.1,Apache-2.0,,
|
json-parser,,,https://rubygems.org/gems/json-parser/versions/0.0.1,Apache-2.0,,
|
||||||
junit:junit,4.12,,https://github.com/junit-team/junit4,Apache-2.0,,
|
junit:junit,4.13.2,,https://github.com/junit-team/junit4,Apache-2.0,,
|
||||||
org.codehaus.janino:commons-compiler,3.0.8,,https://github.com/janino-compiler/janino,BSD-3-Clause-Attribution,,
|
org.codehaus.janino:commons-compiler,3.0.8,,https://github.com/janino-compiler/janino,BSD-3-Clause-Attribution,,
|
||||||
tzinfo,,,https://github.com/tzinfo/tzinfo,MIT,Philip Ross,
|
tzinfo,,,https://github.com/tzinfo/tzinfo,MIT,Philip Ross,
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
"com.fasterxml.jackson.core:jackson-core:2.9.4","https://github.com/FasterXML/jackson-core","The Apache Software License, Version 2.0","http://www.apache.org/licenses/LICENSE-2.0.txt",
|
"com.fasterxml.jackson.core:jackson-core:2.9.4","https://github.com/FasterXML/jackson-core","The Apache Software License, Version 2.0","http://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||||
"com.google.errorprone:javac-shaded:9-dev-r4023-3","https://github.com/google/error-prone-javac","GNU General Public License, version 2, with the Classpath Exception","http://openjdk.java.net/legal/gplv2+ce.html",
|
"com.google.errorprone:javac-shaded:9-dev-r4023-3","https://github.com/google/error-prone-javac","GNU General Public License, version 2, with the Classpath Exception","http://openjdk.java.net/legal/gplv2+ce.html",
|
||||||
"gradle.plugin.com.github.jk1:gradle-license-report:0.7.1",,,,
|
"gradle.plugin.com.github.jk1:gradle-license-report:0.7.1",,,,
|
||||||
"junit:junit:4.12","http://junit.org","Eclipse Public License 1.0","http://www.eclipse.org/legal/epl-v10.html",
|
"junit:junit:4.13.2","http://junit.org","Eclipse Public License 1.0","http://www.eclipse.org/legal/epl-v10.html",
|
||||||
"org.codehaus.janino:commons-compiler:3.0.8",,"New BSD License","https://raw.githubusercontent.com/janino-compiler/janino/master/LICENSE",
|
"org.codehaus.janino:commons-compiler:3.0.8",,"New BSD License","https://raw.githubusercontent.com/janino-compiler/janino/master/LICENSE",
|
||||||
|
|
|
|
@ -44,7 +44,7 @@ buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'net.sf.jopt-simple:jopt-simple:4.6'
|
implementation 'net.sf.jopt-simple:jopt-simple:4.6'
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
|
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
|
||||||
testImplementation "junit:junit:4.12"
|
testImplementation "junit:junit:4.13.2"
|
||||||
testImplementation 'commons-io:commons-io:2.13.0'
|
testImplementation 'commons-io:commons-io:2.13.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ project.sourceCompatibility = JavaVersion.VERSION_11
|
||||||
project.targetCompatibility = JavaVersion.VERSION_11
|
project.targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation "junit:junit:4.13.1"
|
testImplementation "junit:junit:4.13.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
|
|
|
@ -23,7 +23,7 @@ configurations {
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation project(':logstash-core')
|
testImplementation project(':logstash-core')
|
||||||
testImplementation 'org.assertj:assertj-core:3.8.0'
|
testImplementation 'org.assertj:assertj-core:3.8.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
|
|
||||||
geolite2('org.elasticsearch:geolite2-databases:20191119') {
|
geolite2('org.elasticsearch:geolite2-databases:20191119') {
|
||||||
transitive = false
|
transitive = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue