*
* @throws Exception
*/
@Test(priority = 1043)
public void testDiscoveredSecurityNodes() throws Exception {
ConfigurationManager testConfigurationManager = pluginContainer.getConfigurationManager();
//iterate through list of nodes and make sure they've all been discovered
////Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic
String attribute = null;
for (String jsonKey : jsonMap.keySet()) {
//Ex. policy-modules
attribute = jsonKey;
//spinder 6/26/12: Temporarily disable until figure out why NPE happens only for this type?
if (attribute.equals(ModuleOptionType.Authentication.getAttribute())) {
break;//
}
//Ex. name=acl-modules
//check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
Resource moduleOptionsTypeResource = getModuleOptionTypeResource(attribute);
//assert non-zero id returned
assert moduleOptionsTypeResource.getId() != 0 : "The resource was not properly initialized. Expected id != 0";
//Now request the resource complete with resource config
Configuration loadedConfiguration = testConfigurationManager
.loadResourceConfiguration(moduleOptionsTypeResource.getId());
String code = null;
String type = null;
String flag = null;
//populate the associated attributes if it's supported.
for (String key : loadedConfiguration.getAllProperties().keySet()) {
Property property = loadedConfiguration.getAllProperties().get(key);
if (key.equals("code")) {
code = ((PropertySimple) property).getStringValue();
} else if (key.equals("flag")) {
flag = ((PropertySimple) property).getStringValue();
} else {//Ex. type.
type = ((PropertySimple) property).getStringValue();
}
}
//retrieve module options as well.
String jsonContent = jsonMap.get(attribute);
Result result = new Result();
try {
// loading jsonMap contents for Ex. 'login-module'
JsonNode node = mapper.readTree(jsonContent);
Object obj = mapper.treeToValue(node, Object.class);
result.setResult(obj);
result.setOutcome("success");
} catch (JsonProcessingException e) {
e.printStackTrace();
assert false;
} catch (IOException e) {
e.printStackTrace();
assert false;
}
//populate the Value component complete with module Options.
List<Value> moduleTypeValue = populateSecurityDomainModuleOptions(result, loadModuleOptionType(attribute));
Value moduleOptionType = moduleTypeValue.get(0);
//Ex. retrieve the acl-modules component and assert values.
//always test 'code'
assert moduleOptionType.getCode().equals(code) : "Module Option 'code' value is not correct. Expected '"
+ code + "' but was '" + moduleOptionType.getCode() + "'";
if (attribute.equals(ModuleOptionType.Mapping.getAttribute())) {
assert moduleOptionType.getType().equals(type) : "Mapping Module 'type' value is not correct. Expected '"
+ type + "' but was '" + moduleOptionType.getType() + "'";
} else if (!attribute.equals(ModuleOptionType.Audit.getAttribute())) {//Audit has no second parameter
assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
+ flag + "' but was '" + moduleOptionType.getFlag() + "'";
}
//Retrieve Module Options and test
//Ex. Module Options for (Acl Modules - Profile)
Resource moduleOptionsResource = getModuleOptionsResource(moduleOptionsTypeResource, attribute);
//assert non-zero id returned
assert moduleOptionsResource.getId() != 0 : "The resource was not properly initialized. Expected id != 0";
//fetch configuration for module options
//Now request the resource complete with resource config
Configuration loadedOptionsConfiguration = testConfigurationManager
.loadResourceConfiguration(moduleOptionsResource.getId());
for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) {
//retrieve the open map of Module Options
PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key));
LinkedHashMap<String, Object> options = moduleOptionType.getOptions();