diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java new file mode 100644 index 00000000000..3df117c7511 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java @@ -0,0 +1,315 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.entitlement; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.client.WebClient; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO; +import org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient; +import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.common.utils.ISIntegrationTest; + +import java.io.File; +import java.io.IOException; +import java.net.SocketOutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Scanner; +import java.util.Set; + +/** + * This is to test the full flow of XACML Multi Decision Profile scenario + */ +public class EntitlementJSONSupportMultiDecisionProfileTestCase extends ISIntegrationTest { + + private static final Log log = LogFactory.getLog(EntitlementJSONSupportMultiDecisionProfileTestCase.class); + private EntitlementPolicyServiceClient entitlementPolicyClient; + private RemoteUserStoreManagerServiceClient remoteUserStoreManagerServiceClient; + private final static String ENDPOINT_ADDRESS = "https://localhost:9853/api/identity/entitlement/decision"; + private final static String PASSWORD = "abc123"; + private final static String ROLE = "admin"; + + + private static final String POLICY_ID = "urn:oasis:names:tc:xacml:3.0:web-filter-policy"; + private static final String POLICY = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " index.jsp\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " publicUser\n" + + " " + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " view-welcome\n" + + " view-summary\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " internalUser\n" + + " " + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " view-status\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " adminUser\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " modify-welcome\n" + + " modify-summary\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " You can access the" + + " resource index.jsp\n" + + " \n" + + " \n" + + " \n" + + " "; + + @BeforeClass(alwaysRun = true) + public void testInit() throws Exception { + super.init(); + entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie); + remoteUserStoreManagerServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); + PolicyDTO policy = new PolicyDTO(); + policy.setPolicy(POLICY); + entitlementPolicyClient.addPolicy(policy); + entitlementPolicyClient.publishPolicies(new String[]{POLICY_ID}, new String[]{"PDP Subscriber"}, "CREATE", + true, null, 1); + remoteUserStoreManagerServiceClient.addUser("adminUser",PASSWORD, new String[]{ROLE}, null, + "adminUser",false); + remoteUserStoreManagerServiceClient.addUser("publicUser",PASSWORD, new String[]{ROLE}, null, + "publicUser",false); + remoteUserStoreManagerServiceClient.addUser("localUser",PASSWORD, new String[]{ROLE}, null, + "localUser",false); + } + + @Test(groups = "wso2-is", description = "A simple JSON request sample") + public void testPdpJSONSimpleRequest() throws JSONException { + + WebClient client = WebClient.create(ENDPOINT_ADDRESS); + + client.header("Authorization", "Basic YWRtaW46YWRtaW4="); + client.type("application/json"); + client.accept("application/json"); + + client.path("pdp"); + + String request = readReource("entitlement/json/simpleRequest.json"); + String response = readReource("entitlement/json/simpleResponse.json"); + JSONObject objExpected = new JSONObject(response); + + String webRespose = client.post(request, String.class); + JSONObject objReturn = new JSONObject(webRespose); + Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" + + " the response is :" + webRespose); + } + + @Test(groups = "wso2-is", description = "A complex multi-decision JSON request sample") + public void testPdpJSONMultiDecisionRequest() throws JSONException { + + WebClient client = WebClient.create(ENDPOINT_ADDRESS); + + client.header("Authorization", "Basic YWRtaW46YWRtaW4="); + client.type("application/json"); + client.accept("application/json"); + + client.path("pdp"); + + String request = readReource("entitlement/json/complexMDPRequest.json"); + String response = readReource("entitlement/json/complexMDPResponse.json"); + JSONObject objExpected = new JSONObject(response); + + String webRespose = client.post(request, String.class); + JSONObject objReturn = new JSONObject(webRespose); + Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" + + " the response is :" + webRespose); + + } + + @Test(groups = "wso2-is", description = "A complex multi-decision JSON request sample in simple form") + public void testPdpJSONMultiDecisionRequestSimpleForm() throws JSONException { + + WebClient client = WebClient.create(ENDPOINT_ADDRESS); + + client.header("Authorization", "Basic YWRtaW46YWRtaW4="); + client.type("application/json"); + client.accept("application/json"); + + client.path("pdp"); + + String request = readReource("entitlement/json/simpleMDPRequest.json"); + String response = readReource("entitlement/json/simpleMDPResponse.json"); + JSONObject objExpected = new JSONObject(response); + + String webRespose = client.post(request, String.class); + JSONObject objReturn = new JSONObject(webRespose); + Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" + + " the response is :" + webRespose); + } + + @AfterClass(alwaysRun = true) + public void destroy() throws Exception { + + // Remove added policy + entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie); + remoteUserStoreManagerServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); + entitlementPolicyClient.enableDisablePolicy(POLICY_ID, false); + entitlementPolicyClient.removePolicy(POLICY_ID); + remoteUserStoreManagerServiceClient.deleteUser("adminUser"); + remoteUserStoreManagerServiceClient.deleteUser("publicUser"); + remoteUserStoreManagerServiceClient.deleteUser("localUser"); + } + + public static boolean areJSONObjectsEqual(Object ob1, Object ob2) throws JSONException { + + Object obj1Converted = convertJsonElement(ob1); + Object obj2Converted = convertJsonElement(ob2); + return obj1Converted.equals(obj2Converted); + } + + private static Object convertJsonElement(Object elem) throws JSONException { + + if (elem instanceof JSONObject) { + JSONObject obj = (JSONObject) elem; + Iterator keys = obj.keys(); + Map jsonMap = new HashMap<>(); + while (keys.hasNext()) { + String key = keys.next(); + jsonMap.put(key, convertJsonElement(obj.get(key))); + } + return jsonMap; + } else if (elem instanceof JSONArray) { + JSONArray arr = (JSONArray) elem; + Set jsonSet = new HashSet<>(); + for (int i = 0; i < arr.length(); i++) { + jsonSet.add(convertJsonElement(arr.get(i))); + } + return jsonSet; + } else { + return elem; + } + } + + private String readReource(String path) { + + StringBuilder result = new StringBuilder(); + Scanner scanner = null; + try { + //Get file from resources folder + ClassLoader classLoader = getClass().getClassLoader(); + URI filepath = new URI(classLoader.getResource(path).toString()); + + File file = new File(filepath); + + scanner = new Scanner(file); + + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + result.append(line).append("\n"); + } + + } catch (IOException e) { + log.error("Error occured when reading the file.", e); + } catch (URISyntaxException e) { + log.error("URI syntax error.", e); + } finally { + scanner.close(); + } + return result.toString().replaceAll("\\n\\r|\\n|\\r|\\t|\\s{2,}", "").replaceAll(": ", ":"); + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPRequest.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPRequest.json new file mode 100644 index 00000000000..8fa5397be6a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPRequest.json @@ -0,0 +1,68 @@ +{ + "Request": { + "http://wso2.org/identity/user": [ + { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": true, + "DataType": "string" + } + ] + },{ + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "publicUser", + "IncludeInResult": true, + "DataType": "string" + } + ] + } ], + + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": true, + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": [{ + "Attribute": [{ + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": true, + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + },{ + "Attribute": [{ + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-status", + "IncludeInResult": true, + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + },{ + "Attribute": [{ + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-summary", + "IncludeInResult": true, + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + },{ + "Attribute": [{ + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "modify-welcome", + "IncludeInResult": true, + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } ] + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPResponse.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPResponse.json new file mode 100644 index 00000000000..13aa99d0afd --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/complexMDPResponse.json @@ -0,0 +1,368 @@ +{ + "Response": [ + { + "Decision": "Permit", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-summary", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "publicUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Permit", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "modify-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-status", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Permit", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "publicUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-summary", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "publicUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-status", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "modify-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "publicUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + } + ] +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPRequest.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPRequest.json new file mode 100644 index 00000000000..d690d4a7f72 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPRequest.json @@ -0,0 +1,63 @@ +{ + "Request": { + "http://wso2.org/identity/user": [ + { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": true, + "DataType": "string" + } + ] + },{ + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "internalUser", + "IncludeInResult": true, + "DataType": "string" + } + ] + } ], + + "Resource": { + "Attribute": [ + { + "AttributeId": "resource-id", + "Value": "index.jsp", + "IncludeInResult": false + } + ] + }, + "Action": [{ + "Attribute": [{ + "AttributeId": "action-id", + "Value": "view-welcome", + "IncludeInResult": true + } + ] + },{ + "Attribute": [{ + "AttributeId": "action-id", + "Value": "view-status", + "IncludeInResult": false + } + ] + },{ + "Attribute": [{ + "AttributeId": "action-id", + "Value": "view-summary", + "IncludeInResult": true + } + ] + },{ + "Attribute": [{ + "AttributeId": "action-id", + "Value": "modify-welcome", + "IncludeInResult": true + } + ] + } ] + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPResponse.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPResponse.json new file mode 100644 index 00000000000..9c5072a2c7f --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleMDPResponse.json @@ -0,0 +1,280 @@ +{ + "Response": [ + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "internalUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Permit", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "internalUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-summary", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-summary", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "internalUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "internalUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "modify-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Permit", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "modify-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + }, + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + } + ] +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleRequest.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleRequest.json new file mode 100644 index 00000000000..6f42054a9a2 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleRequest.json @@ -0,0 +1,35 @@ +{ + "Request": { + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "DataType": "string", + "IncludeInResult": true + } + ] + }, + + "Resource": { + "Attribute": [ + { + "AttributeId": "resource-id", + "Value": "index.jsp", + "DataType": "string", + "IncludeInResult": true + } + ] + }, + "Action": { + "Attribute": [{ + "AttributeId": "action-id", + "Value": "view-welcome", + "DataType": "string", + "IncludeInResult": true + } + ] + } + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleResponse.json b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleResponse.json new file mode 100644 index 00000000000..b007152e9b1 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/entitlement/json/simpleResponse.json @@ -0,0 +1,54 @@ +{ + "Response": [ + { + "Decision": "Deny", + "Status": { + "StatusCode": { + "Value": "urn:oasis:names:tc:xacml:1.0:status:ok" + } + }, + "Obligations": [ + { + "Id": "fail_to_permit", + "AttributeAssignments": [ + { + "AttributeId": "obligation-id", + "Value": "You can access the resource index.jsp", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://wso2.org/identity/user": { + "Attribute": [ + { + "AttributeId": "http://wso2.org/identity/user/username", + "Value": "adminUser", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Action": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id", + "Value": "view-welcome", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + }, + "Resource": { + "Attribute": [ + { + "AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id", + "Value": "index.jsp", + "IncludeInResult": "true", + "DataType": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + } + ] +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml index e690950e16a..7f2e0d83ad7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml @@ -223,4 +223,9 @@ - \ No newline at end of file + + + + + + diff --git a/pom.xml b/pom.xml index 6df6e99eb73..e89b888f81d 100755 --- a/pom.xml +++ b/pom.xml @@ -1628,7 +1628,7 @@ - 5.11.152 + 5.11.153 [5.11.0, 6.0.0]