mirror of https://github.com/shred/acme4j
Make some IT soft-fail
parent
b62709470e
commit
033f9701c0
|
@ -20,7 +20,6 @@ import java.net.MalformedURLException;
|
|||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.shredzone.acme4j.Session;
|
||||
import org.shredzone.acme4j.connector.Resource;
|
||||
|
@ -140,7 +139,7 @@ public class ProviderIT {
|
|||
* Test ssl.com, staging server
|
||||
*/
|
||||
@Test
|
||||
@Disabled("Instable due to frequent certificate expiration of acme-try.ssl.com")
|
||||
@SoftFail("Frequent certificate expiration of acme-try.ssl.com")
|
||||
public void testSslComStaging() throws AcmeException, MalformedURLException {
|
||||
var sessionEccStage = new Session("acme://ssl.com/staging/ecc");
|
||||
assertThat(sessionEccStage.getMetadata().getWebsite()).hasValue(URI.create("https://www.ssl.com").toURL());
|
||||
|
@ -166,6 +165,7 @@ public class ProviderIT {
|
|||
* Test ZeroSSL
|
||||
*/
|
||||
@Test
|
||||
@SoftFail("Frequent network timeouts or HTTP errors")
|
||||
public void testZeroSsl() throws AcmeException, MalformedURLException {
|
||||
var session = new Session("acme://zerossl.com");
|
||||
session.networkSettings().setTimeout(Duration.ofSeconds(120L));
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* acme4j - Java ACME client
|
||||
*
|
||||
* Copyright (C) 2025 Richard "Shred" Körber
|
||||
* http://acme4j.shredzone.org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
package org.shredzone.acme4j.it;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.shredzone.acme4j.exception.AcmeException;
|
||||
|
||||
/**
|
||||
* Marks a test to fail softly if an {@link AcmeException} is thrown. These are usually
|
||||
* integration tests that fail frequently because the external server has stability
|
||||
* issues.
|
||||
*/
|
||||
@Retention(RUNTIME)
|
||||
@Target(METHOD)
|
||||
@ExtendWith(SoftFailExtension.class)
|
||||
public @interface SoftFail {
|
||||
/**
|
||||
* A human-readable reason why this test is marked as soft fail.
|
||||
*/
|
||||
String value();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* acme4j - Java ACME client
|
||||
*
|
||||
* Copyright (C) 2025 Richard "Shred" Körber
|
||||
* http://acme4j.shredzone.org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
package org.shredzone.acme4j.it;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||
import org.opentest4j.TestAbortedException;
|
||||
import org.shredzone.acme4j.exception.AcmeException;
|
||||
|
||||
/**
|
||||
* Aborts a @{@link SoftFail} annotated test when an {@link AcmeException} is thrown.
|
||||
*/
|
||||
public class SoftFailExtension implements TestExecutionExceptionHandler {
|
||||
@Override
|
||||
public void handleTestExecutionException(ExtensionContext ctx, Throwable ex)
|
||||
throws Throwable {
|
||||
if (ex instanceof AcmeException) {
|
||||
throw new TestAbortedException("SOFT FAIL: " + ctx.getDisplayName()
|
||||
+ " - " + ex.getMessage(), ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue