use of org.hyperledger.fabric.sdk.security.CryptoSuite in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testEnrollUnknownClient.
// Tests enrolling a user to an unknown CA client
@Test
public void testEnrollUnknownClient() throws Exception {
thrown.expect(EnrollmentException.class);
thrown.expectMessage("Failed to enroll user");
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
// This client does not exist
String clientName = "test CA client";
HFCAClient clientWithName = HFCAClient.createNewInstance(clientName, testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
clientWithName.setCryptoSuite(cryptoSuite);
clientWithName.enroll(admin.getName(), TEST_ADMIN_PW);
}
use of org.hyperledger.fabric.sdk.security.CryptoSuite in project fabric-sdk-java by hyperledger.
the class TransactionContextTest method testGetters.
@Test
public void testGetters() throws Exception {
Channel channel = createTestChannel("channel1");
User user = hfclient.getUserContext();
CryptoSuite cryptoSuite = hfclient.getCryptoSuite();
TransactionContext context = new TransactionContext(channel, user, cryptoSuite);
// ensure getCryptoPrimitives returns what we passed in to the constructor
CryptoSuite cryptoPrimitives = context.getCryptoPrimitives();
Assert.assertEquals(cryptoSuite, cryptoPrimitives);
}
use of org.hyperledger.fabric.sdk.security.CryptoSuite in project fabric-sdk-java by hyperledger.
the class TransactionContextTest method createTestContext.
// ==========================================================================================
// Helper methods
// ==========================================================================================
private TransactionContext createTestContext() {
Channel channel = createTestChannel("channel1");
User user = hfclient.getUserContext();
CryptoSuite cryptoSuite = hfclient.getCryptoSuite();
return new TransactionContext(channel, user, cryptoSuite);
}
use of org.hyperledger.fabric.sdk.security.CryptoSuite in project fabric-sdk-java by hyperledger.
the class HFCAClientTest method testEnrollmentNoKeyPair.
@Test
public void testEnrollmentNoKeyPair() throws Exception {
thrown.expect(EnrollmentException.class);
thrown.expectMessage("Failed to enroll user admin");
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
EnrollmentRequest req = new EnrollmentRequest("profile 1", "label 1", null);
req.setCSR("abc");
HFCAClient client = HFCAClient.createNewInstance("client", "http://localhost:99", null);
client.setCryptoSuite(cryptoSuite);
client.enroll(TEST_ADMIN_NAME, TEST_ADMIN_NAME, req);
}
use of org.hyperledger.fabric.sdk.security.CryptoSuite in project fabric-sdk-java by hyperledger.
the class HFCAClientTest method testEnrollmentNoServerResponse.
// Tests enrollment when no server is available
@Test
public void testEnrollmentNoServerResponse() throws Exception {
thrown.expect(EnrollmentException.class);
thrown.expectMessage("Failed to enroll user admin");
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
EnrollmentRequest req = new EnrollmentRequest("profile 1", "label 1", null);
HFCAClient client = HFCAClient.createNewInstance("client", "http://localhost:99", null);
client.setCryptoSuite(cryptoSuite);
client.enroll(TEST_ADMIN_NAME, TEST_ADMIN_NAME, req);
}
Aggregations