Search in sources :

Example 1 with MockHFCAClient

use of org.hyperledger.fabric_ca.sdk.MockHFCAClient in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testMockEnrollNoCert.

@Ignore
@Test
public void testMockEnrollNoCert() throws Exception {
    thrown.expect(EnrollmentException.class);
    thrown.expectMessage("failed enrollment for user");
    MockHFCAClient mockClient = MockHFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    mockClient.setCryptoSuite(crypto);
    SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
    mockClient.setHttpPostResponse("{\"success\":true}");
    mockClient.enroll(user.getName(), user.getEnrollmentSecret());
}
Also used : MockHFCAClient(org.hyperledger.fabric_ca.sdk.MockHFCAClient) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with MockHFCAClient

use of org.hyperledger.fabric_ca.sdk.MockHFCAClient in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testMockReenrollNoResult.

@Test
public void testMockReenrollNoResult() throws Exception {
    thrown.expect(EnrollmentException.class);
    // thrown.expectMessage("failed");
    MockHFCAClient mockClient = MockHFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    mockClient.setCryptoSuite(crypto);
    SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
    mockClient.setHttpPostResponse("{\"success\":true}");
    mockClient.reenroll(user);
}
Also used : MockHFCAClient(org.hyperledger.fabric_ca.sdk.MockHFCAClient) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Test(org.junit.Test)

Example 3 with MockHFCAClient

use of org.hyperledger.fabric_ca.sdk.MockHFCAClient in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testMockEnrollNoResult.

@Test
public void testMockEnrollNoResult() throws Exception {
    thrown.expect(EnrollmentException.class);
    thrown.expectMessage("response did not contain a result");
    MockHFCAClient mockClient = MockHFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    mockClient.setCryptoSuite(crypto);
    SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
    mockClient.setHttpPostResponse("{\"success\":true}");
    mockClient.enroll(user.getName(), user.getEnrollmentSecret());
}
Also used : MockHFCAClient(org.hyperledger.fabric_ca.sdk.MockHFCAClient) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Test(org.junit.Test)

Example 4 with MockHFCAClient

use of org.hyperledger.fabric_ca.sdk.MockHFCAClient in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testMockEnrollSuccessFalse.

@Test
public void testMockEnrollSuccessFalse() throws Exception {
    thrown.expect(EnrollmentException.class);
    thrown.expectMessage("failed enrollment for user");
    MockHFCAClient mockClient = MockHFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    mockClient.setCryptoSuite(crypto);
    SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
    mockClient.setHttpPostResponse("{\"success\":false}");
    mockClient.enroll(user.getName(), user.getEnrollmentSecret());
}
Also used : MockHFCAClient(org.hyperledger.fabric_ca.sdk.MockHFCAClient) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Test(org.junit.Test)

Example 5 with MockHFCAClient

use of org.hyperledger.fabric_ca.sdk.MockHFCAClient in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testMockEnrollWithMessages.

@Test
public void testMockEnrollWithMessages() throws Exception {
    MockHFCAClient mockClient = MockHFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    mockClient.setCryptoSuite(crypto);
    SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
    mockClient.setHttpPostResponse("{\"success\":true, \"result\":{\"Cert\":\"abc\"}, \"messages\":[{\"code\":123, \"message\":\"test message\"}]}");
    mockClient.enroll(user.getName(), user.getEnrollmentSecret());
}
Also used : MockHFCAClient(org.hyperledger.fabric_ca.sdk.MockHFCAClient) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Test(org.junit.Test)

Aggregations

SampleUser (org.hyperledger.fabric.sdkintegration.SampleUser)6 MockHFCAClient (org.hyperledger.fabric_ca.sdk.MockHFCAClient)6 Test (org.junit.Test)6 Ignore (org.junit.Ignore)2