Search in sources :

Example 1 with SampleStore

use of org.hyperledger.fabric.sdkintegration.SampleStore in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method setup.

@Before
public void setup() throws Exception {
    File sampleStoreFile = new File(System.getProperty("java.io.tmpdir") + "/HFCSampletest.properties");
    if (sampleStoreFile.exists()) {
        // For testing start fresh
        sampleStoreFile.delete();
    }
    sampleStore = new SampleStore(sampleStoreFile);
    sampleStoreFile.deleteOnExit();
    client = HFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG).getCAProperties());
    client.setCryptoSuite(crypto);
    // SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
    admin = sampleStore.getMember(TEST_ADMIN_NAME, TEST_ADMIN_ORG);
    if (!admin.isEnrolled()) {
        // Preregistered admin only needs to be enrolled with Fabric CA.
        admin.setEnrollment(client.enroll(admin.getName(), TEST_ADMIN_PW));
    }
}
Also used : SampleStore(org.hyperledger.fabric.sdkintegration.SampleStore) File(java.io.File) Before(org.junit.Before)

Example 2 with SampleStore

use of org.hyperledger.fabric.sdkintegration.SampleStore in project fabric-sdk-java by hyperledger.

the class HFCAClientIT method testEnrollSameUser.

@Test
public void testEnrollSameUser() throws Exception {
    // thrown.expect(RevocationException.class);
    // thrown.expectMessage("does not have attribute 'hf.Revoker'");
    // See if a normal user can revoke the admin...
    SampleUser user1 = getEnrolledUser(TEST_ADMIN_ORG);
    File sampleStoreFile = new File(System.getProperty("java.io.tmpdir") + "/HFCSampletest.properties");
    if (sampleStoreFile.exists()) {
        // For testing start fresh
        sampleStoreFile.delete();
    }
    sampleStore = new SampleStore(sampleStoreFile);
    sampleStoreFile.deleteOnExit();
    SampleUser user2 = getEnrolledUser(TEST_ADMIN_ORG);
    // client.revoke(user, admin.getName(), "revoke admin");
    client.enroll(user1.getName(), user2.getEnrollmentSecret());
}
Also used : SampleStore(org.hyperledger.fabric.sdkintegration.SampleStore) File(java.io.File) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser) Test(org.junit.Test)

Example 3 with SampleStore

use of org.hyperledger.fabric.sdkintegration.SampleStore in project fabric-sdk-java by hyperledger.

the class HFCAAffiliationTest method setup.

@Before
public void setup() throws CryptoException, InvalidArgumentException, org.hyperledger.fabric.sdk.exception.InvalidArgumentException, MalformedURLException, EnrollmentException {
    File sampleStoreFile = new File(System.getProperty("java.io.tmpdir") + "/HFCSampletest.properties");
    if (sampleStoreFile.exists()) {
        // For testing start fresh
        sampleStoreFile.delete();
    }
    sampleStore = new SampleStore(sampleStoreFile);
    sampleStoreFile.deleteOnExit();
    // SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
    admin = sampleStore.getMember(TEST_ADMIN_NAME, TEST_ADMIN_ORG);
}
Also used : SampleStore(org.hyperledger.fabric.sdkintegration.SampleStore) File(java.io.File) Before(org.junit.Before)

Example 4 with SampleStore

use of org.hyperledger.fabric.sdkintegration.SampleStore in project fabric-sdk-java by hyperledger.

the class HFCAClientTest method setup.

@Before
public void setup() throws CryptoException, InvalidArgumentException, org.hyperledger.fabric.sdk.exception.InvalidArgumentException, MalformedURLException, EnrollmentException {
    File sampleStoreFile = new File(System.getProperty("java.io.tmpdir") + "/HFCSampletest.properties");
    if (sampleStoreFile.exists()) {
        // For testing start fresh
        sampleStoreFile.delete();
    }
    sampleStore = new SampleStore(sampleStoreFile);
    sampleStoreFile.deleteOnExit();
    // SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
    admin = sampleStore.getMember(TEST_ADMIN_NAME, TEST_ADMIN_ORG);
}
Also used : SampleStore(org.hyperledger.fabric.sdkintegration.SampleStore) File(java.io.File) Before(org.junit.Before)

Example 5 with SampleStore

use of org.hyperledger.fabric.sdkintegration.SampleStore in project fabric-sdk-java by hyperledger.

the class TestHFClient method setupClient.

public static void setupClient(HFClient hfclient) throws Exception {
    File tempFile = File.createTempFile("teststore", "properties");
    tempFile.deleteOnExit();
    File sampleStoreFile = new File(System.getProperty("user.home") + "/test.properties");
    if (sampleStoreFile.exists()) {
        // For testing start fresh
        sampleStoreFile.delete();
    }
    final SampleStore sampleStore = new SampleStore(sampleStoreFile);
    // src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/
    // SampleUser someTestUSER = sampleStore.getMember("someTestUSER", "someTestORG");
    SampleUser someTestUSER = sampleStore.getMember("someTestUSER", "someTestORG", "mspid", findFileSk("src/test/fixture/sdkintegration/e2e-2Orgs/" + TestConfig.FAB_CONFIG_GEN_VERS + "/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore"), new File("src/test/fixture/sdkintegration/e2e-2Orgs/" + TestConfig.FAB_CONFIG_GEN_VERS + "/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"));
    someTestUSER.setMspId("testMSPID?");
    hfclient.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
    hfclient.setUserContext(someTestUSER);
}
Also used : SampleStore(org.hyperledger.fabric.sdkintegration.SampleStore) File(java.io.File) SampleUser(org.hyperledger.fabric.sdkintegration.SampleUser)

Aggregations

File (java.io.File)6 SampleStore (org.hyperledger.fabric.sdkintegration.SampleStore)6 Before (org.junit.Before)4 SampleUser (org.hyperledger.fabric.sdkintegration.SampleUser)2 Test (org.junit.Test)1