Skip to content

Commit b66ea70

Browse files
authored
users: remove check for offline mode (#342)
1 parent a53b31a commit b66ea70

File tree

2 files changed

+0
-73
lines changed

2 files changed

+0
-73
lines changed

src/main/java/me/itzg/helpers/users/ManageUsersCommand.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ public class ManageUsersCommand implements Callable<Integer> {
6969
@Option(names = {"-f", "--input-is-file"})
7070
boolean inputIsFile;
7171

72-
@Option(names = "--offline", description = "Disable API conversion of usernames to UUID")
73-
boolean offline;
74-
7572
@Option(names = "--mojang-api-base-url", defaultValue = "${env:MOJANG_API_BASE_URL:-https://api.mojang.com/}")
7673
String mojangApiBaseUrl;
7774

@@ -241,10 +238,6 @@ private JavaUser resolveJavaUserId(SharedFetch sharedFetch, List<? extends JavaU
241238
}
242239
}
243240

244-
if (offline) {
245-
throw new InvalidParameterException("Unable to resolve username while offline: " + input);
246-
}
247-
248241
return resolveUserFromApi(sharedFetch, input);
249242
}
250243

src/test/java/me/itzg/helpers/users/ManageUsersCommandTest.java

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.itzg.helpers.users;
22

3-
import static com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemErr;
43
import static com.github.tomakehurst.wiremock.client.WireMock.*;
54
import static org.assertj.core.api.Assertions.assertThat;
65
import static uk.org.webcompere.modelassert.json.JsonAssertions.assertJson;
@@ -12,7 +11,6 @@
1211
import java.nio.file.Files;
1312
import java.nio.file.Path;
1413
import java.util.Collections;
15-
import me.itzg.helpers.errors.ExitCodeMapper;
1614
import org.intellij.lang.annotations.Language;
1715
import org.junit.jupiter.api.Nested;
1816
import org.junit.jupiter.api.Test;
@@ -397,70 +395,6 @@ void givenUuidsAndAllExist(WireMockRuntimeInfo wmInfo) throws IOException {
397395
verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user1")));
398396
verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user2")));
399397
}
400-
401-
@Test
402-
void offline(WireMockRuntimeInfo wmInfo) {
403-
setupUserStubs();
404-
405-
final Path expectedFile = tempDir.resolve("whitelist.json");
406-
407-
final int exitCode = new CommandLine(
408-
new ManageUsersCommand()
409-
)
410-
.execute(
411-
"--mojang-api-base-url", wmInfo.getHttpBaseUrl(),
412-
"--type", "JAVA_WHITELIST",
413-
"--output-directory", tempDir.toString(),
414-
"--offline",
415-
// mix of ID and UUIDs
416-
USER1_ID, USER2_UUID
417-
);
418-
419-
assertThat(exitCode).isEqualTo(0);
420-
421-
assertThat(expectedFile).exists();
422-
423-
assertJson(expectedFile)
424-
.isArrayContainingExactlyInAnyOrder(
425-
conditions()
426-
.satisfies(conditions()
427-
// names should be retained from existing file
428-
.at("/name").hasValue("")
429-
.at("/uuid").hasValue(USER1_UUID)
430-
)
431-
.satisfies(conditions()
432-
.at("/name").hasValue("")
433-
.at("/uuid").hasValue(USER2_UUID)
434-
)
435-
);
436-
437-
verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user1")));
438-
verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user2")));
439-
}
440-
441-
@Test
442-
void offlineFailsGivenName(WireMockRuntimeInfo wmInfo) throws Exception {
443-
setupUserStubs();
444-
445-
final String err = tapSystemErr(() -> {
446-
final int exitCode = new CommandLine(
447-
new ManageUsersCommand()
448-
)
449-
.setExitCodeExceptionMapper(new ExitCodeMapper())
450-
.execute(
451-
"--mojang-api-base-url", wmInfo.getHttpBaseUrl(),
452-
"--type", "JAVA_WHITELIST",
453-
"--output-directory", tempDir.toString(),
454-
"--offline",
455-
"user1"
456-
);
457-
458-
assertThat(exitCode).isEqualTo(ExitCode.USAGE);
459-
});
460-
461-
assertThat(err).contains("Unable to resolve username while offline: user1");
462-
}
463-
464398
}
465399

466400
@Nested

0 commit comments

Comments
 (0)