Skip to content
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
7 changes: 5 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ dependencies {
testImplementation("io.netty", "netty-transport", Versions.nettyVersion)
testImplementation("io.netty", "netty-codec", Versions.nettyVersion)
testImplementation("com.squareup.okhttp3:mockwebserver:4.9.3")
// Parses the release workflows in the release verification tests.
testImplementation("org.yaml:snakeyaml:1.27")
// Parses the release workflows in the release verification tests. 2.x on purpose: Velocity
// 4.x supplies SnakeYAML 2.x at runtime (via Configurate), where the no-arg SafeConstructor
// constructor no longer exists - ConfigLoaderTest's regression guard for the 0.15.10
// NoSuchMethodError must run against the 2.x API the platform actually provides.
testImplementation("org.yaml:snakeyaml:2.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.geysermc.configutils.file.template.ResourceTemplateReader;
import org.geysermc.configutils.updater.change.Changes;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

@Getter
@RequiredArgsConstructor
Expand All @@ -71,7 +70,9 @@ private static void fixPlaceholderIssue(Path path) throws IOException {

private static boolean hasBedrockIdentitySection(Path path) throws IOException {
try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
Object document = new Yaml(new SafeConstructor()).load(reader);
// Default ctor: delegates to SafeConstructor in both SnakeYAML 1.x and 2.x (the
// no-arg SafeConstructor ctor was removed in 2.0, which Velocity provides at runtime).
Object document = new Yaml().load(reader);
return document instanceof Map<?, ?> map && map.containsKey("bedrock-identity");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,33 @@ void loginReassertDefaultsToOnAndPropertiesOnly() throws Exception {
"restoring the UUID needs an operator-side prerequisite, so it must be opt-in");
}

/**
* Velocity 4.x provides SnakeYAML 2.x at runtime (through Configurate), where the no-arg
* {@code SafeConstructor()} constructor was removed. 0.15.10 (PR #157) loaded an existing
* config.yml with {@code new Yaml(new SafeConstructor())}, so every existing-config load on
* Velocity crashed with NoSuchMethodError. The core test dependency pins SnakeYAML 2.x to
* reproduce that platform classpath; loading a legacy config must apply the safe Minekube
* defaults instead of crashing.
*/
@Test
void legacyConfigLoadsOnSnakeYaml2xRuntimeClasspath() throws Exception {
Files.writeString(tempDir.resolve("config.yml"), String.join("\n",
"endpoint: codexp2p3",
"allow-offline-mode-players: false",
"metrics:",
" disabled: true",
" uuid: 00000000-0000-0000-0000-000000000000",
"config-version: 1",
""));

ConnectConfig config = load(ConnectConfig.class);

assertEquals("warn", config.getBedrockIdentity().getEnforcement());
assertEquals(
"https://watch-connect.minekube.net/.well-known/minekube-connect/bedrock-identity-keys.json",
config.getBedrockIdentity().getMetadataUrl());
}

/** Both halves are operator-controllable from the config file. */
@Test
void loadsLoginReassertOverrides() throws Exception {
Expand Down
Loading