Search in sources :

Example 26 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method getIdPsSearchWithAttributesExceptionData.

@DataProvider
public Object[][] getIdPsSearchWithAttributesExceptionData() {
    ExpressionNode en = new ExpressionNode();
    List<ExpressionNode> expressionNodes = new ArrayList<>();
    expressionNodes.add(en);
    List<String> attributes = Arrays.asList("WrongAttribute");
    return new Object[][] { { SAMPLE_TENANT_ID, expressionNodes, 2, 0, "ASC", "NAME", attributes } };
}
Also used : ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) ArrayList(java.util.ArrayList) DataProvider(org.testng.annotations.DataProvider)

Example 27 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method getIdPsSearchWithAttributesData.

@DataProvider
public Object[][] getIdPsSearchWithAttributesData() {
    ExpressionNode expressionNode = new ExpressionNode();
    List<ExpressionNode> expressionNodesList = new ArrayList<>();
    expressionNodesList.add(expressionNode);
    List<String> attributes1 = Arrays.asList("id", "name", "description", "isEnabled", "image", "isPrimary");
    List<String> attributes2 = Arrays.asList("homeRealmIdentifier", "isFederationHub", "certificate", "alias", "claims", "roles", "federatedAuthenticators", "provisioning");
    return new Object[][] { { SAMPLE_TENANT_ID, expressionNodesList, 2, 0, "ASC", "NAME", attributes1, 2 }, { SAMPLE_TENANT_ID, expressionNodesList, 1, 1, "ASC", "NAME", attributes2, 1 }, { SAMPLE_TENANT_ID, expressionNodesList, 2, 0, "DESC", "NAME", attributes1, 2 } };
}
Also used : ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) ArrayList(java.util.ArrayList) DataProvider(org.testng.annotations.DataProvider)

Example 28 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method testGetIdPsSearchWithExpressionNodes.

@Test(dataProvider = "getIdPsSearchWithExpressionNodesData")
public void testGetIdPsSearchWithExpressionNodes(int tenantId, List<ExpressionNode> expressionNodes, int limit, int offset, String sortOrder, String sortBy, int count, String firstIdp) throws Exception {
    mockStatic(IdentityDatabaseUtil.class);
    try (Connection connection = getConnection(DB_NAME)) {
        when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection);
        when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection);
        when(IdentityDatabaseUtil.getDataSource()).thenReturn(dataSourceMap.get(DB_NAME));
        addTestIdps();
        List<IdentityProvider> idps = idPManagementDAO.getIdPsSearch(tenantId, expressionNodes, limit, offset, sortOrder, sortBy);
        assertEquals(idps.size(), count);
        if (count > 0) {
            assertEquals(idps.get(0).getIdentityProviderName(), firstIdp);
        }
    }
}
Also used : Connection(java.sql.Connection) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 29 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project carbon-identity-framework by wso2.

the class IdPManagementDAOTest method getCountOfFilteredIdPsData.

@DataProvider
public Object[][] getCountOfFilteredIdPsData() {
    ExpressionNode expressionNode1 = new ExpressionNode();
    List<ExpressionNode> expressionNodesList1 = new ArrayList<>();
    expressionNodesList1.add(expressionNode1);
    ExpressionNode expressionNode2 = new ExpressionNode();
    expressionNode2.setAttributeValue("name");
    expressionNode2.setOperation("sw");
    expressionNode2.setValue("test");
    List<ExpressionNode> expressionNodesList2 = new ArrayList<>();
    expressionNodesList2.add(expressionNode2);
    return new Object[][] { { SAMPLE_TENANT_ID, expressionNodesList1, 2 }, { SAMPLE_TENANT_ID, expressionNodesList2, 2 }, { SAMPLE_TENANT_ID2, expressionNodesList1, 1 } };
}
Also used : ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) ArrayList(java.util.ArrayList) DataProvider(org.testng.annotations.DataProvider)

Example 30 with ExpressionNode

use of org.wso2.carbon.identity.core.model.ExpressionNode in project carbon-identity-framework by wso2.

the class FilterTreeBuilder method factor.

/**
 * We build the parser using the recursive descent parser technique.
 */
private void factor() throws IdentityException {
    symbol = nextSymbol();
    if (symbol.equals(String.valueOf(IdentityCoreConstants.Filter.NOT))) {
        OperationNode not = new OperationNode(IdentityCoreConstants.Filter.NOT);
        factor();
        not.setRightNode(root);
        root = not;
    } else if (symbol.equals(String.valueOf("("))) {
        expression();
        // We don't care about ')'.
        symbol = nextSymbol();
    } else {
        if (!(symbol.equals(String.valueOf(")")))) {
            ExpressionNode expressionNode = new ExpressionNode();
            validateAndBuildFilterExpression(symbol, expressionNode);
            root = expressionNode;
            symbol = nextSymbol();
        } else {
            throw new IdentityException("Invalid argument: Identity Provider filter name value is empty or " + "invalid symbol: " + symbol);
        }
    }
}
Also used : IdentityException(org.wso2.carbon.identity.base.IdentityException)

Aggregations

ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)21 ArrayList (java.util.ArrayList)16 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)16 ExpressionNode (org.wso2.carbon.identity.core.model.ExpressionNode)15 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)12 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)8 ExpressionNode (org.wso2.charon3.core.utils.codeutils.ExpressionNode)7 Map (java.util.Map)6 IdentityException (org.wso2.carbon.identity.base.IdentityException)6 Attribute (org.wso2.charon3.core.attributes.Attribute)6 ComplexAttribute (org.wso2.charon3.core.attributes.ComplexAttribute)6 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)6 SimpleAttribute (org.wso2.charon3.core.attributes.SimpleAttribute)6 Connection (java.sql.Connection)5 KubernetesPluginException (org.ballerinax.kubernetes.exceptions.KubernetesPluginException)5 JSONObject (org.json.JSONObject)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Test (org.testng.annotations.Test)5 Node (org.wso2.carbon.identity.core.model.Node)5 IdpSearchResult (org.wso2.carbon.idp.mgt.model.IdpSearchResult)5