Search in sources :

Example 1 with PropertyReq

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++;
        }
    }
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) Response(io.restassured.response.Response) PreferenceResp(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PreferenceResp) ValidatableResponse(io.restassured.response.ValidatableResponse) PropertyReq(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq) Test(org.testng.annotations.Test)

Example 2 with 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 createPropertyRequest.

private void createPropertyRequest(List<PropertyReq> propertyReqList, Property property) {
    PropertyReq propertyReq = new PropertyReq();
    propertyReq.setName(property.getName());
    propertyReq.setValue(property.getValue());
    propertyReqList.add(propertyReq);
}
Also used : PropertyReq(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq)

Example 3 with 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);
    }
}
Also used : ConnectorRes(org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorRes) HashMap(java.util.HashMap) IdentityGovernanceService(org.wso2.carbon.identity.governance.IdentityGovernanceService) PropertyReq(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq) IdentityGovernanceException(org.wso2.carbon.identity.governance.IdentityGovernanceException)

Example 4 with 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 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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PropertyReq(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq) Property(org.wso2.carbon.identity.application.common.model.Property) IdentityGovernanceException(org.wso2.carbon.identity.governance.IdentityGovernanceException)

Example 5 with 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 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;
}
Also used : PreferenceResp(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp) PropertyReq(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq)

Aggregations

PropertyReq (org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyReq)4 HashMap (java.util.HashMap)2 IdentityGovernanceException (org.wso2.carbon.identity.governance.IdentityGovernanceException)2 Response (io.restassured.response.Response)1 ValidatableResponse (io.restassured.response.ValidatableResponse)1 ArrayList (java.util.ArrayList)1 Test (org.testng.annotations.Test)1 ConnectorRes (org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorRes)1 PreferenceResp (org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp)1 Property (org.wso2.carbon.identity.application.common.model.Property)1 IdentityGovernanceService (org.wso2.carbon.identity.governance.IdentityGovernanceService)1 PreferenceResp (org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PreferenceResp)1 PropertyReq (org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq)1