use of org.hyperledger.fabric.protos.common.Policies.SignaturePolicy.TypeCase in project fabric-sdk-java by hyperledger.
the class ChaincodeEndorsementPolicyTest method testSDKIntegrationYaml.
/**
* Test method for {@link ChaincodeEndorsementPolicy#fromYamlFile(File)}
* @throws IOException
* @throws ChaincodeEndorsementPolicyParseException
*/
@Test
public void testSDKIntegrationYaml() throws IOException, ChaincodeEndorsementPolicyParseException {
ChaincodeEndorsementPolicy itTestPolicy = new ChaincodeEndorsementPolicy();
itTestPolicy.fromYamlFile(new File("src/test/fixture/sdkintegration/chaincodeendorsementpolicy.yaml"));
SignaturePolicyEnvelope sigPolEnv = SignaturePolicyEnvelope.parseFrom(itTestPolicy.getChaincodeEndorsementPolicyAsBytes());
List<MSPPrincipal> identitiesList = sigPolEnv.getIdentitiesList();
for (MSPPrincipal ident : identitiesList) {
MSPPrincipal mspPrincipal = MSPPrincipal.parseFrom(ident.getPrincipal());
MSPPrincipal.Classification principalClassification = mspPrincipal.getPrincipalClassification();
assertEquals(principalClassification.toString(), MSPPrincipal.Classification.ROLE.name());
MspPrincipal.MSPRole mspRole = MspPrincipal.MSPRole.parseFrom(ident.getPrincipal());
String iden = mspRole.getMspIdentifier();
assertTrue("Org1MSP".equals(iden) || "Org2MSP".equals(iden));
assertTrue(mspRole.getRole().getNumber() == MspPrincipal.MSPRole.MSPRoleType.ADMIN_VALUE || mspRole.getRole().getNumber() == MspPrincipal.MSPRole.MSPRoleType.MEMBER_VALUE);
}
Policies.SignaturePolicy rule = sigPolEnv.getRule();
TypeCase typeCase = rule.getTypeCase();
assertEquals(TypeCase.N_OUT_OF.getNumber(), typeCase.getNumber());
}
Aggregations