mirror of
https://github.com/floci-io/floci.git
synced 2026-12-03 02:07:58 -05:00
test(ui): isolate status mocks from landing tests (#5625)
Move the ready-sidecar Host regression into its own integration test class so the landing test checks the real manager before startup. Keep the Host cases and both HTTP status routes unchanged. Signed-off-by: Liu Jie <maxazure@gmail.com>
This commit is contained in:
1 parent
6442d75115
commit
d817d91dd8
2 files changed
+51
-46
No files matched your search
-46
@@ -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()
|
||||
|
||||
+51
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user