use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq in project product-is by wso2.
the class IdentityGovernanceSuccessTest method testSearchGovernanceConnectorProperties.
@Test(dataProvider = "connectorPropertiesProvider")
public void testSearchGovernanceConnectorProperties(List<PreferenceResp> connectorList, String requestJson) throws IOException {
String body = readResource(requestJson);
Response response = getResponseOfPost(IDENTITY_GOVERNANCE_ENDPOINT_URI + "/preferences", body);
for (PreferenceResp preferenceResp : connectorList) {
String baseIdentifier = "find{ it.('connector-name') == '" + preferenceResp.getConnectorName() + "' }.";
List<PropertyReq> properties = preferenceResp.getProperties();
int i = 0;
for (PropertyReq propertyReq : properties) {
ValidatableResponse validatableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
validatableResponse.body(baseIdentifier + "properties", notNullValue()).body(baseIdentifier + "properties[" + i + "].name", equalTo(propertyReq.getName())).body(baseIdentifier + "properties[" + i + "].value", equalTo(propertyReq.getValue()));
i++;
}
}
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method createPropertyRequest.
private void createPropertyRequest(List<PropertyReq> propertyReqList, Property property) {
PropertyReq propertyReq = new PropertyReq();
propertyReq.setName(property.getName());
propertyReq.setValue(property.getValue());
propertyReqList.add(propertyReq);
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method updateGovernanceConnectorProperty.
/**
* Update governance connector property.
*
* @param categoryId Governance connector category id.
* @param connectorId Governance connector id.
* @param governanceConnector Connector property to update.
*/
public void updateGovernanceConnectorProperty(String categoryId, String connectorId, ConnectorsPatchReq governanceConnector) {
try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
ConnectorRes connector = getGovernanceConnector(categoryId, connectorId);
if (connector == null) {
throw handleNotFoundError(connectorId, GovernanceConstants.ErrorMessage.ERROR_CODE_CONNECTOR_NOT_FOUND);
}
Map<String, String> configurationDetails = new HashMap<>();
for (PropertyReq propertyReqDTO : governanceConnector.getProperties()) {
configurationDetails.put(propertyReqDTO.getName(), propertyReqDTO.getValue());
}
identityGovernanceService.updateConfiguration(tenantDomain, configurationDetails);
} catch (IdentityGovernanceException e) {
GovernanceConstants.ErrorMessage errorEnum = GovernanceConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_CONNECTOR_PROPERTY;
Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
throw handleException(e, errorEnum, status);
}
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method buildPropertyReqForExpectedAttributes.
private List<PropertyReq> buildPropertyReqForExpectedAttributes(Property[] properties, List<String> expectedProperties) {
List<PropertyReq> propertyReqList = new ArrayList<>();
Map<String, Property> propertyMap = new HashMap<>();
for (Property property : properties) {
propertyMap.put(property.getName(), property);
}
for (String expectedProperty : expectedProperties) {
Property property = propertyMap.get(expectedProperty);
if (property == null || property.isConfidential()) {
throw handleException(new IdentityGovernanceException(GovernanceConstants.ErrorMessage.ERROR_CODE_UNSUPPORTED_PROPERTY_NAME.getMessage()), GovernanceConstants.ErrorMessage.ERROR_CODE_UNSUPPORTED_PROPERTY_NAME, Response.Status.BAD_REQUEST, expectedProperty);
}
createPropertyRequest(propertyReqList, property);
}
return propertyReqList;
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method buildPreferenceRespDTO.
private PreferenceResp buildPreferenceRespDTO(String connectorName, Property[] properties, List<String> expectedProperties) {
PreferenceResp preferenceResp = new PreferenceResp();
List<PropertyReq> propertyReqList = buildPropertyReqDTO(properties, expectedProperties);
preferenceResp.setProperties(propertyReqList);
preferenceResp.setConnectorName(connectorName);
return preferenceResp;
}
Aggregations