Search in sources :

Example 6 with MockUser

use of org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser in project fabric-sdk-java by hyperledger.

the class NetworkConfigIT method getAdminUser.

private static User getAdminUser(String orgName) throws Exception {
    NetworkConfig.UserInfo userInfo = networkConfig.getPeerAdmin(orgName);
    // NetworkConfig.UserInfo userInfo = networkConfig.getPeerAdmin();
    String userName = userInfo.getEnrollId();
    String mspId = userInfo.getMspId();
    PrivateKey privateKey = userInfo.getPrivateKey();
    String signedCert = userInfo.getSignedCert();
    MockUser admin = TestUtils.getMockUser(userName, mspId);
    admin.setEnrollment(TestUtils.getMockEnrollment(privateKey, signedCert));
    return admin;
}
Also used : PrivateKey(java.security.PrivateKey) NetworkConfig(org.hyperledger.fabric.sdk.NetworkConfig) MockUser(org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser)

Example 7 with MockUser

use of org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser in project fabric-sdk-java by hyperledger.

the class ClientTest method testCryptoFactory.

// (expected = InvalidArgumentException.class)
@Test
@Ignore
public void testCryptoFactory() throws Exception {
    try {
        resetConfig();
        Assert.assertNotNull(Config.getConfig().getDefaultCryptoSuiteFactory());
        HFClient client = HFClient.createNewInstance();
        client.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
        MockUser mockUser = TestUtils.getMockUser(USER_NAME, USER_MSP_ID);
        MockEnrollment mockEnrollment = TestUtils.getMockEnrollment(null, "mockCert");
        mockUser.setEnrollment(mockEnrollment);
        client.setUserContext(mockUser);
    } finally {
        System.getProperties().remove("org.hyperledger.fabric.sdk.crypto.default_crypto_suite_factory");
    }
}
Also used : MockEnrollment(org.hyperledger.fabric.sdk.testutils.TestUtils.MockEnrollment) MockUser(org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with MockUser

use of org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser in project fabric-sdk-java by hyperledger.

the class ClientTest method testBadUserMSPIDNull.

@Test(expected = InvalidArgumentException.class)
public void testBadUserMSPIDNull() throws Exception {
    HFClient client = HFClient.createNewInstance();
    client.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
    MockUser mockUser = TestUtils.getMockUser(USER_NAME, null);
    client.setUserContext(mockUser);
}
Also used : MockUser(org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser) Test(org.junit.Test)

Example 9 with MockUser

use of org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser in project fabric-sdk-java by hyperledger.

the class ClientTest method testBadEnrollmentBadCert.

@Test(expected = InvalidArgumentException.class)
public void testBadEnrollmentBadCert() throws Exception {
    HFClient client = HFClient.createNewInstance();
    client.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
    MockUser mockUser = TestUtils.getMockUser(USER_NAME, USER_MSP_ID);
    MockEnrollment mockEnrollment = TestUtils.getMockEnrollment(null);
    mockUser.setEnrollment(mockEnrollment);
    client.setUserContext(mockUser);
}
Also used : MockEnrollment(org.hyperledger.fabric.sdk.testutils.TestUtils.MockEnrollment) MockUser(org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser) Test(org.junit.Test)

Aggregations

MockUser (org.hyperledger.fabric.sdk.testutils.TestUtils.MockUser)9 Test (org.junit.Test)8 MockEnrollment (org.hyperledger.fabric.sdk.testutils.TestUtils.MockEnrollment)3 PrivateKey (java.security.PrivateKey)1 NetworkConfig (org.hyperledger.fabric.sdk.NetworkConfig)1 Ignore (org.junit.Ignore)1