mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(cloudformation): name an https ResponseURL for a custom resource when TLS is on (#6993)
This commit is contained in:
1 parent
626af42d45
commit
a0b39a4ad0
11 files changed
+353
-17
No files matched your search
@@ -98,7 +98,7 @@ public class TlsCertificateManager implements Resettable {
|
||||
return;
|
||||
}
|
||||
synchronized (lock) {
|
||||
if (!loadOnce() || covers(name)) {
|
||||
if (!loadOnce() || covers(knownHostnames, name)) {
|
||||
return;
|
||||
}
|
||||
if (!isAllowed(name)) {
|
||||
@@ -118,6 +118,32 @@ public class TlsCertificateManager implements Resettable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the certificate Floci serves names {@code host}, exactly or under a one-label
|
||||
* wildcard, so a client that verifies the name accepts it: the managed leaf with every name it
|
||||
* learned, or a user-provided certificate as it is on disk. False with TLS off, for a host it
|
||||
* does not name, such as an IP from {@code docker-host-override} or the container-IP fallback,
|
||||
* and when the certificate cannot be read.
|
||||
*/
|
||||
public boolean serves(String host) {
|
||||
String name = normalize(host);
|
||||
if (name == null || !config.tls().enabled()) {
|
||||
return false;
|
||||
}
|
||||
if (managesServerCertificate()) {
|
||||
synchronized (lock) {
|
||||
return loadOnce() && covers(knownHostnames, name);
|
||||
}
|
||||
}
|
||||
String certPath = config.tls().certPath().orElse("");
|
||||
try {
|
||||
return covers(sansOf(Pem.parseCertificate(Files.readString(Path.of(certPath)))), name);
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("TLS: could not read the certificate {0} to check it names {1}: {2}", certPath, name, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Every SAN on the served leaf, configured and learned, lower-cased. Empty when not managed. */
|
||||
public Set<String> knownHostnames() {
|
||||
if (!managesServerCertificate()) {
|
||||
@@ -231,12 +257,12 @@ public class TlsCertificateManager implements Resettable {
|
||||
certificateUpdated.fire(new CertificateUpdatedEvent(TlsConfig.DEFAULT_NAME, cfg));
|
||||
}
|
||||
|
||||
private boolean covers(String name) {
|
||||
if (knownHostnames.contains(name)) {
|
||||
private static boolean covers(Set<String> sans, String name) {
|
||||
if (sans.contains(name)) {
|
||||
return true;
|
||||
}
|
||||
int dot = name.indexOf('.');
|
||||
return dot > 0 && knownHostnames.contains("*" + name.substring(dot));
|
||||
return dot > 0 && sans.contains("*" + name.substring(dot));
|
||||
}
|
||||
|
||||
private boolean isAllowed(String name) {
|
||||
|
||||
+30
-2
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.core.common.docker;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.config.TlsCertificateManager;
|
||||
import io.github.hectorvent.floci.core.common.dns.EmbeddedDnsServer;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -33,16 +34,19 @@ public class ContainerReachableEndpoint {
|
||||
private final EmulatorConfig config;
|
||||
private final DockerHostResolver dockerHostResolver;
|
||||
private final EmbeddedDnsServer embeddedDnsServer;
|
||||
private final TlsCertificateManager tlsCertificates;
|
||||
private final int httpPort;
|
||||
|
||||
@Inject
|
||||
public ContainerReachableEndpoint(EmulatorConfig config,
|
||||
DockerHostResolver dockerHostResolver,
|
||||
EmbeddedDnsServer embeddedDnsServer,
|
||||
TlsCertificateManager tlsCertificates,
|
||||
@ConfigProperty(name = "quarkus.http.port") int httpPort) {
|
||||
this.config = config;
|
||||
this.dockerHostResolver = dockerHostResolver;
|
||||
this.embeddedDnsServer = embeddedDnsServer;
|
||||
this.tlsCertificates = tlsCertificates;
|
||||
this.httpPort = httpPort;
|
||||
}
|
||||
|
||||
@@ -62,14 +66,38 @@ public class ContainerReachableEndpoint {
|
||||
|
||||
/** Uses the Docker host when the container does not receive Floci's DNS resolver. */
|
||||
public String baseUrl(boolean useEmbeddedDns) {
|
||||
String flociHostname = useEmbeddedDns && embeddedDnsServer.getServerIp().isPresent()
|
||||
return "http://" + host(useEmbeddedDns) + ":" + port();
|
||||
}
|
||||
|
||||
private String host(boolean useEmbeddedDns) {
|
||||
return useEmbeddedDns && embeddedDnsServer.getServerIp().isPresent()
|
||||
? config.hostname().orElse(EmbeddedDnsServer.DEFAULT_SUFFIX)
|
||||
: dockerHostResolver.resolve();
|
||||
return "http://" + flociHostname + ":" + port();
|
||||
}
|
||||
|
||||
/** The port of {@link #baseUrl()}: the one a launched container can reach Floci on. */
|
||||
public int port() {
|
||||
return config.tls().enabled() ? config.port() : httpPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URL a custom resource's {@code ResponseURL} names: {@link #baseUrl()}, over https
|
||||
* where Floci serves TLS under a certificate that names the host.
|
||||
*
|
||||
* <p>AWS hands a custom resource a presigned Amazon S3 URL to PUT its response to
|
||||
* (CloudFormation User Guide, CloudFormation custom resource request and response reference,
|
||||
* ResponseURL), so a handler that PUTs with Node's {@code https} module, as AWS's own
|
||||
* {@code cfn-response} does, refuses an http URL ({@code Protocol "http:" not supported}). With
|
||||
* TLS enabled, {@code TlsProxyServer} serves https beside http on {@link EmulatorConfig#port()},
|
||||
* and every container Floci launches trusts Floci's CA through {@code NODE_EXTRA_CA_CERTS} and
|
||||
* the other bundle variables, so the https URL is reachable with no shim in the handler. A host
|
||||
* the certificate does not name, an IP from {@code docker-host-override} or the container-IP
|
||||
* fallback when the embedded DNS server cannot start, would fail the handler's certificate
|
||||
* check where http works, so that URL stays http.
|
||||
*/
|
||||
public String customResourceResponseBaseUrl() {
|
||||
String host = host(true);
|
||||
boolean https = tlsCertificates.serves(host);
|
||||
return (https ? "https://" : "http://") + host + ":" + port();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -323,7 +323,7 @@ public class CustomResourceCfnProvisioner implements CfnResourceProvisioner {
|
||||
try {
|
||||
ObjectNode event = objectMapper.createObjectNode();
|
||||
event.put("RequestType", requestType);
|
||||
event.put("ResponseURL", reachableEndpoint.baseUrl() + "/cfn-response/" + token);
|
||||
event.put("ResponseURL", reachableEndpoint.customResourceResponseBaseUrl() + "/cfn-response/" + token);
|
||||
event.put("StackId", stackId);
|
||||
event.put("RequestId", UUID.randomUUID().toString());
|
||||
event.put("ResourceType", resourceType);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package io.github.hectorvent.floci.config;
|
||||
|
||||
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
|
||||
import io.quarkus.tls.CertificateUpdatedEvent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -169,6 +171,55 @@ class TlsCertificateManagerTest extends TlsCertificateManagerFixture {
|
||||
verify(defaultTls, never()).reload();
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesTheNamesTheLeafCarriesAndNoOther() {
|
||||
TlsCertificateManager m = manager();
|
||||
|
||||
assertTrue(m.serves("localhost"));
|
||||
assertTrue(m.serves("LOCALHOST.floci.io."), "case and a trailing dot are not part of the name");
|
||||
assertTrue(m.serves("sqs.localhost.floci.io"), "under the one-label wildcard");
|
||||
assertFalse(m.serves("a.b.localhost.floci.io"), "a wildcard covers one label");
|
||||
assertFalse(m.serves("172.18.0.2"), "an IP the leaf does not list");
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesANameOnceTheLeafLearnedIt() {
|
||||
TlsCertificateManager m = manager();
|
||||
String learned = "orders.example.internal";
|
||||
assertFalse(m.serves(learned));
|
||||
|
||||
m.ensureHost(learned);
|
||||
|
||||
assertTrue(m.serves(learned));
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesNothingWithTlsOff() {
|
||||
when(config.tls().enabled()).thenReturn(false);
|
||||
|
||||
assertFalse(manager().serves("localhost"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesTheNamesOfAUserProvidedCertificate() throws Exception {
|
||||
Path userCert = tempDir.resolve("user.crt");
|
||||
Files.writeString(userCert, ca.issueServerCertificate("floci", List.of("floci", "10.0.0.5"), KeyAlgorithm.RSA_2048, null)
|
||||
.certificatePem());
|
||||
when(config.tls().certPath()).thenReturn(Optional.of(userCert.toString()));
|
||||
TlsCertificateManager m = manager();
|
||||
|
||||
assertTrue(m.serves("floci"));
|
||||
assertTrue(m.serves("10.0.0.5"));
|
||||
assertFalse(m.serves("localhost"), "the managed leaf on disk is not the one served");
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesNothingWhenAUserProvidedCertificateCannotBeRead() {
|
||||
when(config.tls().certPath()).thenReturn(Optional.of(tempDir.resolve("missing.crt").toString()));
|
||||
|
||||
assertFalse(manager().serves("localhost"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNothingWithAUserProvidedCertificate() throws Exception {
|
||||
when(config.tls().certPath()).thenReturn(Optional.of("/etc/floci/user.crt"));
|
||||
|
||||
+40
-1
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.core.common.docker;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.config.TlsCertificateManager;
|
||||
import io.github.hectorvent.floci.core.common.dns.EmbeddedDnsServer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -24,11 +25,12 @@ class ContainerReachableEndpointTest {
|
||||
private final DockerHostResolver dockerHostResolver = mock(DockerHostResolver.class);
|
||||
private final EmbeddedDnsServer embeddedDnsServer = mock(EmbeddedDnsServer.class);
|
||||
private final EmulatorConfig.TlsConfig tls = mock(EmulatorConfig.TlsConfig.class);
|
||||
private final TlsCertificateManager tlsCertificates = mock(TlsCertificateManager.class);
|
||||
private final ContainerReachableEndpoint endpoint = endpoint(4566);
|
||||
|
||||
private ContainerReachableEndpoint endpoint(int httpPort) {
|
||||
when(config.tls()).thenReturn(tls);
|
||||
return new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, httpPort);
|
||||
return new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, tlsCertificates, httpPort);
|
||||
}
|
||||
|
||||
private void hostMappedTo4811() {
|
||||
@@ -100,4 +102,41 @@ class ContainerReachableEndpointTest {
|
||||
assertEquals("http://172.18.0.2:4566", endpoint(4510).baseUrl());
|
||||
assertEquals("http://172.18.0.2:4566", endpoint(4510).baseUrl(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customResourceResponseUrlIsHttpsForAHostTheCertificateNames() {
|
||||
// TlsProxyServer serves https on floci.port, and a custom resource's handler PUTs to its
|
||||
// ResponseURL with https, as it does to AWS's presigned S3 URL.
|
||||
when(tls.enabled()).thenReturn(true);
|
||||
when(config.port()).thenReturn(4566);
|
||||
when(config.hostname()).thenReturn(Optional.empty());
|
||||
when(embeddedDnsServer.getServerIp()).thenReturn(Optional.of("172.18.0.2"));
|
||||
when(tlsCertificates.serves(EmbeddedDnsServer.DEFAULT_SUFFIX)).thenReturn(true);
|
||||
|
||||
assertEquals("https://" + EmbeddedDnsServer.DEFAULT_SUFFIX + ":4566",
|
||||
endpoint(4510).customResourceResponseBaseUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customResourceResponseUrlStaysHttpForAnIpTheCertificateDoesNotName() {
|
||||
// The container-IP fallback when the embedded DNS server cannot start, or an IP set as
|
||||
// docker-host-override: the leaf does not name it, so a handler verifying the certificate
|
||||
// would refuse https where http works.
|
||||
when(tls.enabled()).thenReturn(true);
|
||||
when(config.port()).thenReturn(4566);
|
||||
when(embeddedDnsServer.getServerIp()).thenReturn(Optional.empty());
|
||||
when(dockerHostResolver.resolve()).thenReturn("172.18.0.2");
|
||||
when(tlsCertificates.serves("172.18.0.2")).thenReturn(false);
|
||||
|
||||
assertEquals("http://172.18.0.2:4566", endpoint(4510).customResourceResponseBaseUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customResourceResponseUrlIsHttpWithoutTls() {
|
||||
hostMappedTo4811();
|
||||
when(embeddedDnsServer.getServerIp()).thenReturn(Optional.empty());
|
||||
when(dockerHostResolver.resolve()).thenReturn("172.18.0.2");
|
||||
|
||||
assertEquals("http://172.18.0.2:4566", endpoint(4566).customResourceResponseBaseUrl());
|
||||
}
|
||||
}
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation;
|
||||
|
||||
import io.github.hectorvent.floci.config.FlociCertificateAuthority;
|
||||
import io.github.hectorvent.floci.config.SelfSignedTlsProfile;
|
||||
import io.github.hectorvent.floci.core.common.XmlParser;
|
||||
import io.github.hectorvent.floci.services.lambda.LambdaService;
|
||||
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
|
||||
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
|
||||
import io.github.hectorvent.floci.testing.CfnStackWaits;
|
||||
import io.quarkus.test.InjectMock;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static io.github.hectorvent.floci.testing.CfnRequests.cfn;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* With TLS on, a custom resource's {@code ResponseURL} is https, as AWS's presigned S3 URL is
|
||||
* (CloudFormation User Guide, CloudFormation custom resource request and response reference), so a
|
||||
* Node handler that PUTs its response with {@code https.request}, which refuses an http URL with
|
||||
* {@code Protocol "http:" not supported}, completes the resource.
|
||||
*
|
||||
* <p>The ServiceToken Lambda is mocked, as {@code CloudFormationCustomResourceStackIdIntegrationTest}
|
||||
* mocks it, and answers by running a real Node handler on the event. The handler trusts Floci's CA
|
||||
* through {@code NODE_EXTRA_CA_CERTS}, as every container Floci launches does. The ports are the
|
||||
* ones TLS mode serves in production: the protocol-detecting proxy on {@code floci.port}, the HTTP
|
||||
* backend on 4510 and the HTTPS backend on 4511.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(CloudFormationCustomResourceHttpsResponseUrlIntegrationTest.Profile.class)
|
||||
class CloudFormationCustomResourceHttpsResponseUrlIntegrationTest {
|
||||
|
||||
private static final String SERVICE_TOKEN =
|
||||
"arn:aws:lambda:us-east-1:000000000000:function:https-response-probe";
|
||||
private static final int FLOCI_PORT = 4592;
|
||||
|
||||
/** A response PUT the way a Node custom resource handler sends it, over node:https. */
|
||||
private static final String HANDLER = """
|
||||
const { request } = require("node:https");
|
||||
const event = JSON.parse(require("node:fs").readFileSync(process.argv[2], "utf8"));
|
||||
const body = JSON.stringify({
|
||||
Status: "SUCCESS",
|
||||
RequestId: event.RequestId,
|
||||
StackId: event.StackId,
|
||||
LogicalResourceId: event.LogicalResourceId,
|
||||
PhysicalResourceId: "https-response-probe",
|
||||
Data: { Scheme: new URL(event.ResponseURL).protocol }
|
||||
});
|
||||
const req = request(new URL(event.ResponseURL), {
|
||||
method: "PUT",
|
||||
headers: { "content-type": "", "content-length": Buffer.byteLength(body) }
|
||||
}, (res) => { res.resume(); res.on("end", () => process.exit(res.statusCode === 200 ? 0 : 1)); });
|
||||
req.on("error", (error) => { console.error(error.message); process.exit(1); });
|
||||
req.end(body);
|
||||
""";
|
||||
|
||||
private final List<String> handlerErrors = new CopyOnWriteArrayList<>();
|
||||
|
||||
@InjectMock
|
||||
LambdaService lambdaService;
|
||||
|
||||
@BeforeAll
|
||||
static void requireNode() {
|
||||
Assumptions.assumeTrue(nodeAvailable(), "node must be on the PATH to run the custom resource handler");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void handlerRunsInNode() {
|
||||
when(lambdaService.invoke(any(), eq(SERVICE_TOKEN), any(), eq(InvocationType.RequestResponse)))
|
||||
.thenAnswer(inv -> {
|
||||
runHandler((byte[]) inv.getArgument(2));
|
||||
return new InvokeResult(200, null, "null".getBytes(StandardCharsets.UTF_8), null, "req-1");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void nodeHandlerPutsItsResponseOverHttpsAndTheResourceCompletes() throws Exception {
|
||||
String stackName = "cr-https-response-" + Long.toString(System.nanoTime(), 36);
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"Probe": {"Type": "Custom::HttpsResponseProbe", "Properties": {"ServiceToken": "%s"}}
|
||||
},
|
||||
"Outputs": {"Scheme": {"Value": {"Fn::GetAtt": ["Probe", "Scheme"]}}}
|
||||
}
|
||||
""".formatted(SERVICE_TOKEN);
|
||||
|
||||
cfn("CreateStack", stackName).formParam("TemplateBody", template)
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
try {
|
||||
CfnStackWaits.awaitStatus(stackName, "CREATE_COMPLETE");
|
||||
assertEquals(List.of(), handlerErrors);
|
||||
String created = cfn("DescribeStacks", stackName)
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.extract().asString();
|
||||
assertEquals("https:", XmlParser.extractPairs(created, "Outputs", "OutputKey", "OutputValue")
|
||||
.get("Scheme"));
|
||||
} finally {
|
||||
cfn("DeleteStack", stackName).when().post("/");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the handler with its output in a file, so the wait is bounded by its deadline and
|
||||
* never by a read; a handler still running at the deadline is destroyed.
|
||||
*/
|
||||
private void runHandler(byte[] payload) throws IOException, InterruptedException {
|
||||
Path event = Files.createTempFile("cr-event-", ".json");
|
||||
Path script = Files.createTempFile("cr-handler-", ".js");
|
||||
Path output = Files.createTempFile("cr-handler-", ".log");
|
||||
Process process = null;
|
||||
try {
|
||||
Files.write(event, payload);
|
||||
Files.writeString(script, HANDLER);
|
||||
String ca = FlociCertificateAuthority.loadOrCreate(Path.of(SelfSignedTlsProfile.TLS_DIR))
|
||||
.certificatePath().toAbsolutePath().toString();
|
||||
ProcessBuilder node = new ProcessBuilder("node", script.toString(), event.toString())
|
||||
.redirectErrorStream(true)
|
||||
.redirectOutput(output.toFile());
|
||||
node.environment().put("NODE_EXTRA_CA_CERTS", ca);
|
||||
process = node.start();
|
||||
if (!process.waitFor(30, TimeUnit.SECONDS)) {
|
||||
handlerErrors.add("the handler did not exit within 30 seconds: " + Files.readString(output).trim());
|
||||
} else if (process.exitValue() != 0) {
|
||||
handlerErrors.add(Files.readString(output).trim());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handlerErrors.add(e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
Files.deleteIfExists(event);
|
||||
Files.deleteIfExists(script);
|
||||
Files.deleteIfExists(output);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean nodeAvailable() {
|
||||
Process process = null;
|
||||
try {
|
||||
process = new ProcessBuilder("node", "--version").redirectErrorStream(true)
|
||||
.redirectOutput(ProcessBuilder.Redirect.DISCARD).start();
|
||||
return process.waitFor(10, TimeUnit.SECONDS) && process.exitValue() == 0;
|
||||
} catch (IOException | InterruptedException e) {
|
||||
return false;
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SelfSignedTlsProfile}'s TLS, served the way TLS mode serves it outside tests: the
|
||||
* proxy on {@code floci.port}, the backends on 4510 and 4511. The handler reaches Floci on
|
||||
* localhost, which the leaf covers.
|
||||
*/
|
||||
public static final class Profile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
Map<String, String> overrides = new HashMap<>(new SelfSignedTlsProfile().getConfigOverrides());
|
||||
overrides.put("quarkus.http.test-port", "4510");
|
||||
overrides.put("quarkus.http.test-ssl-port", "4511");
|
||||
overrides.put("floci.port", String.valueOf(FLOCI_PORT));
|
||||
overrides.put("floci.services.lambda.docker-host-override", "localhost");
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -57,6 +57,7 @@ class CustomResourceProvisionerTest {
|
||||
store = new CustomResourceResponseStore(new ProviderFrameworkDetector(lambdaService));
|
||||
ContainerReachableEndpoint endpoint = mock(ContainerReachableEndpoint.class);
|
||||
when(endpoint.baseUrl()).thenReturn("http://floci:4566");
|
||||
when(endpoint.customResourceResponseBaseUrl()).thenReturn("http://floci:4566");
|
||||
|
||||
provisioner = CfnProvisionerFixture.builder()
|
||||
.lambda(lambdaService)
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class CodeBuildRunnerTest {
|
||||
when(config.tls()).thenReturn(mock(EmulatorConfig.TlsConfig.class));
|
||||
when(config.port()).thenReturn(4566);
|
||||
ContainerDetector containerDetector = mock(ContainerDetector.class);
|
||||
ContainerReachableEndpoint endpoint = new ContainerReachableEndpoint(config, null, null, 4811);
|
||||
ContainerReachableEndpoint endpoint = new ContainerReachableEndpoint(config, null, null, null, 4811);
|
||||
CodeBuildRunner runner = new CodeBuildRunner(null, null, null, null, null, null, null,
|
||||
config, containerDetector, null, endpoint);
|
||||
|
||||
|
||||
+4
-4
@@ -58,7 +58,7 @@ class FlociDuckClientServiceTest {
|
||||
when(config.tls()).thenReturn(mock(EmulatorConfig.TlsConfig.class));
|
||||
|
||||
FlociDuckClient client = new FlociDuckClient(duckManager, config,
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566), mapper);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566), mapper);
|
||||
client.execute("CREATE VIEW example AS SELECT 1", "", null);
|
||||
|
||||
assertEquals("CREATE VIEW example AS SELECT 1", requestBody.get().path("sql").asText());
|
||||
@@ -90,7 +90,7 @@ class FlociDuckClientServiceTest {
|
||||
when(dockerHostResolver.resolve()).thenReturn("172.18.0.2");
|
||||
|
||||
FlociDuckClient client = new FlociDuckClient(duckManager, config,
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566), mapper);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566), mapper);
|
||||
client.execute("SELECT 1", "", null);
|
||||
|
||||
assertEquals("http://172.18.0.2:4566", requestBody.get().path("s3_endpoint").asText());
|
||||
@@ -120,7 +120,7 @@ class FlociDuckClientServiceTest {
|
||||
when(dockerHostResolver.resolve()).thenReturn("127.0.0.1");
|
||||
|
||||
FlociDuckClient client = new FlociDuckClient(duckManager, config,
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566), mapper);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566), mapper);
|
||||
client.execute("SELECT 1", "INSTALL iceberg;", "s3://bucket/out.csv",
|
||||
"ASIAEXAMPLE", "secretKey123", "tokenXYZ");
|
||||
|
||||
@@ -159,7 +159,7 @@ class FlociDuckClientServiceTest {
|
||||
when(dockerHostResolver.resolve()).thenReturn("127.0.0.1");
|
||||
|
||||
FlociDuckClient client = new FlociDuckClient(duckManager, config,
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566), mapper);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566), mapper);
|
||||
client.query("SELECT 1 AS col", "", "ASIAEXAMPLE", "secretKey123", "tokenXYZ");
|
||||
|
||||
JsonNode body = requestBody.get();
|
||||
|
||||
@@ -250,7 +250,7 @@ class LambdaImageConfigTest {
|
||||
|
||||
ContainerBuilder containerBuilder = new ContainerBuilder(config, dockerHostResolver, embeddedDnsServer);
|
||||
ContainerReachableEndpoint reachableEndpoint =
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566);
|
||||
LaunchedContainerAwsEnv awsEnv = new LaunchedContainerAwsEnv(reachableEndpoint);
|
||||
launcher = new ContainerLauncher(containerBuilder, lifecycleManager, logStreamer, imageResolver,
|
||||
runtimeApiServerFactory, dockerHostResolver, config, ecrRegistryManager,
|
||||
|
||||
+3
-3
@@ -237,7 +237,7 @@ class ContainerLauncherTest {
|
||||
LambdaLayerService layers = LambdaLayerFixtures.accountScopedService(
|
||||
defaultAccount, region, Map.of(defaultAccount, defaultLayer, owner, ownerLayer));
|
||||
ContainerReachableEndpoint endpoint =
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566);
|
||||
ContainerLauncher backgroundLauncher = new ContainerLauncher(
|
||||
new ContainerBuilder(config, dockerHostResolver, embeddedDnsServer),
|
||||
lifecycleManager, logStreamer, imageResolver, runtimeApiServerFactory,
|
||||
@@ -459,7 +459,7 @@ class ContainerLauncherTest {
|
||||
ContainerBuilder builder = new ContainerBuilder(config, dockerHostResolver, embeddedDnsServer,
|
||||
networkResolver, new ContainerEngineDetector(dockerClient));
|
||||
ContainerReachableEndpoint endpoint =
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566);
|
||||
return new ContainerLauncher(builder, lifecycleManager, logStreamer, selectedResolver,
|
||||
runtimeApiServerFactory, dockerHostResolver, config, ecrRegistryManager,
|
||||
layerService, new LaunchedContainerAwsEnv(endpoint),
|
||||
@@ -2250,7 +2250,7 @@ class ContainerLauncherTest {
|
||||
void launchFunction_forwardsExtensionOutputToCloudWatchLogs() throws Exception {
|
||||
CloudWatchLogsService cloudWatchLogs = mock(CloudWatchLogsService.class);
|
||||
ContainerReachableEndpoint reachableEndpoint =
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, 4566);
|
||||
new ContainerReachableEndpoint(config, dockerHostResolver, embeddedDnsServer, null, 4566);
|
||||
ContainerLauncher launcherWithRealStreamer = new ContainerLauncher(
|
||||
new ContainerBuilder(config, dockerHostResolver, embeddedDnsServer),
|
||||
lifecycleManager,
|
||||
|
||||
Reference in new issue
Block a user