Skip to content

Commit

Permalink
Do not allow for extraneous keys in the ARP
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jun 19, 2024
1 parent e6954d7 commit caaa971
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"use_as_nameid": {
"type": "boolean"
}
}
},
"additionalProperties": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"use_as_nameid": {
"type": "boolean"
}
}
},
"additionalProperties": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"use_as_nameid": {
"type": "boolean"
}
}
},
"additionalProperties": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1874,4 +1874,33 @@ private void doCreateChangeRequest() {
.then()
.statusCode(SC_OK);
}

@Test
public void saveInvalidARPMetaData() {
MetaData existingMetaData = given()
.when()
.pathParam("id", "11")
.get("manage/api/client/metadata/saml20_sp/{id}")
.as(MetaData.class);
Map<String, Object> arp = (Map<String, Object>) existingMetaData.getData().get("arp");
Map<String, List<Map<String, Object>>> attributes = (Map<String, List<Map<String, Object>>>) arp.get("attributes");
List<Map<String, Object>> givenNameArpAttributes = attributes.get("urn:mace:dir:attribute-def:givenName");
Map<String, Object> arpAttribute = givenNameArpAttributes.get(0);
arpAttribute.put("useAsNameId", true);
arpAttribute.put("use_as_name_id", true);
arpAttribute.put("releaseAs", true);

Map errors = given()
.when()
.body(existingMetaData)
.header("Content-type", "application/json")
.put("manage/api/client/metadata")
.as(Map.class);
String validations = (String) errors.get("validations");
assertEquals("#/arp/attributes/urn:mace:dir:attribute-def:givenName/0: extraneous key [use_as_name_id] is not permitted, " +
"#/arp/attributes/urn:mace:dir:attribute-def:givenName/0: extraneous key [releaseAs] is not permitted, " +
"#/arp/attributes/urn:mace:dir:attribute-def:givenName/0: extraneous key [useAsNameId] is not permitted",
validations);
}

}

0 comments on commit caaa971

Please sign in to comment.