Compare commits

..

No commits in common. "cff3c4a584e12fa7d6ea5be7f71ec2e9bf32a2df" and "b0e2f0e25b8aa8b3f2ed11f2cdf3d9d47c2697f1" have entirely different histories.

3 changed files with 1 additions and 90 deletions

View File

@ -1,35 +1,6 @@
package djmil.cordacheckers.cordaclient.pojo;
import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public record holdingIdentity(String x500Name, String shortHash) {
public String getName() throws InvalidNameException {
LdapName ln = new LdapName(x500Name);
for(Rdn rdn : ln.getRdns()) {
if(rdn.getType().equalsIgnoreCase("CN")) {
return rdn.getValue().toString();
}
}
throw new IllegalArgumentException("CN was not found");
}
public boolean isPlayer() throws InvalidNameException {
LdapName ln = new LdapName(x500Name);
for(Rdn rdn : ln.getRdns()) {
if(rdn.getType().equalsIgnoreCase("OU")) {
return rdn.getValue().toString().equalsIgnoreCase("Player");
}
}
return false;
}
}
public record holdingIdentity(String x500Name, String shortHash) { }

View File

@ -1,33 +0,0 @@
package djmil.cordacheckers;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import djmil.cordacheckers.cordaclient.CordaClient;
import djmil.cordacheckers.cordaclient.pojo.holdingIdentity;
import djmil.cordacheckers.cordaclient.pojo.virtualNodes;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.List;
import javax.naming.InvalidNameException;
@SpringBootTest
public class CordaClientTest {
@Autowired
CordaClient cordaclient;
@Test
void whenGetVirtualnode_thenListHoldingIdentity() throws GeneralSecurityException, IOException, InvalidNameException {
List<virtualNodes> vNodes = cordaclient.getVirtualnode();
holdingIdentity identity = vNodes.get(0).holdingIdentity();
assertThat(identity.getName()).isEqualTo("NotaryRep1");
}
}

View File

@ -1,27 +0,0 @@
package djmil.cordacheckers;
import org.junit.jupiter.api.Test;
import djmil.cordacheckers.cordaclient.pojo.holdingIdentity;
import static org.assertj.core.api.Assertions.assertThat;
import javax.naming.InvalidNameException;
public class HoldingIdentityTest {
@Test
public void isPlayerTest() throws InvalidNameException {
holdingIdentity alice = new holdingIdentity("CN=Alice, OU=Player, O=Checkers, L=Zug, C=CH", "HHHDDD");
holdingIdentity bob = new holdingIdentity("CN=Bob, OU=Other, O=Checkers, L=Zug, C=CH", "HHHDDD");
assertThat(alice.getName()).isEqualTo("Alice");
assertThat(alice.isPlayer()).isEqualTo(true);
assertThat(bob.getName()).isEqualTo("Bob");
assertThat(bob.isPlayer()).isEqualTo(false);
}
}