Skip to content

Commit

Permalink
[FAB-6670] Update AttrReq class definition
Browse files Browse the repository at this point in the history
Changed property 'require' to 'optional' to match
the update fabric-ca API definition.

Change-Id: I435f8c66a4656ae34d73ca64bf9a14a750eb659f
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Oct 18, 2017
1 parent 67eafc6 commit d0a28cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ private JsonObject toJsonObject() {
for (AttrReq attrReq : attrreqs.values()) {
JsonObjectBuilder i = Json.createObjectBuilder();
i.add("name", attrReq.name);
if (attrReq.require != null) {
i.add("require", attrReq.require);
if (attrReq.optional != null) {
i.add("optional", attrReq.optional);
}
ab.add(i);

Expand Down Expand Up @@ -206,7 +206,7 @@ public AttrReq addAttrReq(String name) throws InvalidArgumentException {

public class AttrReq {
final String name;
Boolean require = null;
Boolean optional = null;

AttrReq(String name) {
this.name = name;
Expand All @@ -216,8 +216,8 @@ public class AttrReq {
attrreqs.put(name, this);
}

public AttrReq setRequire(boolean require) {
this.require = require;
public AttrReq setOptional(boolean optional) {
this.optional = optional;
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ public void testEnrollReqToJsonAttr() throws Exception {
testEnrollReq.setKeyPair(null);
testEnrollReq.setCAName(caName);
testEnrollReq.addAttrReq("foo");
testEnrollReq.addAttrReq("foorequired").setRequire(true);
testEnrollReq.addAttrReq("foofalse").setRequire(false);
testEnrollReq.addAttrReq("foorequired").setOptional(false);
testEnrollReq.addAttrReq("foofalse").setOptional(true);

String s = testEnrollReq.toJson();
assertNotNull(s);
assertTrue(s.contains("\"attr_reqs\":["));
assertTrue(s.contains("\"name\":\"foorequired\",\"require\":true"));
assertTrue(s.contains("\"name\":\"foofalse\",\"require\":false"));
assertTrue(s.contains("\"name\":\"foorequired\",\"optional\":false"));
assertTrue(s.contains("\"name\":\"foofalse\",\"optional\":true"));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void testRegisterAttributes() throws Exception {
fail("Secret returned from RegistrationRequest not match : " + user.getEnrollmentSecret());
}
EnrollmentRequest req = new EnrollmentRequest();
req.addAttrReq("testattr2").setRequire(true);
req.addAttrReq("testattr2").setOptional(false);

user.setEnrollment(client.enroll(user.getName(), user.getEnrollmentSecret(), req));

Expand Down

0 comments on commit d0a28cf

Please sign in to comment.