mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-08 00:22:11 +01:00
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:
@@ -80,6 +80,7 @@ task javaIntegrationTests(type: Test) {
|
||||
ignoreFailures = project.isCI
|
||||
outputs.upToDateWhen { !project.hasProperty('rerunIntegrationTests') }
|
||||
finalizedBy = ['stopScmServer']
|
||||
useJUnitPlatform()
|
||||
|
||||
dependsOn 'test', 'startScmServer'
|
||||
mustRunAfter 'startScmServer'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user