Browse Source
Closes gh-49590dependabot/npm_and_yarn/antora/springio/asciidoctor-extensions-1.0.0-alpha.18
18 changed files with 492 additions and 16 deletions
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
MIIFhjCCA26gAwIBAgIUfIkk29IT9OpbgfjL8oRIPSLjUcAwDQYJKoZIhvcNAQEL |
||||
BQAwOzEZMBcGA1UECgwQU3ByaW5nIEJvb3QgVGVzdDEeMBwGA1UEAwwVQ2VydGlm |
||||
aWNhdGUgQXV0aG9yaXR5MB4XDTI0MDUwMTE2NTMyNVoXDTM0MDQyOTE2NTMyNVow |
||||
OzEZMBcGA1UECgwQU3ByaW5nIEJvb3QgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNh |
||||
dGUgQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAusN2 |
||||
KzQQUUxZSiI3ZZuZohFwq2KXSUNPdJ6rgD3/YKNTDSZXKZPO53kYPP0DXf0sm3CH |
||||
cyWSWVabyimZYuPWena1MElSL4ZpJ9WwkZoOQ3bPFK1utz6kMOwrgAUcky8H/rIK |
||||
j2JEBhkSHUIGr57NjUEwG1ygaSerM8RzWw1PtMq+C8LOu3v94qzE3NDg1QRpyvV9 |
||||
OmsLsjISd0ZmAJNi9vmiEH923KnPyiqnQmWKpYicdgQmX1GXylS22jZqAwaOkYGj |
||||
X8UdeyvrohkZkM0hn9uaSufQGEW4yKACn3PkjJtzi8drBIyjIi9YcAzBxZB9oVKq |
||||
XZMlltgO2fDMmIJi0Ngt0Ci7fCoEMqSocKyDKML6YLr9UWtx4bfsrk+rVO9Q/D/v |
||||
8RKgstv7dCf2KWRX3ZJEC0IBHS5gLNq0qqqVcGx3LcSyhdiKJOtSwAnNkHMh+jSQ |
||||
xLSlBjcSqTPiGTRK/Rddl+xnU/mBgk7ZBGNrUFaD5McMFjddS7Ih82aHnpQ1gekW |
||||
nUGv+Tm/G68h2BvZ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Wzlx1h2WVJ65ASFDjBWb8eVmB6 |
||||
Dyno/RVFR/rUL5091gjGRXhLsi1oUHKdEzU= |
||||
-----END CERTIFICATE----- |
||||
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
services: |
||||
otlp: |
||||
image: '{imageName}' |
||||
ports: |
||||
- '4317' |
||||
- '4318' |
||||
labels: |
||||
- 'org.springframework.boot.sslbundle.pem.truststore.certificate=ca.crt' |
||||
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.micrometer.metrics.autoconfigure.export.otlp; |
||||
|
||||
import java.io.IOException; |
||||
import java.net.URI; |
||||
import java.net.http.HttpClient; |
||||
import java.net.http.HttpRequest; |
||||
import java.net.http.HttpRequest.BodyPublishers; |
||||
import java.net.http.HttpResponse; |
||||
import java.net.http.HttpResponse.BodyHandlers; |
||||
import java.time.Duration; |
||||
|
||||
import javax.net.ssl.SSLParameters; |
||||
|
||||
import io.micrometer.core.ipc.http.HttpSender; |
||||
import org.jspecify.annotations.Nullable; |
||||
|
||||
import org.springframework.boot.ssl.SslBundle; |
||||
import org.springframework.boot.ssl.SslOptions; |
||||
|
||||
/** |
||||
* {@link HttpSender} implementation using the JDK {@link HttpClient}. |
||||
* |
||||
* @author Moritz Halbritter |
||||
*/ |
||||
class JdkClientHttpSender implements HttpSender { |
||||
|
||||
private final HttpClient httpClient; |
||||
|
||||
private final Duration timeout; |
||||
|
||||
/** |
||||
* Creates a new {@link JdkClientHttpSender}. |
||||
* @param connectTimeout the connect timeout |
||||
* @param timeout the request timeout |
||||
* @param sslBundle the SSL bundle to use for TLS configuration, or {@code null} |
||||
*/ |
||||
JdkClientHttpSender(Duration connectTimeout, Duration timeout, @Nullable SslBundle sslBundle) { |
||||
this.httpClient = buildHttpClient(connectTimeout, sslBundle); |
||||
this.timeout = timeout; |
||||
} |
||||
|
||||
private static HttpClient buildHttpClient(Duration connectTimeout, @Nullable SslBundle sslBundle) { |
||||
HttpClient.Builder builder = HttpClient.newBuilder().connectTimeout(connectTimeout); |
||||
if (sslBundle != null) { |
||||
builder.sslContext(sslBundle.createSslContext()); |
||||
builder.sslParameters(asSslParameters(sslBundle)); |
||||
} |
||||
return builder.build(); |
||||
} |
||||
|
||||
private static SSLParameters asSslParameters(SslBundle sslBundle) { |
||||
SslOptions options = sslBundle.getOptions(); |
||||
SSLParameters parameters = new SSLParameters(); |
||||
parameters.setCipherSuites(options.getCiphers()); |
||||
parameters.setProtocols(options.getEnabledProtocols()); |
||||
return parameters; |
||||
} |
||||
|
||||
@Override |
||||
public Response send(Request request) throws IOException { |
||||
HttpRequest.Builder httpRequest = HttpRequest.newBuilder() |
||||
.uri(URI.create(request.getUrl().toString())) |
||||
.timeout(this.timeout); |
||||
request.getRequestHeaders().forEach(httpRequest::header); |
||||
httpRequest.method(request.getMethod().name(), BodyPublishers.ofByteArray(request.getEntity())); |
||||
try { |
||||
HttpResponse<String> response = this.httpClient.send(httpRequest.build(), BodyHandlers.ofString()); |
||||
return new Response(response.statusCode(), response.body()); |
||||
} |
||||
catch (InterruptedException ex) { |
||||
Thread.currentThread().interrupt(); |
||||
throw new IOException("HTTP request interrupted", ex); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.micrometer.metrics.autoconfigure.export.otlp; |
||||
|
||||
import java.io.IOException; |
||||
import java.time.Duration; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import io.micrometer.core.ipc.http.HttpSender.Response; |
||||
import okhttp3.mockwebserver.MockResponse; |
||||
import okhttp3.mockwebserver.MockWebServer; |
||||
import okhttp3.mockwebserver.RecordedRequest; |
||||
import org.junit.jupiter.api.AfterEach; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.assertj.core.api.Assertions.assertThatIOException; |
||||
|
||||
/** |
||||
* Tests for {@link JdkClientHttpSender}. |
||||
* |
||||
* @author Moritz Halbritter |
||||
*/ |
||||
class JdkClientHttpSenderTests { |
||||
|
||||
private MockWebServer mockWebServer; |
||||
|
||||
private JdkClientHttpSender sender; |
||||
|
||||
@BeforeEach |
||||
void setUp() throws IOException { |
||||
this.mockWebServer = new MockWebServer(); |
||||
this.mockWebServer.start(); |
||||
this.sender = new JdkClientHttpSender(Duration.ofSeconds(5), Duration.ofSeconds(5), null); |
||||
} |
||||
|
||||
@AfterEach |
||||
void tearDown() throws IOException { |
||||
this.mockWebServer.shutdown(); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldSendGetRequest() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setBody("response-body").setResponseCode(200)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
Response response = this.sender.get(url).send(); |
||||
assertThat(response.code()).isEqualTo(200); |
||||
assertThat(response.body()).isEqualTo("response-body"); |
||||
RecordedRequest request = this.mockWebServer.takeRequest(); |
||||
assertThat(request.getMethod()).isEqualTo("GET"); |
||||
assertThat(request.getPath()).isEqualTo("/test"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldSendPostRequest() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(200)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
Response response = this.sender.post(url).withJsonContent("{\"key\":\"value\"}").send(); |
||||
assertThat(response.code()).isEqualTo(200); |
||||
RecordedRequest request = this.mockWebServer.takeRequest(); |
||||
assertThat(request.getMethod()).isEqualTo("POST"); |
||||
assertThat(request.getHeader("Content-Type")).isEqualTo("application/json"); |
||||
assertThat(request.getBody().readUtf8()).isEqualTo("{\"key\":\"value\"}"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldIncludeHeaders() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(200)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
this.sender.post(url).withHeader("X-Custom", "custom-value").send(); |
||||
RecordedRequest request = this.mockWebServer.takeRequest(); |
||||
assertThat(request.getHeader("X-Custom")).isEqualTo("custom-value"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldHandleServerError() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(500).setBody("error")); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
Response response = this.sender.get(url).send(); |
||||
assertThat(response.code()).isEqualTo(500); |
||||
assertThat(response.body()).isEqualTo("error"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldTimeoutOnSlowResponse() { |
||||
JdkClientHttpSender sender = new JdkClientHttpSender(Duration.ofSeconds(5), Duration.ofMillis(10), null); |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(200).setHeadersDelay(500, TimeUnit.MILLISECONDS)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
assertThatIOException().isThrownBy(() -> sender.get(url).send()).withMessageContaining("timed out"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldSendPutRequest() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(200)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
this.sender.put(url).withPlainText("data").send(); |
||||
RecordedRequest request = this.mockWebServer.takeRequest(); |
||||
assertThat(request.getMethod()).isEqualTo("PUT"); |
||||
assertThat(request.getBody().readUtf8()).isEqualTo("data"); |
||||
} |
||||
|
||||
@Test |
||||
void sendShouldSendDeleteRequest() throws Throwable { |
||||
this.mockWebServer.enqueue(new MockResponse().setResponseCode(204)); |
||||
String url = this.mockWebServer.url("/test").toString(); |
||||
Response response = this.sender.delete(url).send(); |
||||
assertThat(response.code()).isEqualTo(204); |
||||
RecordedRequest request = this.mockWebServer.takeRequest(); |
||||
assertThat(request.getMethod()).isEqualTo("DELETE"); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue