use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsWithMd5AndSha1.
@Test
public void testGetAllArtifactsWithMd5AndSha1() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Artifact> artifacts = client.getAll(null, artifactRest2.getMd5(), artifactRest2.getSha1());
assertThat(artifacts).hasSize(1).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest2.getId()));
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldNotModifyBlacklistedQualityLevel.
@Test
public void shouldNotModifyBlacklistedQualityLevel() throws ClientException {
String id = artifactRest3.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
String REASON = "This artifact has severe CVEs";
Artifact artifact = client.getSpecific(id);
client.createQualityLevelRevision(id, "BLACKLISTED", REASON);
Artifact updatedArtifactDB = client.getSpecific(id);
assertThat(updatedArtifactDB.getId()).isEqualTo(artifact.getId());
assertThat(updatedArtifactDB.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
assertThat(updatedArtifactDB.getQualityLevelReason()).isEqualTo(REASON);
assertThat(updatedArtifactDB.getCreationTime()).isEqualTo(artifact.getCreationTime());
assertThat(updatedArtifactDB.getModificationTime()).isNotEqualTo(artifact.getModificationTime());
assertThat(updatedArtifactDB.getModificationUser().getUsername()).isEqualTo("system");
assertThatThrownBy(() -> client.createQualityLevelRevision(id, "DEPRECATED", REASON)).hasCauseInstanceOf(ClientErrorException.class);
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsWithSha256.
@Test
public void testGetAllArtifactsWithSha256() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Artifact> artifacts = client.getAll(artifactRest1.getSha256(), null, null);
// artifacts 1 and 3 have same SHA256
assertThat(artifacts).hasSize(2).allSatisfy(a -> assertThat(a.getId()).isIn(artifactRest1.getId(), artifactRest4.getId()));
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldNotStandardUserModifyUnallowedQualityLevel.
@Test
public void shouldNotStandardUserModifyUnallowedQualityLevel() throws ClientException {
String id = artifactRest4.getId();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asUser());
String REASON = "This artifact has become dangerous";
assertThatThrownBy(() -> client.createQualityLevelRevision(id, "BLACKLISTED", REASON)).hasCauseInstanceOf(BadRequestException.class);
}
use of org.jboss.pnc.client.ArtifactClient in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldSaveArtifact.
@Test
public void shouldSaveArtifact() throws ClientException {
Artifact artifact = Artifact.builder().artifactQuality(ArtifactQuality.NEW).filename("builtArtifactInsert2.jar").identifier("integration-test:built-artifact-insert2:jar:1.0").targetRepository(targetRepositoryRef).buildCategory(BuildCategory.STANDARD).md5("insert-md5-2").sha1("insert-2").sha256("insert-2").size(10L).build();
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asSystem());
Artifact inserted = client.create(artifact);
String id = inserted.getId();
Artifact retrieved = client.getSpecific(id);
Assertions.assertThat(retrieved.getArtifactQuality()).isEqualTo(ArtifactQuality.NEW);
Assertions.assertThat(retrieved.getMd5()).isEqualTo("insert-md5-2");
Assertions.assertThat(retrieved.getSize()).isEqualTo(10L);
Artifact.Builder builder = inserted.toBuilder();
builder.artifactQuality(ArtifactQuality.TESTED);
Artifact update = builder.build();
client.update(id, update);
Artifact updated = client.getSpecific(id);
Assertions.assertThat(updated.getArtifactQuality()).isEqualTo(ArtifactQuality.TESTED);
}
Aggregations