Annotation Type SslCert


@Documented @Target(FIELD) @Retention(RUNTIME) public @interface SslCert
Marks a field for injection of a SelfSignedCertificate.

The test class must also be annotated with @SelfSignedCert to trigger certificate generation.

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

    @Test
    public void testSsl() {
        SSLContext ctx = certificate.clientSslContext();
        // ...
    }
}

This annotation can also be used on fields in ConfigurationProvider and RestClientBuilderProvider implementations to receive the generated certificate for custom SSL configuration:

public class CustomSslConfigProvider implements ConfigurationProvider {
    @SslCert
    private SelfSignedCertificate certificate;

    @Override
    public Configuration getConfiguration(ExtensionContext context) {
        return Configuration.builder()
                .protocol("HTTPS")
                .sslContext(certificate.serverSslContext())
                .build();
    }
}

For test method parameters, injection is resolved by type without requiring this annotation.

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