Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

test(ui): isolate status mocks from landing tests (#5625)

Liu Jied817d91dd837
diff --git a/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiLandingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiLandingIntegrationTest.java
index 39a60639b1..265f7e0b11 100644
--- a/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiLandingIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiLandingIntegrationTest.java
@@ -1,20 +1,11 @@
package io.github.hectorvent.floci.services.floci.ui;
-import io.github.hectorvent.floci.services.floci.ui.FlociUiManager.UiStatus;
-import io.quarkus.test.InjectMock;
import io.quarkus.test.junit.QuarkusTest;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-
-import java.util.List;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.mockito.Mockito.when;
/**
* Verifies the browser landing page content-negotiation on {@code /} and the
@@ -24,43 +15,6 @@ import static org.mockito.Mockito.when;
@QuarkusTest
class UiLandingIntegrationTest {
- @InjectMock
- FlociUiManager uiManager;
-
- @BeforeEach
- void sidecarHasNotStarted() {
- when(uiManager.status()).thenReturn(new UiStatus(false, false, 0, null));
- }
-
- @ParameterizedTest
- @CsvSource({
- "[::1]:4566, http://[::1]:4500/",
- "[::1], http://[::1]:4500/",
- "[2001:db8::1]:4566, http://[2001:db8::1]:4500/",
- "[2001:db8::1], http://[2001:db8::1]:4500/",
- "floci.example:4566, http://floci.example:4500/",
- "floci.example, http://floci.example:4500/",
- "127.0.0.1:4566, http://127.0.0.1:4500/",
- "127.0.0.1, http://127.0.0.1:4500/"
- })
- void readyStatusUsesTheBrowserHostAndPublishedPort(String host, String url) {
- when(uiManager.status()).thenReturn(new UiStatus(true, true, 4500, null));
-
- for (String prefix : List.of("_floci", "_localstack")) {
- given()
- .header("Host", host)
- .accept("application/json")
- .when()
- .get("/" + prefix + "/ui/status")
- .then()
- .statusCode(200)
- .body("ready", is(true))
- .body("url", is(url))
- .body("error", nullValue());
- }
- }
-
-
@Test
void browserAcceptHtmlGetsLandingPage() {
given()
diff --git a/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiStatusIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiStatusIntegrationTest.java
new file mode 100644
index 0000000000..8c0cec778f
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/floci/ui/UiStatusIntegrationTest.java
@@ -0,0 +1,51 @@
+package io.github.hectorvent.floci.services.floci.ui;
+
+import io.github.hectorvent.floci.services.floci.ui.FlociUiManager.UiStatus;
+import io.quarkus.test.InjectMock;
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import java.util.List;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.mockito.Mockito.when;
+
+/** Verifies ready-sidecar redirect URLs through HTTP without starting a Docker sidecar. */
+@QuarkusTest
+class UiStatusIntegrationTest {
+
+ @InjectMock
+ FlociUiManager uiManager;
+
+ @ParameterizedTest
+ @CsvSource({
+ "[::1]:4566, http://[::1]:4500/",
+ "[::1], http://[::1]:4500/",
+ "[2001:db8::1]:4566, http://[2001:db8::1]:4500/",
+ "[2001:db8::1], http://[2001:db8::1]:4500/",
+ "floci.example:4566, http://floci.example:4500/",
+ "floci.example, http://floci.example:4500/",
+ "127.0.0.1:4566, http://127.0.0.1:4500/",
+ "127.0.0.1, http://127.0.0.1:4500/"
+ })
+ void readyStatusUsesTheBrowserHostAndPublishedPort(String host, String url) {
+ when(uiManager.status()).thenReturn(new UiStatus(true, true, 4500, null));
+
+ for (String prefix : List.of("_floci", "_localstack")) {
+ given()
+ .header("Host", host)
+ .accept("application/json")
+ .when()
+ .get("/" + prefix + "/ui/status")
+ .then()
+ .statusCode(200)
+ .body("ready", is(true))
+ .body("url", is(url))
+ .body("error", nullValue());
+ }
+ }
+
+}