|
1 | 1 | package me.itzg.helpers.users; |
2 | 2 |
|
3 | | -import static com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemErr; |
4 | 3 | import static com.github.tomakehurst.wiremock.client.WireMock.*; |
5 | 4 | import static org.assertj.core.api.Assertions.assertThat; |
6 | 5 | import static uk.org.webcompere.modelassert.json.JsonAssertions.assertJson; |
|
12 | 11 | import java.nio.file.Files; |
13 | 12 | import java.nio.file.Path; |
14 | 13 | import java.util.Collections; |
15 | | -import me.itzg.helpers.errors.ExitCodeMapper; |
16 | 14 | import org.intellij.lang.annotations.Language; |
17 | 15 | import org.junit.jupiter.api.Nested; |
18 | 16 | import org.junit.jupiter.api.Test; |
@@ -397,70 +395,6 @@ void givenUuidsAndAllExist(WireMockRuntimeInfo wmInfo) throws IOException { |
397 | 395 | verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user1"))); |
398 | 396 | verify(0, getRequestedFor(urlEqualTo("/users/profiles/minecraft/user2"))); |
399 | 397 | } |
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 | | - |
464 | 398 | } |
465 | 399 |
|
466 | 400 | @Nested |
|
0 commit comments