use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp 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.PreferenceResp in project identity-api-server by wso2.
the class ServerIdentityGovernanceService method getConfigPreference.
/**
* Get governance connector properties according to the search attribute.
*
* @param preferenceSearchAttribute Governance connector details.
* @return Governance connector properties for the given connector or properties.
*/
public List<PreferenceResp> getConfigPreference(List<PreferenceSearchAttribute> preferenceSearchAttribute) {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
List<PreferenceResp> preferenceRespList = new ArrayList<>();
for (PreferenceSearchAttribute prefSearchAttr : preferenceSearchAttribute) {
String connectorName = prefSearchAttr.getConnectorName();
List<String> expectedProperties = prefSearchAttr.getProperties();
Property[] properties;
try {
ConnectorConfig connectorConfig = identityGovernanceService.getConnectorWithConfigs(tenantDomain, connectorName);
if (connectorConfig == null) {
throw handleBadRequestError(GovernanceConstants.ErrorMessage.ERROR_CODE_INCORRECT_CONNECTOR_NAME, connectorName);
}
properties = connectorConfig.getProperties();
PreferenceResp preferenceResp = buildPreferenceRespDTO(connectorName, properties, expectedProperties);
preferenceRespList.add(preferenceResp);
} catch (IdentityGovernanceException e) {
GovernanceConstants.ErrorMessage errorEnum = GovernanceConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_CONNECTOR_PREFERENCES;
Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
throw handleException(e, errorEnum, status);
}
}
return preferenceRespList;
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp in project product-is by wso2.
the class IdentityGovernanceSuccessTest method init.
@BeforeClass(alwaysRun = true)
public void init() throws IOException {
super.testInit(API_VERSION, swaggerDefinition, tenant);
String expectedResponse = readResource("get-categories-response.json");
ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
List<CategoriesRes> categoryList = Arrays.asList(jsonWriter.readValue(expectedResponse, CategoriesRes[].class));
categories = categoryList.stream().collect(Collectors.toMap(CategoriesRes::getId, c -> c));
String expectedResponseForConnectors = readResource("get-connector-properties-response.json");
ObjectMapper objectMapper = new ObjectMapper(new JsonFactory());
connectors = Arrays.asList(objectMapper.readValue(expectedResponseForConnectors, PreferenceResp[].class));
String expectedResponseForConnectorsWithoutProperty = readResource("get-properties-without-property-name-response.json");
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
connectorsWithAllProperties = Arrays.asList(mapper.readValue(expectedResponseForConnectorsWithoutProperty, PreferenceResp[].class));
}
use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp 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