HoldingIdentityResolver Test
This commit is contained in:
parent
ada353ce2f
commit
74176ecf45
@ -0,0 +1,67 @@
|
||||
package djmil.cordacheckers;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||
|
||||
@SpringBootTest
|
||||
public class HoldingIdentityResolverTests {
|
||||
|
||||
@Autowired
|
||||
HoldingIdentityResolver holdingIdentityResolver;
|
||||
|
||||
/*
|
||||
* The test is expecting that CSDE static-network-config.json to look like stated below.
|
||||
* Important bits:
|
||||
* - the contents of 'CN', 'OU', 'O' fields
|
||||
* - there shall be only one Custodian
|
||||
*/
|
||||
/*
|
||||
[
|
||||
{
|
||||
"x500Name" : "CN=Alice, OU=Player, O=Checkers, L=Zug, C=CH",
|
||||
"cpi" : "CordaCheckers"
|
||||
},
|
||||
{
|
||||
"x500Name" : "CN=Bob, OU=Player, O=Checkers, L=Kyiv, C=UA",
|
||||
"cpi" : "CordaCheckers"
|
||||
},
|
||||
{
|
||||
"x500Name" : "CN=Charlie, OU=Player, O=Checkers, L=London, C=GB",
|
||||
"cpi" : "CordaCheckers"
|
||||
},
|
||||
{
|
||||
"x500Name" : "CN=Kumar, OU=Custodian, O=Checkers, L=Mumbai, C=IN",
|
||||
"cpi" : "CordaCheckers"
|
||||
},
|
||||
{
|
||||
"x500Name" : "CN=NotaryRep1, OU=Test Dept, O=R3, L=London, C=GB",
|
||||
"cpi" : "NotaryServer",
|
||||
"serviceX500Name": "CN=NotaryService, OU=Test Dept, O=R3, L=London, C=GB"
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
@Test
|
||||
void testCheckUsers() {
|
||||
assertDoesNotThrow( () -> {
|
||||
holdingIdentityResolver.getByUsername("alice");
|
||||
holdingIdentityResolver.getByUsername("BOB");
|
||||
holdingIdentityResolver.getByUsername("Charlie");
|
||||
});
|
||||
|
||||
assertThat(holdingIdentityResolver.getByUsername("SomeRundomName")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustodian() {
|
||||
assertThat(holdingIdentityResolver.getByUsername("Kumar")).isNull();
|
||||
assertThat(holdingIdentityResolver.getCustodian()).isNotNull();
|
||||
}
|
||||
|
||||
}
|
@ -60,40 +60,4 @@ public class GameBoardTests {
|
||||
assertThat(winnerGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_WON);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// void testGameBoardMove() throws JsonMappingException, JsonProcessingException, InvalidNameException {
|
||||
// final var hiAlice = holdingIdentityResolver.getByUsername("alice");
|
||||
// final var hiBob = holdingIdentityResolver.getByUsername("bob");
|
||||
// final var bobColor = Piece.Color.WHITE;
|
||||
|
||||
// final UUID gpUuid = cordaClient.gameProposalCreate(
|
||||
// hiAlice, hiBob,
|
||||
// bobColor, "GameBoard MOVE test"
|
||||
// );
|
||||
|
||||
// System.out.println("New GameProposal UUID "+ gpUuid);
|
||||
|
||||
// final GameBoard gbState = cordaClient.gameProposalAccept(
|
||||
// hiBob, gpUuid
|
||||
// );
|
||||
|
||||
// System.out.println("New GameBoard UUID "+ gbState.gameUuid());
|
||||
|
||||
// assertThatThrownBy(() -> { // Alice can not move, since it is Bob's turn
|
||||
// cordaClient.gameBoardMove(
|
||||
// hiAlice, gbState.gameUuid(),
|
||||
// Arrays.asList(1, 2));
|
||||
// });
|
||||
|
||||
// final GameBoard gameBoard = cordaClient.gameBoardMove(
|
||||
// hiBob, gbState.gameUuid(), Arrays.asList(1, 2));
|
||||
// }
|
||||
|
||||
// private <T extends GameState> T findByUuid(List<T> statesList, UUID uuid) {
|
||||
// for (T state : statesList) {
|
||||
// if (state.uuid().compareTo(uuid) == 0)
|
||||
// return state;
|
||||
// };
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
@ -1,20 +1,14 @@
|
||||
package djmil.cordacheckers.cordaclient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.naming.InvalidNameException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import djmil.cordacheckers.cordaclient.dao.GameState;
|
||||
import djmil.cordacheckers.cordaclient.dao.VirtualNode;
|
||||
import djmil.cordacheckers.cordaclient.dao.Piece;
|
||||
import djmil.cordacheckers.user.HoldingIdentityResolver;
|
||||
|
||||
@SpringBootTest
|
||||
@ -25,15 +19,12 @@ public class GameStateTests {
|
||||
@Autowired
|
||||
HoldingIdentityResolver holdingIdentityResolver;
|
||||
|
||||
@Test
|
||||
void testGetVirtualNodeList() throws InvalidNameException {
|
||||
List<VirtualNode> vNodes = cordaClient.getVirtualNodeList();
|
||||
|
||||
assertThat(vNodes.size()).isEqualTo(5); // default vNode config for CSDE
|
||||
}
|
||||
final String issuer = "alice";
|
||||
final String acquier = "bob";
|
||||
final Piece.Color acquierColor = Piece.Color.WHITE;
|
||||
|
||||
@Test
|
||||
void testList() throws JsonProcessingException {
|
||||
void testList() {
|
||||
List<GameState> gsList = cordaClient.gameStateList(
|
||||
holdingIdentityResolver.getByUsername("bob"));
|
||||
|
||||
@ -41,7 +32,7 @@ public class GameStateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGet() throws JsonProcessingException {
|
||||
void testGet() {
|
||||
GameState gameStateView = cordaClient.gameStateGet(
|
||||
holdingIdentityResolver.getByUsername("bob"),
|
||||
UUID.fromString("cf357d0a-8f64-4599-b9b5-d263163812d4")
|
||||
|
Loading…
Reference in New Issue
Block a user