Run JUnit 5 integration tests again (#1571)

With the migration to gradle we lost the JUnit 5 integration tests. This is fixed here. In addition we have to adapt the AnonymousAccessITCase to the change, that the anonymous access is disabled when creating the default test data.
This commit is contained in:
René Pfeuffer
2021-03-05 15:08:20 +01:00
committed by GitHub
parent 861e1d34ca
commit 512bf20659
3 changed files with 22 additions and 13 deletions

View File

@@ -80,6 +80,7 @@ task javaIntegrationTests(type: Test) {
ignoreFailures = project.isCI
outputs.upToDateWhen { !project.hasProperty('rerunIntegrationTests') }
finalizedBy = ['stopScmServer']
useJUnitPlatform()
dependsOn 'test', 'startScmServer'
mustRunAfter 'startScmServer'

View File

@@ -26,7 +26,6 @@ package sonia.scm.it;
import io.restassured.RestAssured;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -61,6 +60,11 @@ import static sonia.scm.it.utils.TestData.getDefaultRepositoryUrl;
class AnonymousAccessITCase {
@BeforeEach
void createRepositoryAndSetAnonymous() {
TestData.createDefault();
}
@Test
void shouldAccessIndexResourceWithoutAuthentication() {
ScmRequests.start()
@@ -79,14 +83,10 @@ class AnonymousAccessITCase {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class WithProtocolOnlyAnonymousAccess {
@BeforeAll
void enableAnonymousAccess() {
setAnonymousAccess(AnonymousMode.PROTOCOL_ONLY);
}
@BeforeEach
void createRepository() {
TestData.createDefault();
void createRepositoryAndSetAnonymous() {
setAnonymousAccess(AnonymousMode.PROTOCOL_ONLY);
}
@Test
@@ -150,14 +150,10 @@ class AnonymousAccessITCase {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class WithFullAnonymousAccess {
@BeforeAll
void enableAnonymousAccess() {
setAnonymousAccess(AnonymousMode.FULL);
}
@BeforeEach
void createRepository() {
TestData.createDefault();
void createRepositoryAndSetAnonymous() {
setAnonymousAccess(AnonymousMode.FULL);
}
@Test

View File

@@ -230,6 +230,18 @@ public class TestData {
.body().jsonPath().getList("_embedded.users._links.self.href");
LOG.info("about to delete {} users", users.size());
users.stream().filter(url -> PROTECTED_USERS.stream().noneMatch(url::contains)).forEach(TestData::delete);
clearAnonymousUserPermissions();
}
private static void clearAnonymousUserPermissions() {
given(VndMediaType.PERMISSION_COLLECTION).accept("application/json")
.when()
.body("{\"permissions\":[]}")
.put(createResourceUrl("users/_anonymous/permissions"))
.then()
.statusCode(HttpStatus.SC_NO_CONTENT);
LOG.info("deleted permissions for user _anonymous");
}
private static void cleanupConfig() {