Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance test vault and test exporter #1333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_WORKERS;
import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
import static java.nio.file.Files.exists;
import static java.util.Collections.synchronizedList;
import static java.util.Objects.requireNonNull;
import static org.junit.runners.model.MultipleFailureException.assertEmpty;

Expand Down Expand Up @@ -317,7 +318,7 @@ public void evaluate() throws Throwable
{
final EngineConfiguration config = configuration();
final Thread baseThread = Thread.currentThread();
final List<Throwable> errors = new ArrayList<>();
final List<Throwable> errors = synchronizedList(new ArrayList<>());
final ErrorHandler errorHandler = ex ->
{
ex.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void stop()
{
readEvent.read(this::handleEvent, Integer.MAX_VALUE);
}

if (options.events == null ||
options.events.isEmpty())
{
readEvent.read(this::handleEvent, 1);
}
}
catch (Exception ex)
{
Expand All @@ -87,7 +93,12 @@ private void handleEvent(
String name = context.supplyEventName(event.id());
String message = formatter.format(msgTypeId, buffer, index, length);

if (options.events != null && eventIndex < options.events.size())
if (options.events == null || options.events.isEmpty())
{
throw new IllegalStateException(String.format("event not expected: %s %s %s %s",
qname, id, name, message));
}
else if (eventIndex < options.events.size())
{
TestExporterOptionsConfig.Event e = options.events.get(eventIndex);
if (!qname.equals(e.qName) || !id.equals(e.id) || !name.equals(e.name) || !message.equals(e.message))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public final class TestVaultHandler implements VaultHandler
{
private static final Pattern PATTERN_KEY_ENTRY =
Pattern.compile(
"(?<key>-----BEGIN PRIVATE KEY-----\n[^-]+-----END PRIVATE KEY-----\n)" +
"(?<chain>(?:-----BEGIN CERTIFICATE-----\n[^-]+-----END CERTIFICATE-----\n)+)");
"(?<key>-----BEGIN PRIVATE KEY-----[^-]+-----END PRIVATE KEY-----[^-]+)" +
"(?<chain>(?:-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----[^-]+)+)");

private final TestVaultEntryConfig key;
private final TestVaultEntryConfig signer;
Expand Down Expand Up @@ -87,8 +87,8 @@ public KeyManagerFactory initKeys(

String base64 = encodedKey
.replace("-----BEGIN PRIVATE KEY-----", "")
.replaceAll(System.lineSeparator(), "")
.replace("-----END PRIVATE KEY-----", "");
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("[^a-zA-Z0-9+/=]", "");
byte[] encoded = Base64.getMimeDecoder().decode(base64);

KeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
Expand Down