Browse Source

Merge pull request #45792 from shekharAggarwal

* pr/45792:
  Add SSL response structure to actuator info endpoint documentation

Closes gh-45792
pull/45853/head
Moritz Halbritter 7 months ago
parent
commit
77454a6703
  1. 10
      spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/antora/modules/api/pages/rest/actuator/info.adoc
  2. 64
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointDocumentationTests.java
  3. BIN
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/test.p12

10
spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/antora/modules/api/pages/rest/actuator/info.adoc

@ -76,3 +76,13 @@ The following table describes the structure of the `java` section of the respons @@ -76,3 +76,13 @@ The following table describes the structure of the `java` section of the respons
[cols="2,1,3"]
include::partial$rest/actuator/info/response-fields-beneath-java.adoc[]
[[info.retrieving.response-structure.ssl]]
==== SSL Response Structure
The following table describes the structure of the `ssl` section of the response:
[cols="2,1,3"]
include::partial$rest/actuator/info/response-fields-beneath-ssl.adoc[]

64
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointDocumentationTests.java

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.info;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Properties;
@ -30,8 +31,15 @@ import org.springframework.boot.actuate.info.InfoEndpoint; @@ -30,8 +31,15 @@ import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.boot.actuate.info.JavaInfoContributor;
import org.springframework.boot.actuate.info.OsInfoContributor;
import org.springframework.boot.actuate.info.ProcessInfoContributor;
import org.springframework.boot.actuate.info.SslInfoContributor;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties;
import org.springframework.boot.info.SslInfo;
import org.springframework.boot.ssl.DefaultSslBundleRegistry;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
@ -55,7 +63,7 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -55,7 +63,7 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
void info() {
assertThat(this.mvc.get().uri("/actuator/info")).hasStatusOk()
.apply(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo(),
javaInfo()));
javaInfo(), sslInfo()));
}
private ResponseFieldsSnippet gitInfo() {
@ -142,6 +150,45 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -142,6 +150,45 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
.optional());
}
private ResponseFieldsSnippet sslInfo() {
return responseFields(beneathPath("ssl"),
fieldWithPath("bundles").description("SSL bundles information.").type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].name").description("Name of the SSL bundle.").type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains").description("Certificate chains in the bundle.")
.type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].certificateChains[].alias").description("Alias of the certificate chain.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates").description("Certificates in the chain.")
.type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].certificateChains[].certificates[].subject")
.description("Subject of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].version")
.description("Version of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].issuer")
.description("Issuer of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validityStarts")
.description("Certificate validity start date.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].serialNumber")
.description("Serial number of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validityEnds")
.description("Certificate validity end date.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validity")
.description("Certificate validity information.")
.type(JsonFieldType.OBJECT),
fieldWithPath("bundles[].certificateChains[].certificates[].validity.status")
.description("Certificate validity status.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].signatureAlgorithmName")
.description("Signature algorithm name.")
.type(JsonFieldType.STRING));
}
@Configuration(proxyBeanMethods = false)
static class TestConfiguration {
@ -186,6 +233,21 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -186,6 +233,21 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
return new JavaInfoContributor();
}
@Bean
SslInfo sslInfo() {
DefaultSslBundleRegistry sslBundleRegistry = new DefaultSslBundleRegistry();
JksSslStoreDetails keyStoreDetails = JksSslStoreDetails.forLocation("classpath:test.p12")
.withPassword("secret");
SslStoreBundle sslStoreBundle = new JksSslStoreBundle(keyStoreDetails, null);
sslBundleRegistry.registerBundle("test-0", SslBundle.of(sslStoreBundle));
return new SslInfo(sslBundleRegistry, Duration.ofDays(7));
}
@Bean
SslInfoContributor sslInfoContributor(SslInfo sslInfo) {
return new SslInfoContributor(sslInfo);
}
}
}

BIN
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/test.p12

Binary file not shown.
Loading…
Cancel
Save