mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
merge
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package sonia.scm.it;
|
||||
|
||||
import io.restassured.response.ExtractableResponse;
|
||||
import io.restassured.response.Response;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
@@ -11,6 +13,7 @@ import org.junit.runners.Parameterized;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.client.api.ClientCommand;
|
||||
import sonia.scm.repository.client.api.RepositoryClient;
|
||||
import sonia.scm.web.VndMediaType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -84,6 +87,85 @@ public class RepositoryAccessITCase {
|
||||
assertNotNull(branchName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindTags() throws IOException {
|
||||
RepositoryClient repositoryClient = RepositoryUtil.createRepositoryClient(repositoryType, folder);
|
||||
|
||||
Assume.assumeTrue("There are no tags for " + repositoryType, repositoryClient.isCommandSupported(ClientCommand.TAG));
|
||||
|
||||
Changeset changeset = RepositoryUtil.createAndCommitFile(repositoryClient, ADMIN_USERNAME, "a.txt", "a");
|
||||
|
||||
String tagName = "v1.0";
|
||||
String repositoryUrl = TestData.getDefaultRepositoryUrl(repositoryType);
|
||||
String tagsUrl = given()
|
||||
.when()
|
||||
.get(repositoryUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("_links.tags.href");
|
||||
|
||||
ExtractableResponse<Response> response = given(VndMediaType.TAG_COLLECTION, ADMIN_USERNAME, ADMIN_PASSWORD)
|
||||
.when()
|
||||
.get(tagsUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract();
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.body()).isNotNull();
|
||||
assertThat(response.body().asString())
|
||||
.isNotNull()
|
||||
.isNotBlank();
|
||||
|
||||
RepositoryUtil.addTag(repositoryClient, changeset.getId(), tagName);
|
||||
response = given(VndMediaType.TAG_COLLECTION, ADMIN_USERNAME, ADMIN_PASSWORD)
|
||||
.when()
|
||||
.get(tagsUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract();
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.body()).isNotNull();
|
||||
assertThat(response.body().asString())
|
||||
.isNotNull()
|
||||
.isNotBlank();
|
||||
|
||||
assertThat(response.body().jsonPath().getString("_links.self.href"))
|
||||
.as("assert tags self link")
|
||||
.isNotNull()
|
||||
.contains(repositoryUrl + "/tags/");
|
||||
|
||||
assertThat(response.body().jsonPath().getList("_embedded.tags"))
|
||||
.as("assert tag size")
|
||||
.isNotNull()
|
||||
.size()
|
||||
.isGreaterThan(0);
|
||||
|
||||
assertThat(response.body().jsonPath().getMap("_embedded.tags.find{it.name=='" + tagName + "'}"))
|
||||
.as("assert tag name and revision")
|
||||
.isNotNull()
|
||||
.hasSize(3)
|
||||
.containsEntry("name", tagName)
|
||||
.containsEntry("revision", changeset.getId());
|
||||
|
||||
assertThat(response.body().jsonPath().getString("_embedded.tags.find{it.name=='" + tagName + "'}._links.self.href"))
|
||||
.as("assert single tag self link")
|
||||
.isNotNull()
|
||||
.contains(String.format("%s/tags/%s", repositoryUrl, tagName));
|
||||
|
||||
assertThat(response.body().jsonPath().getString("_embedded.tags.find{it.name=='" + tagName + "'}._links.sources.href"))
|
||||
.as("assert single tag source link")
|
||||
.isNotNull()
|
||||
.contains(String.format("%s/sources/%s", repositoryUrl, changeset.getId()));
|
||||
|
||||
assertThat(response.body().jsonPath().getString("_embedded.tags.find{it.name=='" + tagName + "'}._links.changesets.href"))
|
||||
.as("assert single tag changesets link")
|
||||
.isNotNull()
|
||||
.contains(String.format("%s/changesets/%s", repositoryUrl, changeset.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadContent() throws IOException, InterruptedException {
|
||||
RepositoryClient repositoryClient = RepositoryUtil.createRepositoryClient(repositoryType, folder);
|
||||
@@ -107,7 +189,8 @@ public class RepositoryAccessITCase {
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("files.find{it.name=='a.txt'}._links.self.href");
|
||||
.path("_embedded.files.find{it.name=='a.txt'}._links.self.href");
|
||||
|
||||
given()
|
||||
.when()
|
||||
.get(rootContentUrl)
|
||||
@@ -121,14 +204,22 @@ public class RepositoryAccessITCase {
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("files.find{it.name=='subfolder'}._links.self.href");
|
||||
String subfolderContentUrl= given()
|
||||
.path("_embedded.files.find{it.name=='subfolder'}._links.self.href");
|
||||
String selfOfSubfolderUrl = given()
|
||||
.when()
|
||||
.get(subfolderSourceUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("files[0]._links.self.href");
|
||||
.path("_links.self.href");
|
||||
assertThat(subfolderSourceUrl).isEqualTo(selfOfSubfolderUrl);
|
||||
String subfolderContentUrl = given()
|
||||
.when()
|
||||
.get(subfolderSourceUrl)
|
||||
.then()
|
||||
.statusCode(HttpStatus.SC_OK)
|
||||
.extract()
|
||||
.path("_embedded.files[0]._links.self.href");
|
||||
given()
|
||||
.when()
|
||||
.get(subfolderContentUrl)
|
||||
@@ -167,21 +258,22 @@ public class RepositoryAccessITCase {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void shouldFindFileHistory() throws IOException {
|
||||
RepositoryClient repositoryClient = RepositoryUtil.createRepositoryClient(repositoryType, folder);
|
||||
|
||||
String fileName_1 = "a.txt";
|
||||
Changeset changeset_1 = RepositoryUtil.createAndCommitFile(repositoryClient, ADMIN_USERNAME, fileName_1, "a");
|
||||
|
||||
Changeset changeset = RepositoryUtil.createAndCommitFile(repositoryClient, ADMIN_USERNAME, "folder/subfolder/a.txt", "a");
|
||||
repositoryGetRequest
|
||||
.usingRepositoryResponse()
|
||||
.requestSources()
|
||||
.usingSourcesResponse()
|
||||
.requestFileHistory(fileName_1)
|
||||
.requestSelf("folder")
|
||||
.usingSourcesResponse()
|
||||
.requestSelf("subfolder")
|
||||
.usingSourcesResponse()
|
||||
.requestFileHistory("a.txt")
|
||||
.assertStatusCode(HttpStatus.SC_OK)
|
||||
.usingChangesetsResponse()
|
||||
.assertChangesets(changesets -> {
|
||||
assertThat(changesets).hasSize(1);
|
||||
assertThat(changesets.get(0)).containsEntry("id", changeset_1.getId());
|
||||
assertThat(changesets.get(0)).containsEntry("description", changeset_1.getDescription());
|
||||
assertThat(changesets.get(0)).containsEntry("id", changeset.getId());
|
||||
assertThat(changesets.get(0)).containsEntry("description", changeset.getDescription());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user