Search in sources :

Example 1 with PropertyRes

use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyRes in project product-is by wso2.

the class IdentityGovernanceSuccessTest method testGetGovernanceConnector.

@Test
public void testGetGovernanceConnector() throws IOException {
    for (Map.Entry<String, CategoriesRes> category : categories.entrySet()) {
        String expectedResponse = readResource("get-category-" + category.getKey() + "-response.json");
        ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
        List<ConnectorRes> connectorsList = jsonWriter.readValue(expectedResponse, CategoryRes.class).getConnectors();
        Map<String, ConnectorRes> connectors = connectorsList.stream().collect(Collectors.toMap(ConnectorRes::getId, c -> c));
        for (Map.Entry<String, ConnectorRes> connector : connectors.entrySet()) {
            Response response = getResponseOfGet(IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + category.getKey() + "/connectors/" + connector.getKey());
            ValidatableResponse validatableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
            validatableResponse.body("id", equalTo(connector.getKey())).body("name", equalTo(connector.getValue().getName())).body("category", equalTo(connector.getValue().getCategory())).body("friendlyName", equalTo(connector.getValue().getFriendlyName())).body("order", equalTo(connector.getValue().getOrder())).body("subCategory", equalTo(connector.getValue().getSubCategory()));
            Map<String, PropertyRes> properties = connector.getValue().getProperties().stream().collect(Collectors.toMap(PropertyRes::getName, c -> c));
            for (Map.Entry<String, PropertyRes> property : properties.entrySet()) {
                validatableResponse.body("properties.find{it.name == '" + property.getValue().getName() + "' }.displayName", equalTo(property.getValue().getDisplayName())).body("properties.find{it.name == '" + property.getValue().getName() + "' }.description", equalTo(property.getValue().getDescription()));
            }
        }
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) ValidatableResponse(io.restassured.response.ValidatableResponse) DataProvider(org.testng.annotations.DataProvider) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) HttpStatus(org.apache.http.HttpStatus) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) Map(java.util.Map) PreferenceResp(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PreferenceResp) ConnectorRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorRes) AfterClass(org.testng.annotations.AfterClass) Factory(org.testng.annotations.Factory) PropertyRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyRes) BeforeClass(org.testng.annotations.BeforeClass) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod) TestUserMode(org.wso2.carbon.automation.engine.context.TestUserMode) CategoryRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoryRes) PropertyReq(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) List(java.util.List) JsonFactory(com.fasterxml.jackson.core.JsonFactory) Response(io.restassured.response.Response) CategoriesRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoriesRes) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) RestAssured(io.restassured.RestAssured) ValidatableResponse(io.restassured.response.ValidatableResponse) JsonFactory(com.fasterxml.jackson.core.JsonFactory) CategoryRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoryRes) ValidatableResponse(io.restassured.response.ValidatableResponse) Response(io.restassured.response.Response) ConnectorRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorRes) CategoriesRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoriesRes) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PropertyRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyRes) Test(org.testng.annotations.Test)

Example 2 with PropertyRes

use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyRes in project product-is by wso2.

the class IdentityGovernanceSuccessTest method testGetGovernanceConnectorCategory.

@Test
public void testGetGovernanceConnectorCategory() throws IOException {
    for (Map.Entry<String, CategoriesRes> category : categories.entrySet()) {
        String expectedResponse = readResource("get-category-" + category.getKey() + "-response.json");
        ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
        List<ConnectorRes> connectorsList = jsonWriter.readValue(expectedResponse, CategoryRes.class).getConnectors();
        Map<String, ConnectorRes> connectors = connectorsList.stream().collect(Collectors.toMap(ConnectorRes::getId, c -> c));
        Response response = getResponseOfGet(IDENTITY_GOVERNANCE_ENDPOINT_URI + "/" + category.getKey());
        ValidatableResponse validatableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
        for (Map.Entry<String, ConnectorRes> connector : connectors.entrySet()) {
            validatableResponse.body("connectors.find{ it.id == '" + connector.getKey() + "' }.name", equalTo(connector.getValue().getName())).body("connectors.find{ it.id == '" + connector.getKey() + "' }.category", equalTo(connector.getValue().getCategory())).body("connectors.find{ it.id == '" + connector.getKey() + "' }.friendlyName", equalTo(connector.getValue().getFriendlyName())).body("connectors.find{ it.id == '" + connector.getKey() + "' }.order", equalTo(connector.getValue().getOrder())).body("connectors.find{ it.id == '" + connector.getKey() + "' }.subCategory", equalTo(connector.getValue().getSubCategory()));
            Map<String, PropertyRes> properties = connector.getValue().getProperties().stream().collect(Collectors.toMap(PropertyRes::getName, c -> c));
            for (Map.Entry<String, PropertyRes> property : properties.entrySet()) {
                validatableResponse.body("connectors.find{ it.id == '" + connector.getKey() + "' }.properties.find{it.name " + "== '" + property.getValue().getName() + "' }.displayName", equalTo(property.getValue().getDisplayName())).body("connectors.find{ it.id == '" + connector.getKey() + "' }.properties.find{it.name " + "== '" + property.getValue().getName() + "' }.description", equalTo(property.getValue().getDescription()));
            }
        }
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) ValidatableResponse(io.restassured.response.ValidatableResponse) DataProvider(org.testng.annotations.DataProvider) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) HttpStatus(org.apache.http.HttpStatus) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) Map(java.util.Map) PreferenceResp(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PreferenceResp) ConnectorRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorRes) AfterClass(org.testng.annotations.AfterClass) Factory(org.testng.annotations.Factory) PropertyRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyRes) BeforeClass(org.testng.annotations.BeforeClass) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod) TestUserMode(org.wso2.carbon.automation.engine.context.TestUserMode) CategoryRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoryRes) PropertyReq(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) List(java.util.List) JsonFactory(com.fasterxml.jackson.core.JsonFactory) Response(io.restassured.response.Response) CategoriesRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoriesRes) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) RestAssured(io.restassured.RestAssured) ValidatableResponse(io.restassured.response.ValidatableResponse) JsonFactory(com.fasterxml.jackson.core.JsonFactory) CategoryRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoryRes) ValidatableResponse(io.restassured.response.ValidatableResponse) Response(io.restassured.response.Response) ConnectorRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorRes) CategoriesRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.CategoriesRes) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PropertyRes(org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyRes) Test(org.testng.annotations.Test)

Example 3 with PropertyRes

use of org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyRes in project identity-api-server by wso2.

the class ServerIdentityGovernanceService method buildConnectorResDTO.

private ConnectorRes buildConnectorResDTO(ConnectorConfig connectorConfig) {
    ConnectorRes connectorsResDTO = new ConnectorRes();
    connectorsResDTO.setId(Base64.getUrlEncoder().withoutPadding().encodeToString(connectorConfig.getName().getBytes(StandardCharsets.UTF_8)));
    connectorsResDTO.setName(connectorConfig.getName());
    connectorsResDTO.setFriendlyName(connectorConfig.getFriendlyName());
    connectorsResDTO.setCategory(connectorConfig.getCategory());
    connectorsResDTO.setSubCategory(connectorConfig.getSubCategory());
    connectorsResDTO.setOrder(connectorConfig.getOrder());
    List<PropertyRes> properties = new ArrayList<>();
    for (Property property : connectorConfig.getProperties()) {
        PropertyRes propertyRes = new PropertyRes();
        propertyRes.setName(property.getName());
        propertyRes.setValue(property.getValue());
        propertyRes.setDisplayName(property.getDisplayName());
        propertyRes.setDescription(property.getDescription() != null ? property.getDescription() : "");
        MetaRes metaRes = new MetaRes();
        metaRes.setType(property.getType());
        metaRes.setRegex(property.getRegex());
        metaRes.setGroupID(property.getGroupId());
        propertyRes.setMeta(metaRes);
        properties.add(propertyRes);
    }
    connectorsResDTO.setProperties(properties);
    return connectorsResDTO;
}
Also used : ConnectorRes(org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorRes) MetaRes(org.wso2.carbon.identity.api.server.identity.governance.v1.model.MetaRes) ArrayList(java.util.ArrayList) Property(org.wso2.carbon.identity.application.common.model.Property) PropertyRes(org.wso2.carbon.identity.api.server.identity.governance.v1.model.PropertyRes)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RestAssured (io.restassured.RestAssured)2 Response (io.restassured.response.Response)2 ValidatableResponse (io.restassured.response.ValidatableResponse)2 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang.StringUtils)2 HttpStatus (org.apache.http.HttpStatus)2 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)2 IsNull.notNullValue (org.hamcrest.core.IsNull.notNullValue)2 AfterClass (org.testng.annotations.AfterClass)2 AfterMethod (org.testng.annotations.AfterMethod)2 BeforeClass (org.testng.annotations.BeforeClass)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 DataProvider (org.testng.annotations.DataProvider)2 Factory (org.testng.annotations.Factory)2