use of org.hyperledger.fabric_ca.sdk.HFCAIdentity in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testDeleteIdentity.
// Tests deleting an identity
@Test
public void testDeleteIdentity() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
thrown.expect(IdentityException.class);
thrown.expectMessage("Failed to get User");
SampleUser user = new SampleUser("testuser4", TEST_ADMIN_ORG, sampleStore);
HFCAIdentity ident = client.newHFCAIdentity(user.getName());
ident.create(admin);
ident.delete(admin);
ident.read(admin);
}
use of org.hyperledger.fabric_ca.sdk.HFCAIdentity in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testForceDeleteAffiliationInvalid.
// Trying to delete affiliation with child affiliations and identities should result
// in an error without force option.
@Test
public void testForceDeleteAffiliationInvalid() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
thrown.expectMessage("Authorization failure");
HFCAAffiliation aff = client.newHFCAAffiliation("org1.dept3");
aff.create(admin);
HFCAAffiliation aff2 = client.newHFCAAffiliation("org1.dept3.team1");
aff2.create(admin);
HFCAIdentity ident = getIdentityReq("testorg1dept3", "client");
ident.setAffiliation("org1.dept3");
ident.create(admin);
HFCAAffiliationResp resp = aff.delete(admin);
assertEquals("Incorrect status code", new Integer(401), new Integer(resp.getStatusCode()));
}
use of org.hyperledger.fabric_ca.sdk.HFCAIdentity in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testDeleteIdentityNotAllowed.
// Tests deleting an identity on CA that does not allow identity removal
@Test
public void testDeleteIdentityNotAllowed() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
thrown.expectMessage("Identity removal is disabled");
SampleUser user = new SampleUser("testuser5", "org2", sampleStore);
HFCAClient client2 = HFCAClient.createNewInstance(testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG2).getCALocation(), testConfig.getIntegrationTestsSampleOrg(TEST_WITH_INTEGRATION_ORG2).getCAProperties());
client2.setCryptoSuite(crypto);
// SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface
SampleUser admin2 = sampleStore.getMember(TEST_ADMIN_NAME, "org2");
if (!admin2.isEnrolled()) {
// Preregistered admin only needs to be enrolled with Fabric CA.
admin2.setEnrollment(client2.enroll(admin.getName(), TEST_ADMIN_PW));
}
HFCAIdentity ident = client2.newHFCAIdentity(user.getName());
ident.create(admin2);
ident.delete(admin2);
}
use of org.hyperledger.fabric_ca.sdk.HFCAIdentity in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method getIdentityReq.
private HFCAIdentity getIdentityReq(String enrollmentID, String type) throws InvalidArgumentException {
String password = "password";
HFCAIdentity ident = client.newHFCAIdentity(enrollmentID);
ident.setSecret(password);
ident.setAffiliation(TEST_USER1_AFFILIATION);
ident.setMaxEnrollments(1);
ident.setType(type);
Collection<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute("testattr1", "valueattr1"));
ident.setAttributes(attributes);
return ident;
}
use of org.hyperledger.fabric_ca.sdk.HFCAIdentity in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testGetIdentityNotExist.
// Tests getting an identity that does not exist
@Test
public void testGetIdentityNotExist() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
setField(client, "statusCode", 405);
HFCAIdentity ident = client.newHFCAIdentity("fakeUser");
int statusCode = ident.read(admin);
if (statusCode != 404) {
fail("Incorrect status code return for an identity that is not found, should have returned 404 and not thrown an excpetion");
}
setField(client, "statusCode", 400);
}
Aggregations