This commit is contained in:
Mohamed Karray
2018-09-05 10:44:03 +02:00
parent 3516bf9913
commit a03a6fc8ac
2 changed files with 13 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package sonia.scm.it;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.io.Files; import com.google.common.io.Files;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.Changeset; import sonia.scm.repository.Changeset;
import sonia.scm.repository.Person; import sonia.scm.repository.Person;
import sonia.scm.repository.client.api.ClientCommand; import sonia.scm.repository.client.api.ClientCommand;
@@ -15,6 +17,8 @@ import java.util.UUID;
public class RepositoryUtil { public class RepositoryUtil {
private static final Logger LOG = LoggerFactory.getLogger(RepositoryUtil.class);
private static final RepositoryClientFactory REPOSITORY_CLIENT_FACTORY = new RepositoryClientFactory(); private static final RepositoryClientFactory REPOSITORY_CLIENT_FACTORY = new RepositoryClientFactory();
static RepositoryClient createRepositoryClient(String repositoryType, File folder) throws IOException { static RepositoryClient createRepositoryClient(String repositoryType, File folder) throws IOException {
@@ -58,6 +62,7 @@ public class RepositoryUtil {
} }
static Changeset commit(RepositoryClient repositoryClient, String username, String message) throws IOException { static Changeset commit(RepositoryClient repositoryClient, String username, String message) throws IOException {
LOG.info("user: {} try to commit with message: {}", username, message);
Changeset changeset = repositoryClient.getCommitCommand().commit(new Person(username, username + "@scm-manager.org"), message); Changeset changeset = repositoryClient.getCommitCommand().commit(new Person(username, username + "@scm-manager.org"), message);
if (repositoryClient.isCommandSupported(ClientCommand.PUSH)) { if (repositoryClient.isCommandSupported(ClientCommand.PUSH)) {
repositoryClient.getPushCommand().push(); repositoryClient.getPushCommand().push();

View File

@@ -33,6 +33,7 @@ public class TestData {
} }
public static void cleanup() { public static void cleanup() {
LOG.info("start to clean up to integration tests");
cleanupRepositories(); cleanupRepositories();
cleanupGroups(); cleanupGroups();
cleanupUsers(); cleanupUsers();
@@ -43,6 +44,7 @@ public class TestData {
} }
public static void createUser(String username, String password) { public static void createUser(String username, String password) {
LOG.info("create user with username: {}", username);
given(VndMediaType.USER) given(VndMediaType.USER)
.when() .when()
.content(" {\n" + .content(" {\n" +
@@ -64,6 +66,8 @@ public class TestData {
public static void createUserPermission(String name, PermissionType permissionType, String repositoryType) { public static void createUserPermission(String name, PermissionType permissionType, String repositoryType) {
String defaultPermissionUrl = TestData.getDefaultPermissionUrl(USER_SCM_ADMIN, USER_SCM_ADMIN, repositoryType);
LOG.info("create permission with name {} and type: {} using the endpoint: {}", name, permissionType, defaultPermissionUrl);
given(VndMediaType.PERMISSION) given(VndMediaType.PERMISSION)
.when() .when()
.content("{\n" + .content("{\n" +
@@ -72,7 +76,7 @@ public class TestData {
"\t\"groupPermission\": false\n" + "\t\"groupPermission\": false\n" +
"\t\n" + "\t\n" +
"}") "}")
.post(TestData.getDefaultPermissionUrl(USER_SCM_ADMIN, USER_SCM_ADMIN, repositoryType)) .post(defaultPermissionUrl)
.then() .then()
.statusCode(HttpStatus.SC_CREATED) .statusCode(HttpStatus.SC_CREATED)
; ;
@@ -114,6 +118,7 @@ public class TestData {
private static void cleanupRepositories() { private static void cleanupRepositories() {
LOG.info("clean up repository");
List<String> repositories = given(VndMediaType.REPOSITORY_COLLECTION) List<String> repositories = given(VndMediaType.REPOSITORY_COLLECTION)
.when() .when()
.get(createResourceUrl("repositories")) .get(createResourceUrl("repositories"))
@@ -160,6 +165,7 @@ public class TestData {
} }
private static void createDefaultRepositories() { private static void createDefaultRepositories() {
LOG.info("create default repositories");
for (String repositoryType : availableScmTypes()) { for (String repositoryType : availableScmTypes()) {
String url = given(VndMediaType.REPOSITORY) String url = given(VndMediaType.REPOSITORY)
.body(repositoryJson(repositoryType)) .body(repositoryJson(repositoryType))
@@ -171,6 +177,7 @@ public class TestData {
.statusCode(HttpStatus.SC_CREATED) .statusCode(HttpStatus.SC_CREATED)
.extract() .extract()
.header("location"); .header("location");
LOG.info("a {} repository is created: {}", repositoryType, url);
DEFAULT_REPOSITORIES.put(repositoryType, url); DEFAULT_REPOSITORIES.put(repositoryType, url);
} }
} }