use of org.hyperledger.fabric_ca.sdk.HFCAAffiliation.HFCAAffiliationResp in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testUpdateAffiliationNoForce.
// Tests updating an affiliation that doesn't require force option
@Test
public void testUpdateAffiliationNoForce() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
HFCAAffiliation aff = client.newHFCAAffiliation("org_5");
aff.create(admin);
aff.setUpdateName("org_6");
HFCAAffiliationResp resp = aff.update(admin);
assertEquals("Incorrect status code", new Integer(200), new Integer(resp.getStatusCode()));
assertEquals("Failed to delete affiliation", "org_6", aff.getName());
}
use of org.hyperledger.fabric_ca.sdk.HFCAAffiliation.HFCAAffiliationResp in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testUpdateAffiliation.
// Tests updating an affiliation
@Test
public void testUpdateAffiliation() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
HFCAAffiliation aff = client.newHFCAAffiliation("org4");
aff.create(admin);
HFCAIdentity ident = client.newHFCAIdentity("testuser_org4");
ident.setAffiliation(aff.getName());
ident.create(admin);
HFCAAffiliation aff2 = client.newHFCAAffiliation("org4.dept1");
aff2.create(admin);
HFCAIdentity ident2 = client.newHFCAIdentity("testuser_org4.dept1");
ident2.setAffiliation("org4.dept1");
ident2.create(admin);
HFCAAffiliation aff3 = client.newHFCAAffiliation("org4.dept1.team1");
aff3.create(admin);
HFCAIdentity ident3 = client.newHFCAIdentity("testuser_org4.dept1.team1");
ident3.setAffiliation("org4.dept1.team1");
ident3.create(admin);
aff.setUpdateName("org5");
// Set force option to true, since their identities associated with affiliations
// that are getting updated
HFCAAffiliationResp resp = aff.update(admin, true);
int found = 0;
int idCount = 0;
// Should contain the affiliations affected by the update request
HFCAAffiliation child = aff.getChild("dept1");
assertNotNull(child);
assertEquals("Failed to get correct child affiliation", "org5.dept1", child.getName());
for (HFCAIdentity id : child.getIdentities()) {
if (id.getEnrollmentId().equals("testuser_org4.dept1")) {
idCount++;
}
}
HFCAAffiliation child2 = child.getChild("team1");
assertNotNull(child2);
assertEquals("Failed to get correct child affiliation", "org5.dept1.team1", child2.getName());
for (HFCAIdentity id : child2.getIdentities()) {
if (id.getEnrollmentId().equals("testuser_org4.dept1.team1")) {
idCount++;
}
}
for (HFCAIdentity id : aff.getIdentities()) {
if (id.getEnrollmentId().equals("testuser_org4")) {
idCount++;
}
}
if (idCount != 3) {
fail("Incorrect number of ids returned");
}
assertEquals("Incorrect response for id", "org5", aff.getName());
assertEquals("Incorrect status code", new Integer(200), new Integer(resp.getStatusCode()));
}
use of org.hyperledger.fabric_ca.sdk.HFCAAffiliation.HFCAAffiliationResp in project fabric-sdk-java by hyperledger.
the class HFCAClientIT method testDeleteAffiliation.
// Tests deleting an affiliation
@Test
public void testDeleteAffiliation() throws Exception {
if (testConfig.isRunningAgainstFabric10()) {
// needs v1.1
return;
}
thrown.expectMessage("Affiliation has been deleted");
HFCAAffiliation aff = client.newHFCAAffiliation("org6");
aff.create(admin);
HFCAIdentity ident = client.newHFCAIdentity("testuser_org6");
ident.setAffiliation("org6");
ident.create(admin);
HFCAAffiliation aff2 = client.newHFCAAffiliation("org6.dept1");
aff2.create(admin);
HFCAIdentity ident2 = client.newHFCAIdentity("testuser_org6.dept1");
ident2.setAffiliation("org6.dept1");
ident2.create(admin);
HFCAAffiliationResp resp = aff.delete(admin, true);
int idCount = 0;
boolean found = false;
for (HFCAAffiliation childAff : resp.getChildren()) {
if (childAff.getName().equals("org6.dept1")) {
found = true;
}
for (HFCAIdentity id : childAff.getIdentities()) {
if (id.getEnrollmentId().equals("testuser_org6.dept1")) {
idCount++;
}
}
}
for (HFCAIdentity id : resp.getIdentities()) {
if (id.getEnrollmentId().equals("testuser_org6")) {
idCount++;
}
}
if (!found) {
fail("Incorrect response received");
}
if (idCount != 2) {
fail("Incorrect number of ids returned");
}
assertEquals("Incorrect status code", new Integer(200), new Integer(resp.getStatusCode()));
assertEquals("Failed to delete affiliation", "org6", aff.getName());
aff.delete(admin);
}
Aggregations