TSK-1444: enable disabled tests
This commit is contained in:
parent
19746c5c08
commit
e44b699607
|
|
@ -14,7 +14,6 @@ import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.DynamicContainer;
|
import org.junit.jupiter.api.DynamicContainer;
|
||||||
import org.junit.jupiter.api.DynamicTest;
|
import org.junit.jupiter.api.DynamicTest;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
|
|
@ -25,11 +24,13 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import pro.taskana.common.api.security.CurrentUserContext;
|
import pro.taskana.common.api.security.CurrentUserContext;
|
||||||
import pro.taskana.common.internal.security.CurrentUserContextImpl;
|
import pro.taskana.common.internal.security.CurrentUserContextImpl;
|
||||||
|
import pro.taskana.common.test.security.JaasExtensionTestExtensions.ShouldThrowJunitException;
|
||||||
|
import pro.taskana.common.test.security.JaasExtensionTestExtensions.ShouldThrowParameterResolutionException;
|
||||||
|
|
||||||
@ExtendWith(JaasExtension.class)
|
@ExtendWith(JaasExtension.class)
|
||||||
class JaasExtensionTest {
|
class JaasExtensionTest {
|
||||||
|
|
||||||
private static final String INSIDE_DYNAMIC_TEST_USER = "insidedynamictest";
|
private static final String INSIDE_DYNAMIC_TEST_USER = "inside_dynamic_test";
|
||||||
private static final CurrentUserContext CURRENT_USER_CONTEXT = new CurrentUserContextImpl(true);
|
private static final CurrentUserContext CURRENT_USER_CONTEXT = new CurrentUserContextImpl(true);
|
||||||
private static final DynamicTest NOT_NULL_DYNAMIC_TEST =
|
private static final DynamicTest NOT_NULL_DYNAMIC_TEST =
|
||||||
dynamicTest("dynamic test", () -> assertThat(CURRENT_USER_CONTEXT.getUserid()).isNotNull());
|
dynamicTest("dynamic test", () -> assertThat(CURRENT_USER_CONTEXT.getUserid()).isNotNull());
|
||||||
|
|
@ -153,17 +154,20 @@ class JaasExtensionTest {
|
||||||
|
|
||||||
@WithAccessId(user = "user")
|
@WithAccessId(user = "user")
|
||||||
@Test
|
@Test
|
||||||
@Disabled("this can be tested with a org.junit.platform.launcher.TestExecutionListener")
|
@ExtendWith(ShouldThrowParameterResolutionException.class)
|
||||||
void should_NotInjectParameter_When_ParameterIsPresent_On_Test(WithAccessId accessId) {
|
void should_NotInjectParameter_When_TestTemplateIsNotUsed(
|
||||||
assertThat(CURRENT_USER_CONTEXT.getUserid()).isEqualTo("user");
|
@SuppressWarnings("unused") WithAccessId accessId) {
|
||||||
|
// THIS IS NOT RELEVANT
|
||||||
|
assertThat(true).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@WithAccessId(user = "user")
|
@WithAccessId(user = "user")
|
||||||
@WithAccessId(user = "user2")
|
@WithAccessId(user = "user2")
|
||||||
@Test
|
@Test
|
||||||
@Disabled("this can be tested with a org.junit.platform.launcher.TestExecutionListener")
|
@ExtendWith(ShouldThrowJunitException.class)
|
||||||
void should_ThrowException_When_MultipleAnnotationsExist_On_Test() {
|
void should_ThrowJunitException_When_MultipleAnnotationsExist_On_Test() {
|
||||||
assertThat(CURRENT_USER_CONTEXT.getUserid()).isNull();
|
// THIS IS NOT RELEVANT
|
||||||
|
assertThat(true).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
@ -196,12 +200,6 @@ class JaasExtensionTest {
|
||||||
|
|
||||||
// region JaasExtension#interceptTestTemplateMethod
|
// region JaasExtension#interceptTestTemplateMethod
|
||||||
|
|
||||||
@TestTemplate
|
|
||||||
@Disabled("this can be tested with a org.junit.platform.launcher.TestExecutionListener")
|
|
||||||
void should_NotFindContextProvider_When_AnnotationIsMissing_On_TestTemplate() {
|
|
||||||
assertThat(CURRENT_USER_CONTEXT.getUserid()).isNotNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@WithAccessId(user = "testtemplate")
|
@WithAccessId(user = "testtemplate")
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
void should_SetJaasSubject_When_AnnotationExists_On_TestTemplate() {
|
void should_SetJaasSubject_When_AnnotationExists_On_TestTemplate() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package pro.taskana.common.test.security;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||||
|
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||||
|
import org.junit.platform.commons.JUnitException;
|
||||||
|
|
||||||
|
public class JaasExtensionTestExtensions {
|
||||||
|
static class ShouldThrowParameterResolutionException implements TestExecutionExceptionHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTestExecutionException(ExtensionContext context, Throwable throwable)
|
||||||
|
throws Throwable {
|
||||||
|
if (throwable instanceof ParameterResolutionException) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ShouldThrowJunitException implements TestExecutionExceptionHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTestExecutionException(ExtensionContext context, Throwable throwable)
|
||||||
|
throws Throwable {
|
||||||
|
if (throwable instanceof JUnitException) {
|
||||||
|
JUnitException exception = (JUnitException) throwable;
|
||||||
|
assertThat(exception.getMessage())
|
||||||
|
.isEqualTo("Please use @TestTemplate instead of @Test for multiple accessIds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue