Skip to content

BEV-75 add deletion approver #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ pipeline {
maven 'Maven' // Use the maven automatic installation configured in Jenkins
}
environment {
// TODO: Need to use settings: -s /etc/m2/settings.xml
MVN_CMD = 'mvn -s /etc/m2/settings.xml --batch-mode' // Define the base Maven command
APP_NAME = 'bitrepository' // Application Name (Must match ArgoCD)
AUTH_TOKEN = 'TOKEN' // Authentication token for ArgoCD
}
options {
disableConcurrentBuilds() // Prevent concurrent builds
Expand Down Expand Up @@ -43,8 +44,8 @@ pipeline {
stage('Push to Nexus (if Master)') {
steps {
script {
echo "Deploying '${env.BRANCH_NAME}' branch to Nexus"
if (env.BRANCH_NAME == 'master') {
echo "Deploying '${env.BRANCH_NAME}' branch to Nexus"
sh "${env.MVN_CMD} clean deploy -DskipTests=true"
}
}
Expand All @@ -53,10 +54,11 @@ pipeline {
}
post {
success {
echo 'Build succeeded.'
script {
echo 'Build succeeded, syncing application in ArgoCD.'
}
}
failure {
// TODO: Notify on email (possibly just use plugin)
echo 'Build failed, investigate errors in the console output.'
}
}
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-alarm-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.bitrepository.reference</groupId>
<artifactId>bitrepository-parent</artifactId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-audit-trail-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>bitrepository-parent</artifactId>
<groupId>org.bitrepository.reference</groupId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>

<artifactId>bitrepository-audit-trail-service</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>bitrepository-parent</artifactId>
<groupId>org.bitrepository.reference</groupId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bitrepository-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.bitrepository.reference</groupId>
<artifactId>bitrepository-parent</artifactId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>
<artifactId>bitrepository-core</artifactId>
<name>Bitrepository Core</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public static byte[] encodeBase16(String hexString) throws DecoderException {
try {
return Hex.decodeHex(hexString);
} catch (DecoderException e) {
throw new DecoderException("The string '" + hexString + "' is not a valid hex-string.");
throw new DecoderException(
"The string '" + hexString + "' is not a valid hex-string: " + e.getMessage(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -101,41 +102,51 @@ public static String getCollectionName(String collectionID) {
return name;
}

public static IntegrityServiceSettings getIntegrityServiceSettings() {
return settings.getReferenceSettings().getIntegrityServiceSettings();
}

/**
* Grab all PillarDetails from the ReferenceSettings if any are defined and return them as a list.
* Return an empty list if not defined.
* @return List of all PillarDetails defined in the ReferenceSettings
*/
public static List<PillarIntegrityDetails.PillarDetails> getPillarIntegrityDetails() {
PillarIntegrityDetails pillarIntegrityDetails = getIntegrityServiceSettings().getPillarIntegrityDetails();
if (pillarIntegrityDetails != null) {
List<PillarIntegrityDetails.PillarDetails> pillarDetails = pillarIntegrityDetails.getPillarDetails();
if (pillarDetails != null) {
return Collections.unmodifiableList(pillarDetails);
}
}
return List.of();
}

/**
* Get the human-readable pillar name for the given pillarID from the ReferenceSettings.
*
* @param pillarID The pillarID for which the pillar name is wanted.
* @return Returns the pillar name for the given pillar ID.
*/
public static String getPillarName(String pillarID) {
PillarIntegrityDetails details = settings.getReferenceSettings().getIntegrityServiceSettings().getPillarIntegrityDetails();
if (details != null) {
for (PillarIntegrityDetails.PillarDetails d : details.getPillarDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarName();
}
for (PillarIntegrityDetails.PillarDetails d : getPillarIntegrityDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarName();
}
}
return null;
}

public static IntegrityServiceSettings getIntegrityServiceSettings() {
return settings.getReferenceSettings().getIntegrityServiceSettings();
}

/**
* Get the {@link PillarType} for the given Pillar ID.
*
* @param pillarID The pillar ID for which the {@link PillarType} is wanted.
* @return Returns the {@link PillarType} for the given pillar ID.
*/
public static PillarType getPillarType(String pillarID) {
PillarIntegrityDetails details = settings.getReferenceSettings().getIntegrityServiceSettings().getPillarIntegrityDetails();
if (details != null) {
for (PillarIntegrityDetails.PillarDetails d : details.getPillarDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarType();
}
for (PillarIntegrityDetails.PillarDetails d : getPillarIntegrityDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarType();
}
}
return null;
Expand Down Expand Up @@ -212,5 +223,4 @@ public static Set<String> getStatusContributorsForCollection() {
contributors.addAll(SettingsUtils.getAllPillarIDs());
return contributors;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
<PillarID>Pillar1</PillarID>
<PillarName>Alpha</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose [email protected]</PillarDeleteFileApprover>
</PillarDetails>
</PillarIntegrityDetails>
</IntegrityServiceSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Base16UtilsTest extends ExtendedTestCase {

private final String DECODED_CHECKSUM = "ff5aca7ae8c80c9a3aeaf9173e4dfd27";
private final byte[] ENCODED_CHECKSUM = new byte[]{-1,90,-54,122,-24,-56,12,-102,58,-22,-7,23,62,77,-3,39};

@Test(groups = { "regressiontest" })
public void encodeChecksum() throws Exception {
addDescription("Validating the encoding of the checksums.");
Expand All @@ -55,7 +55,15 @@ public void decodeChecksum() {
String decodedChecksum = Base16Utils.decodeBase16(ENCODED_CHECKSUM);
Assert.assertEquals(decodedChecksum, DECODED_CHECKSUM);
}


@Test
public void decodesNull() {
addDescription("Test decoding null");
byte[] data = null;
String decoded = Base16Utils.decodeBase16(data);
Assert.assertNull(decoded);
}

@Test(groups = { "regressiontest" })
public void badArgumentTest() {
addDescription("Test bad arguments");
Expand All @@ -64,5 +72,7 @@ public void badArgumentTest() {
addStep("Test with an odd number of characters.", "Should throw a decoder exception");
Assert.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("123"));

addStep("Test with a non hex digit.", "Should throw a decoder exception");
Assert.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("1g"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void checkUrlEncodingOfFilenamesTest() throws MalformedURLException {
Settings mySettings = TestSettingsProvider.reloadSettings("uploadTest");
FileExchangeSettings fileExchangeSettings = mySettings.getReferenceSettings().getFileExchangeSettings();
fileExchangeSettings.setProtocolType(ProtocolType.HTTP);
fileExchangeSettings.setServerName("http:testserver.org");
fileExchangeSettings.setServerName("testserver.org");
fileExchangeSettings.setPort(BigInteger.valueOf(8000));
fileExchangeSettings.setPath("dav");
HttpFileExchange fe = new HttpFileExchange(fileExchangeSettings);
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.bitrepository.reference</groupId>
<artifactId>bitrepository-parent</artifactId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bitrepository-integration</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,19 @@
<PillarID>checksum-pillar</PillarID>
<PillarName>Alpha</PillarName>
<PillarType>CHECKSUM</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose [email protected]</PillarDeleteFileApprover>
</PillarDetails>
<PillarDetails>
<PillarID>file1-pillar</PillarID>
<PillarName>Beta</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose [email protected]</PillarDeleteFileApprover>
</PillarDetails>
<PillarDetails>
<PillarID>file2-pillar</PillarID>
<PillarName>Gamma</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose [email protected]</PillarDeleteFileApprover>
</PillarDetails>
</PillarIntegrityDetails>
</IntegrityServiceSettings>
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-integrity-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.bitrepository.reference</groupId>
<artifactId>bitrepository-parent</artifactId>
<version>1.12-SNAPSHOT</version>
<version>1.11.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.bitrepository.integrityservice.web;

import java.io.Serializable;

public class PillarDetailsDto implements Serializable {
private static final long serialVersionUID = 1L;

private String pillarID;
private String pillarName;
private String pillarType;
private String pillarDeleteFileApprover;

public PillarDetailsDto() {}

public PillarDetailsDto(String pillarID, String pillarName, String pillarType, String pillarDeleteFileApprover) {
this.pillarID = pillarID;
this.pillarName = pillarName;
this.pillarType = pillarType;
this.pillarDeleteFileApprover = pillarDeleteFileApprover;
}

public String getPillarID() {
return pillarID;
}

public void setPillarID(String pillarID) {
this.pillarID = pillarID;
}

public String getPillarName() {
return pillarName;
}

public void setPillarName(String pillarName) {
this.pillarName = pillarName;
}

public String getPillarType() {
return pillarType;
}

public void setPillarType(String pillarType) {
this.pillarType = pillarType;
}

public String getPillarDeleteFileApprover() {
return pillarDeleteFileApprover;
}

public void setPillarDeleteFileApprover(String pillarDeleteFileApprover) {
this.pillarDeleteFileApprover = pillarDeleteFileApprover;
}

@Override
public String toString() {
return "PillarDetailsDTO{" +
"pillarID='" + pillarID + '\'' +
", pillarName='" + pillarName + '\'' +
", pillarType=" + pillarType +
", pillarDeleteFileApprover='" + pillarDeleteFileApprover + '\'' +
'}';
}
}
Loading