summaryrefslogtreecommitdiffstats
path: root/tutorials/tutorial-xacml-application
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-01-03 15:00:40 +0000
committeradheli.tavares <adheli.tavares@est.tech>2024-01-18 10:42:28 +0000
commit2e7b3c77cf6f7bf68233368bce17edb598daedc8 (patch)
treec6915325f1ba9705b3072f950b2d5c7b543a570d /tutorials/tutorial-xacml-application
parentef722a6ef6a64b69bf152c0187992f0ee91a2682 (diff)
Support for kafka within xacml tutorial
Issue-ID: POLICY-4202 Change-Id: I7bb47dce25d7613221a13f8437030f02a978770d Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'tutorials/tutorial-xacml-application')
-rw-r--r--tutorials/tutorial-xacml-application/postman/PolicyApplicationTutorial.postman_collection.json74
-rw-r--r--tutorials/tutorial-xacml-application/src/main/docker/README.md30
-rw-r--r--tutorials/tutorial-xacml-application/src/main/docker/docker-compose.yml4
-rwxr-xr-xtutorials/tutorial-xacml-application/src/main/docker/run-tutorial.sh6
-rw-r--r--tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java7
5 files changed, 38 insertions, 83 deletions
diff --git a/tutorials/tutorial-xacml-application/postman/PolicyApplicationTutorial.postman_collection.json b/tutorials/tutorial-xacml-application/postman/PolicyApplicationTutorial.postman_collection.json
index dbb1e0d1..3f94ac6f 100644
--- a/tutorials/tutorial-xacml-application/postman/PolicyApplicationTutorial.postman_collection.json
+++ b/tutorials/tutorial-xacml-application/postman/PolicyApplicationTutorial.postman_collection.json
@@ -19,7 +19,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -66,7 +66,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -122,7 +122,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -182,7 +182,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -229,7 +229,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -276,7 +276,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -332,7 +332,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -382,7 +382,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -436,7 +436,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -476,54 +476,6 @@
]
},
{
- "name": "Dmaap Simulator - Policy Update Notification",
- "protocolProfileBehavior": {
- "disableBodyPruning": true
- },
- "request": {
- "auth": {
- "type": "noauth"
- },
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "url": {
- "raw": "{{DMAAP-URL}}/events/POLICY-NOTIFICATION/group/id?timeout=5000",
- "host": [
- "{{DMAAP-URL}}"
- ],
- "path": [
- "events",
- "POLICY-NOTIFICATION",
- "group",
- "id"
- ],
- "query": [
- {
- "key": "timeout",
- "value": "5000"
- }
- ]
- }
- },
- "response": [
- ]
- },
- {
"name": "Xacml Healthcheck",
"request": {
"auth": {
@@ -536,7 +488,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -583,7 +535,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -630,7 +582,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
@@ -681,7 +633,7 @@
},
{
"key": "username",
- "value": "healthcheck",
+ "value": "policyadmin",
"type": "string"
}
]
diff --git a/tutorials/tutorial-xacml-application/src/main/docker/README.md b/tutorials/tutorial-xacml-application/src/main/docker/README.md
index 05a87462..33c9166a 100644
--- a/tutorials/tutorial-xacml-application/src/main/docker/README.md
+++ b/tutorials/tutorial-xacml-application/src/main/docker/README.md
@@ -12,7 +12,7 @@
### Setting Up and Starting from policy/docker components
1. Clone ```https://git.onap.org/policy/docker/```
- 2. ```cd /docker/csit```
+ 2. ```cd /docker```
3. Run the following to set the containers location, project, branch, and version:
- ```export CONTAINER_LOCATION=nexus3.onap.org:10001/```
- ```export PROJECT=pap```
@@ -21,32 +21,34 @@
- ```get-versions.sh```
4. Run ```docker image ls```
- Take note of the REPOSITORY ```onap/policy/xacml-tutorial``` and its ```TAG```
- - This refers to the image from our mvn clean install from above
+ - This refers to the image from our `mvn clean install` from above
5. Edit ```docker-compose-all.sh```
- Replace xacml-pdp image with the format "REPOSITORY:TAG" as noted in Step 4
- - ex. image: ```onap/policy-xacml-tutorial:2.7.1-SNAPSHOT```
+ - ex. image: ```onap/policy-xacml-tutorial:3.1.1-SNAPSHOT```
### Running the Containers and Testing
-Run ```docker-compose -f docker-compose-all.yml up xacml-pdp```
+Run ```./compose/start-compose.sh xacml-pdp```
+### Triggering policy notification update
+
+Run python script ```kafka_producer.py``` under docker repository with topic name and message as parameters.
+i.e. ```python3 /docker/csit/resources/tests/kafka_producer.py POLICY-PDP-PAP "message"```
+(update "message" to the usual json body)
## Verification Example Calls
Verify that the components are accessible:
- 1. ```curl -X POST http://0.0.0.0:3904/events/POLICY-PDP-PAP```
- - Should return JSON similar to this: ```{"serverTimeMs":0,"count":0}```
-
- 2. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6969/policy/pdpx/v1/healthcheck'```
- - Should return JSON similar to this: ```{"name":"Policy Xacml PDP","url":"self","healthy":true,"code":200,"message":"alive"}```
+ 1. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6969/policy/pdpx/v1/healthcheck'```
+ - Should return JSON similar to this: ```{"name":"Policy Xacml PDP","url":"self","healthy":true,"code":200,"message":"alive"}```
- 3. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6767/policy/api/v1/healthcheck'```
- - Should return JSON similar to this: ```{"name": "Policy API","url": "policy-api","healthy": true,"code": 200,"message": "alive"}```
+ 2. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6767/policy/api/v1/healthcheck'```
+ - Should return JSON similar to this: ```{"name": "Policy API","url": "policy-api","healthy": true,"code": 200,"message": "alive"}```
- 4. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6868/policy/pap/v1/healthcheck'```
- - Should return JSON similar to this: ```{"name": "Policy PAP","url": "policy-pap","healthy": true,"code": 200,"message": "alive"}```
+ 3. ```curl -k -u 'healthcheck:zb!XztG34' 'https://0.0.0.0:6868/policy/pap/v1/healthcheck'```
+ - Should return JSON similar to this: ```{"name": "Policy PAP","url": "policy-pap","healthy": true,"code": 200,"message": "alive"}```
## POSTMAN Collection
-You can find the collection under ```/policy-xacml-pdp/tutorials-tutorial-xacml-application/postman/```
+You can find the collection under ```/policy-xacml-pdp/tutorials/tutorial-xacml-application/postman/```
diff --git a/tutorials/tutorial-xacml-application/src/main/docker/docker-compose.yml b/tutorials/tutorial-xacml-application/src/main/docker/docker-compose.yml
index 48d246be..296f115c 100644
--- a/tutorials/tutorial-xacml-application/src/main/docker/docker-compose.yml
+++ b/tutorials/tutorial-xacml-application/src/main/docker/docker-compose.yml
@@ -1,6 +1,6 @@
# ============LICENSE_START=======================================================
# Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
-# Modifications Copyright (C) 2022 Nordix Foundation.
+# Modifications Copyright (C) 2022, 2024 Nordix Foundation.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
version: '3'
services:
mariadb:
- image: ${CONTAINER_LOCATION}mariadb:${POLICY_MARIADB_VER}
+ image: nexus3.onap.org:10001/mariadb:${POLICY_MARIADB_VER}
container_name: mariadb
hostname: mariadb
command: [ '--lower-case-table-names=1', '--wait_timeout=28800' ]
diff --git a/tutorials/tutorial-xacml-application/src/main/docker/run-tutorial.sh b/tutorials/tutorial-xacml-application/src/main/docker/run-tutorial.sh
index 82750c41..7b2f31e2 100755
--- a/tutorials/tutorial-xacml-application/src/main/docker/run-tutorial.sh
+++ b/tutorials/tutorial-xacml-application/src/main/docker/run-tutorial.sh
@@ -1,7 +1,7 @@
#! /bin/bash
# ============LICENSE_START====================================================
-# Copyright 2022 Nordix Foundation.
+# Copyright 2022, 2024 Nordix Foundation.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ fi
echo "Looking up latest versions of Policy Framework images . . ."
GETVERS_SCRIPT=$(mktemp)
-curl -qL --silent "https://raw.githubusercontent.com/onap/policy-docker/master/csit/get-versions.sh" > "$GETVERS_SCRIPT"
+curl -qL --silent "https://raw.githubusercontent.com/onap/policy-docker/master/compose/get-versions.sh" > "$GETVERS_SCRIPT"
export GERRIT_BRANCH="master"
chmod +x "$GETVERS_SCRIPT"
source "$GETVERS_SCRIPT"
@@ -57,4 +57,4 @@ echo "Tutorial run completed"
echo "Cleaning up . . ."
rm "$GETVERS_SCRIPT"
-echo "Cleanup competed"
+echo "Cleanup completed"
diff --git a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
index b30dd943..2f8fb851 100644
--- a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
+++ b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +56,7 @@ public class TutorialTranslator extends StdBaseTranslator {
new IdentifierImpl(ToscaDictionary.ID_URN_ONAP, "tutorial-permission");
/**
- * Constructor will setup some defaults.
+ * Constructor will set up some defaults.
*/
public TutorialTranslator() {
//
@@ -71,7 +72,7 @@ public class TutorialTranslator extends StdBaseTranslator {
*/
@SuppressWarnings("unchecked")
@Override
- public PolicyType convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
+ public PolicyType convertPolicy(ToscaPolicy toscaPolicy) {
//
// Here is our policy with a version and default combining algo
//
@@ -102,7 +103,7 @@ public class TutorialTranslator extends StdBaseTranslator {
XACML3.ID_DATATYPE_STRING, ID_TUTORIAL_USER, XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
var anyOf = new AnyOfType();
//
- // Create AllOf (AND) of just Policy Id
+ // Create AllOf (AND) of just Policy ID
//
anyOf.getAllOf().add(ToscaPolicyTranslatorUtils.buildAllOf(matchAction, matchUser));
var target = new TargetType();