Runway 1.2.0

This commit is contained in:
Runway committed 2026-10-30 11:24:46 -06:00
1 parent 5fa0c1ef9f
commit 9144c206be
90 files changed
+2737 -554

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>mx.quest</groupId>
<artifactId>runway</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>
</parent>
<artifactId>runway-spi-testkit</artifactId>
@@ -18,7 +18,8 @@ import mx.quest.runway.spi.service.PluginSettings;
* .defaults(Map.of("enabled", true, "limit", 20))
* .site("acme", Map.of("limit", 50))
* .secret("acme", "smtpPassword", "s3cret")
* .appSecret("password", "app-s3cret");
* .appSecret("password", "app-s3cret")
* .savedApp("host", "db.example.com");
* MyWidget widget = new MyWidget(settings);
* }</pre>
*
@@ -34,6 +35,7 @@ public final class FakePluginSettings implements PluginSettings {
private final Map<String, Map<String, Object>> sites = new ConcurrentHashMap<>();
private final Map<String, String> secrets = new ConcurrentHashMap<>();
private final Map<String, String> appSecrets = new ConcurrentHashMap<>();
private final Map<String, String> savedApp = new ConcurrentHashMap<>();
/** The declared {@code siteSettings:} defaults (replaces any set before). */
public FakePluginSettings defaults(Map<String, ?> declaredDefaults) {
@@ -59,6 +61,15 @@ public final class FakePluginSettings implements PluginSettings {
return this;
}
/**
* An app-level value as {@link #savedApp(String)} answers it: what the operator saved and a restart would apply
* (a secret in clear). Pass the declared default yourself if the test needs one.
*/
public FakePluginSettings savedApp(String key, String value) {
savedApp.put(key, value);
return this;
}
@Override
public SettingsView site(String siteId) {
Map<String, Object> values = new LinkedHashMap<>(defaults);
@@ -83,6 +94,12 @@ public final class FakePluginSettings implements PluginSettings {
return value == null || value.isBlank() ? Optional.empty() : Optional.of(value);
}
@Override
public Optional<String> savedApp(String key) {
String value = key == null ? null : savedApp.get(key);
return value == null || value.isBlank() ? Optional.empty() : Optional.of(value);
}
private static String requireSafe(String siteId) {
if (siteId == null || siteId.equals(".") || siteId.equals("..") || !SAFE_ID.matcher(siteId).matches()) {
throw new IllegalArgumentException("unsafe site id: " + siteId);
@@ -56,4 +56,14 @@ class FakePluginSettingsTest {
assertEquals(Optional.empty(), settings.appSecret("other"));
assertEquals(Optional.empty(), settings.appSecret(null));
}
@Test
void savedAppValuesAreReturnedAndBlankOrUnsetOnesAreAbsent() {
FakePluginSettings settings = new FakePluginSettings().savedApp("host", "db.example").savedApp("blank", " ")
.appSecret("password", "running");
assertEquals(Optional.of("db.example"), settings.savedApp("host"));
assertEquals(Optional.empty(), settings.savedApp("blank"));
assertEquals(Optional.empty(), settings.savedApp("password"), "independent of the running secrets");
assertEquals(Optional.empty(), settings.savedApp(null));
}
}