Annotation Type SelfSignedCert


@Inherited @Documented @Target(TYPE) @Retention(RUNTIME) @ExtendWith(dev.resteasy.junit.extension.extensions.SelfSignedCertificateExtension.class) @Tag("ssl-test") public @interface SelfSignedCert
Enables generation of self-signed certificates for SSL/TLS testing.

When placed on a test class, this annotation triggers the generation of self-signed certificates for both server and client. The generated SelfSignedCertificate can be injected into test fields annotated with @SslCert or into test method parameters by type.

Standalone Usage

This annotation can be used independently of @RestBootstrap when only the certificate artifacts are needed (e.g., for configuring a non-Jakarta REST client or an external server):

@SelfSignedCert
public class ClientTest {
    @SslCert
    private SelfSignedCertificate certificate;

    @Test
    public void testClient() {
        SSLContext clientCtx = certificate.clientSslContext();
        // configure a custom client with the SSL context
    }
}

Usage with @RestBootstrap

When combined with @RestBootstrap, the server is automatically started with HTTPS using the generated server SSL context, and injected Client instances are configured with the client SSL context:

@SelfSignedCert
@RestBootstrap(MyResource.class)
public class SslTest {
    @RestResource
    private Client client; // auto-configured with client SSL context

    @Test
    public void testHttps(URI baseUri) {
        assertEquals("https", baseUri.getScheme());
    }
}

Tests annotated with this annotation are automatically tagged with ssl-test, allowing them to be included or excluded using JUnit tag filtering.

Since:
1.0
Author:
James R. Perkins
See Also: