Added documentation test changes as well
Signed-off-by: Shruthi Manavalli Ramanna <shruthimanavalli.ramanna@bosch-si.com>
This commit is contained in:
@@ -169,7 +169,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
systemManagement.getTenantMetadata().getId(), null, null,
|
||||
new URLPlaceholder.SoftwareData(artifact.getSoftwareModule().getId(), artifact.getFilename(),
|
||||
artifact.getId(), artifact.getSha1Hash())), ApiType.MGMT, null);
|
||||
response.add(Link.of(urls.get(0).getRef()).withRel("cdn-download").expand());
|
||||
response.add(Link.of(urls.get(0).getRef()).withRel("download").expand());
|
||||
}
|
||||
|
||||
static List<MgmtArtifact> artifactsToResponse(final Collection<Artifact> artifacts) {
|
||||
|
||||
@@ -616,7 +616,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.hashes.sha1", equalTo(artifact.getSha1Hash())))
|
||||
.andExpect(jsonPath("$.hashes.sha256", equalTo(artifact.getSha256Hash())))
|
||||
.andExpect(jsonPath("$.providedFilename", equalTo("file1")))
|
||||
.andExpect(jsonPath("$._links.cdn-download.href",
|
||||
.andExpect(jsonPath("$._links.download.href",
|
||||
equalTo("http://localhost:8080/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/"
|
||||
+ artifact.getFilename())))
|
||||
.andExpect(jsonPath("$._links.self.href", equalTo(
|
||||
|
||||
@@ -417,6 +417,10 @@ include::{snippets}/softwaremodules/get-artifact/http-request.adoc[]
|
||||
|
||||
include::{snippets}/softwaremodules/get-artifact/path-parameters.adoc[]
|
||||
|
||||
==== Request query parameter
|
||||
|
||||
include::{snippets}/softwaremodules/get-artifact-with-parameters/request-parameters.adoc[]
|
||||
|
||||
=== Response (Status 200)
|
||||
|
||||
==== Response fields
|
||||
|
||||
@@ -55,10 +55,9 @@ public final class MgmtApiModelProperties {
|
||||
public static final String ARTIFACT_HASHES_SHA1 = "SHA1 hash of the artifact.";
|
||||
public static final String ARTIFACT_HASHES_MD5 = "MD5 hash of the artifact.";
|
||||
public static final String ARTIFACT_HASHES_SHA256 = "SHA256 hash of the artifact.";
|
||||
|
||||
public static final String ARTIFACT_DOWNLOAD_LINK = "Download link of the artifact.";
|
||||
|
||||
public static final String ARTIFACT_DOWNLOAD_LINK = "Download link of the artifact based on the chosen download url type parameter.";
|
||||
public static final String ARTIFACT_LIST = "List of artifacts of given software module.";
|
||||
public static final String ARTIFACT_DOWNLOAD_URL_TYPE = "Type of the artifact download url. (can be default or cdn)";
|
||||
|
||||
// Distribution Set
|
||||
public static final String DS_OS = "Operating system or firmware software module - DEPRECATED (use modules).";
|
||||
|
||||
@@ -368,7 +368,7 @@ public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentati
|
||||
|
||||
mockMvc.perform(
|
||||
get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}",
|
||||
sm.getId(), artifact.getId()))
|
||||
sm.getId(), artifact.getId()).param("downloadurltype", "default"))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
@@ -391,6 +391,27 @@ public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentati
|
||||
.description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_LINK))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving a single Artifact meta data request. Required Permission: "
|
||||
+ SpPermission.READ_REPOSITORY)
|
||||
public void getArtifactWithParameters() throws Exception {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5).getBytes();
|
||||
|
||||
final Artifact artifact = artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0));
|
||||
|
||||
mockMvc.perform(
|
||||
get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}",
|
||||
sm.getId(), artifact.getId()).param("downloadurltype", "default"))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
.andDo(this.document.document(
|
||||
requestParameters(
|
||||
parameterWithName("downloadurltype").description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_URL_TYPE))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handles the GET request for downloading an artifact. Required Permission: "
|
||||
+ SpPermission.READ_REPOSITORY)
|
||||
|
||||
Reference in New Issue
Block a user