mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ui): serve the Console Contract v2 manifest and pass its URL to the console (#6711)
* feat(ui): serve the Console Contract v2 manifest and pass its URL to the console /_floci/info and /_localstack/info now carry manifest_version, console_contract, cloud, endpoint, health_url, tls, services, defaults and ui, keeping their existing keys. FlociUiManager injects FLOCI_INFO_URL so the console can read it. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * test(ui): drop the DisplayName from the manifest test Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
78278f4a04
commit
258994c1b9
6 files changed
+147
-4
No files matched your search
+20
@@ -68,6 +68,26 @@ class EmulatorInfoControllerIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"/_floci/info", "/_localstack/info"})
|
||||
void info_isTheConsoleContractManifestOnBothPaths(String path) {
|
||||
given()
|
||||
.when().get(path)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType("application/json")
|
||||
.body("manifest_version", equalTo(1))
|
||||
.body("console_contract", equalTo(2))
|
||||
.body("cloud", equalTo("aws"))
|
||||
.body("health_url", equalTo("/_floci/health"))
|
||||
.body("services.s3", equalTo("enabled"))
|
||||
.body("defaults.region", equalTo("us-east-1"))
|
||||
.body("defaults.account_id", equalTo("000000000000"))
|
||||
.body("ui.port", equalTo(4500))
|
||||
.body("version", equalTo(FlociVersion.current()))
|
||||
.body("dynamodb_backend", notNullValue());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"/_floci/init", "/_localstack/init"})
|
||||
void init_returnsLifecycleStateOnBothPaths(String path) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
@@ -61,11 +62,45 @@ class EmulatorInfoControllerTest {
|
||||
void info_reportsTheSelectedDynamoDbBackend() {
|
||||
when(dynamoDbBackendSelector.selected()).thenReturn("local");
|
||||
|
||||
Map<?, ?> info = (Map<?, ?>) controller.info().getEntity();
|
||||
Map<?, ?> info = (Map<?, ?>) manifestController().info().getEntity();
|
||||
|
||||
assertEquals("local", info.get("dynamodb_backend"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void info_isTheConsoleContractManifest() {
|
||||
EmulatorConfig manifestConfig = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
|
||||
when(manifestConfig.effectiveBaseUrl()).thenReturn("http://floci:4566");
|
||||
when(manifestConfig.defaultRegion()).thenReturn("us-east-1");
|
||||
when(manifestConfig.defaultAccountId()).thenReturn("000000000000");
|
||||
when(manifestConfig.tls().enabled()).thenReturn(true);
|
||||
when(manifestConfig.services().ui().enabled()).thenReturn(true);
|
||||
when(manifestConfig.services().ui().port()).thenReturn(4500);
|
||||
when(serviceRegistry.getServices()).thenReturn(Map.of("s3", "running", "ec2", "available"));
|
||||
|
||||
Map<?, ?> info = (Map<?, ?>) new EmulatorInfoController(serviceRegistry, initLifecycleState, storageFactory,
|
||||
resettables, containerTeardowns, certificateAuthority, manifestConfig, dynamoDbBackendSelector)
|
||||
.info().getEntity();
|
||||
|
||||
assertEquals(1, info.get("manifest_version"));
|
||||
assertEquals(2, info.get("console_contract"));
|
||||
assertEquals("aws", info.get("cloud"));
|
||||
assertEquals("floci", info.get("emulator"));
|
||||
assertEquals("http://floci:4566", info.get("endpoint"));
|
||||
assertEquals("/_floci/health", info.get("health_url"));
|
||||
assertEquals(Map.of("enabled", true), info.get("tls"));
|
||||
assertEquals(Map.of("ec2", "disabled", "s3", "enabled"), info.get("services"));
|
||||
assertEquals(Map.of("region", "us-east-1", "account_id", "000000000000"), info.get("defaults"));
|
||||
assertEquals(Map.of("enabled", true, "port", 4500), info.get("ui"));
|
||||
assertEquals("community", info.get("edition"), "the original keys stay");
|
||||
}
|
||||
|
||||
private EmulatorInfoController manifestController() {
|
||||
return new EmulatorInfoController(serviceRegistry, initLifecycleState, storageFactory,
|
||||
resettables, containerTeardowns, certificateAuthority, mock(EmulatorConfig.class, RETURNS_DEEP_STUBS),
|
||||
dynamoDbBackendSelector);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should stop every managed container before wiping storage on reset")
|
||||
void reset_stopsManagedContainersBeforeClearingStorage() {
|
||||
|
||||
@@ -689,9 +689,16 @@ class FlociUiManagerTest {
|
||||
assertTrue(env.contains("AWS_REGION=us-east-1"), env.toString());
|
||||
assertTrue(env.contains("AWS_DEFAULT_REGION=us-east-1"), env.toString());
|
||||
assertTrue(env.contains("FLOCI_CLOUD=aws"), env.toString());
|
||||
assertTrue(env.contains("FLOCI_INFO_URL=http://floci:4566/_floci/info"), env.toString());
|
||||
assertTrue(env.contains("PORT=4500"), env.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theManifestUrlNeverDoublesTheSlash() {
|
||||
assertEquals("http://floci:4566/_floci/info", FlociUiManager.infoUrl("http://floci:4566/"));
|
||||
assertEquals("http://floci:4566/_floci/info", FlociUiManager.infoUrl("http://floci:4566"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theConsoleIsNeverHandedFlocisOwnAwsCredentials() {
|
||||
// The baseline forwards Floci's ambient credentials when none are supplied, which is
|
||||
|
||||
Reference in new issue
Block a user