From ad9f3334d908cce1d4c3c0f0d71a64f7ab6e6084 Mon Sep 17 00:00:00 2001 From: sebdet Date: Sun, 24 Jan 2021 16:40:18 +0100 Subject: Add new Camel route Add the new rest endpoint in camel + add new permission type + add robot test for that route + small refactoring of trst files Issue-ID: POLICY-2924 Signed-off-by: sebdet Change-Id: I623cc8ec1724513cdb92eeea000adca5c2433bae (cherry picked from commit 9d04a9cc8c6f4b12ae60cc0d4d42f71085f72328) --- .../org/onap/policy/clamp/clds/ClampServlet.java | 13 +- src/main/resources/META-INF/resources/swagger.html | 269 +- src/main/resources/application-noaaf.properties | 3 +- src/main/resources/application.properties | 3 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 2592 ++++++++++---------- src/main/resources/clds/clds-users.json | 63 +- .../org/onap/policy/clamp/clds/it/RobotItCase.java | 11 +- .../policy/pdpgroup/PoliciesPdpMergerTest.java | 4 +- src/test/resources/application.properties | 16 +- .../resources/example/policy/policy-merger.json | 215 ++ src/test/resources/https/https-test.properties | 3 +- .../robotframework/robotframework-test.properties | 15 +- .../robotframework/tests/02_policy_queries.robot | 21 + 13 files changed, 1788 insertions(+), 1440 deletions(-) create mode 100644 src/test/resources/example/policy/policy-merger.json create mode 100644 src/test/resources/robotframework/tests/02_policy_queries.robot (limited to 'src') diff --git a/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java b/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java index 801f59c31..5149dd3b7 100644 --- a/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java +++ b/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights + * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung @@ -62,6 +62,7 @@ public class ClampServlet extends CamelHttpTransportServlet { private static final String PERM_VF = "clamp.config.security.permission.type.filter.vf"; private static final String PERM_MANAGE = "clamp.config.security.permission.type.cl.manage"; private static final String PERM_TOSCA = "clamp.config.security.permission.type.tosca"; + private static final String PERM_POLICIES = "clamp.config.security.permission.type.policies"; private static final String AUTHENTICATION_CLASS = "clamp.config.security.authentication.class"; private static final String READ = "read"; private static final String UPDATE = "update"; @@ -95,8 +96,14 @@ public class ClampServlet extends CamelHttpTransportServlet { permissionList.add(SecureServicePermission .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, READ)); permissionList.add(SecureServicePermission - .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), - cldsPermissionInstance, UPDATE)); + .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, + UPDATE)); + permissionList.add(SecureServicePermission + .create(applicationContext.getEnvironment().getProperty(PERM_POLICIES), cldsPermissionInstance, + READ)); + permissionList.add(SecureServicePermission + .create(applicationContext.getEnvironment().getProperty(PERM_POLICIES), cldsPermissionInstance, + UPDATE)); } return permissionList; } diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html index ab1d4fa1a..6712ab096 100644 --- a/src/main/resources/META-INF/resources/swagger.html +++ b/src/main/resources/META-INF/resources/swagger.html @@ -444,31 +444,31 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • 2. Paths @@ -723,13 +729,13 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    1.1. Version information

    -

    Version : 5.1.5-SNAPSHOT

    +

    Version : 6.0.0-SNAPSHOT

    1.2. URI scheme

    -

    Host : localhost:38837
    +

    Host : localhost:40283
    BasePath : /restservices/clds/
    Schemes : HTTP

    @@ -740,7 +746,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    2. Paths

    -

    2.1. GET /v1/healthcheck

    +

    2.1. GET /v1/healthcheck

    2.1.1. Responses

    @@ -777,7 +783,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -811,7 +817,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -848,7 +854,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -885,7 +891,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -957,7 +963,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -994,7 +1000,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1056,7 +1062,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1134,7 +1140,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1193,7 +1199,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1258,7 +1264,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1332,7 +1338,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1404,7 +1410,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1453,7 +1459,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1515,7 +1521,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1552,7 +1558,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1614,7 +1620,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1682,7 +1688,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1750,7 +1756,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1830,7 +1836,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1892,7 +1898,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1954,7 +1960,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2016,7 +2022,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2078,7 +2084,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2156,7 +2162,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2234,7 +2240,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2312,7 +2318,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -2374,9 +2380,46 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    +++++ + + + + + + + + + + + + + + +
    HTTP CodeDescriptionSchema

    200

    Output type

    string

    +
    +
    +

    2.28.2. Produces

    +
    +
      +
    • +

      application/json

      +
    • +
    +
    +
    +
    +
    +

    2.29. POST /v2/policyToscaModels

    +
    +

    2.29.1. Parameters

    @@ -2401,7 +2444,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.2. Responses

    +

    2.29.2. Responses

    @@ -2425,7 +2468,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.3. Consumes

    +

    2.29.3. Consumes

    • @@ -2435,7 +2478,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.4. Produces

    +

    2.29.4. Produces

    • @@ -2446,9 +2489,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.29. GET /v2/policyToscaModels

    +

    2.30. GET /v2/policyToscaModels

    -

    2.29.1. Responses

    +

    2.30.1. Responses

    @@ -2472,7 +2515,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.29.2. Produces

    +

    2.30.2. Produces

    • @@ -2483,9 +2526,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30. GET /v2/policyToscaModels/yaml/{policyModelType}/{policyModelVersion}

    +

    2.31. GET /v2/policyToscaModels/yaml/{policyModelType}/{policyModelVersion}

    -

    2.30.1. Parameters

    +

    2.31.1. Parameters

    @@ -2516,7 +2559,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30.2. Responses

    +

    2.31.2. Responses

    @@ -2540,7 +2583,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30.3. Produces

    +

    2.31.3. Produces

    • @@ -2551,9 +2594,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31. GET /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    +

    2.32. GET /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    -

    2.31.1. Parameters

    +

    2.32.1. Parameters

    @@ -2584,7 +2627,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31.2. Responses

    +

    2.32.2. Responses

    @@ -2608,7 +2651,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31.3. Produces

    +

    2.32.3. Produces

    • @@ -2619,9 +2662,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32. PUT /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    +

    2.33. PUT /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    -

    2.32.1. Parameters

    +

    2.33.1. Parameters

    @@ -2658,7 +2701,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.2. Responses

    +

    2.33.2. Responses

    @@ -2682,7 +2725,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.3. Consumes

    +

    2.33.3. Consumes

    • @@ -2692,7 +2735,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.4. Produces

    +

    2.33.4. Produces

    • @@ -2703,9 +2746,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.33. GET /v2/templates

    +

    2.34. GET /v2/templates

    -

    2.33.1. Responses

    +

    2.34.1. Responses

    @@ -2729,7 +2772,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.33.2. Produces

    +

    2.34.2. Produces

    • @@ -2740,9 +2783,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.34. GET /v2/templates/names

    +

    2.35. GET /v2/templates/names

    -

    2.34.1. Responses

    +

    2.35.1. Responses

    @@ -2766,7 +2809,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.34.2. Produces

    +

    2.35.2. Produces

    • @@ -2777,9 +2820,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35. GET /v2/templates/{templateName}

    +

    2.36. GET /v2/templates/{templateName}

    -

    2.35.1. Parameters

    +

    2.36.1. Parameters

    @@ -2804,7 +2847,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35.2. Responses

    +

    2.36.2. Responses

    @@ -2828,7 +2871,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35.3. Produces

    +

    2.36.3. Produces

    • diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index ba838adb8..f398f8d98 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2019,2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -171,6 +171,7 @@ clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf clamp.config.security.permission.type.template=org.onap.clamp.clds.template clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca +clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 7d2d4ef1b..97870d2b6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Modifications copyright (c) 2019 Nokia @@ -174,6 +174,7 @@ clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf clamp.config.security.permission.type.template=org.onap.clamp.clds.template clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca +clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index c43f3297d..011c24a9d 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -1,1322 +1,1368 @@ - - - - - - - - - - - java.lang.Exception - - true - - - + + + + + + + + + + + java.lang.Exception + + true + + + - - 500 - - - GET All Loop names FAILED - - - - - - - - - - - - - - - java.lang.Exception - - true - - - + + 500 + + + GET All Loop names FAILED + + + + + + + + + + + + + + + java.lang.Exception + + true + + + - - 500 - - - GET Loop FAILED - - - - - + + 500 + + + GET Loop FAILED + + + + + - - - - - - - - ${body} - - - - - - - java.lang.Exception - - true - - - + + + + + + + ${body} + + + + + + + java.lang.Exception + + true + + + - - 500 - - - UPDATE Global properties FAILED - - - - - - + 500 + + + UPDATE Global properties FAILED + + + + + + - - - - - - - ${body} - - - - - - - java.lang.Exception - - true - - - - + + + + + + + ${body} + + + + + + + java.lang.Exception + + true + + + + - - 500 - - - UPDATE Operational policies FAILED - - - - - - - - - - - - - ${body} - + + 500 + + + UPDATE Operational policies FAILED + + + + + + + + + + + + + ${body} + - - - - - - java.lang.Exception - - true - - - - - - 500 - - - UPDATE MicroService policy FAILED - - - - - - + + + + + java.lang.Exception + + true + + + + + + 500 + + + UPDATE MicroService policy FAILED + + + + + + - - - - - - true - - - - - + + + + + + true + + + + + - + - - - - - java.lang.Exception - - true - - - - - - 500 - - - DEPLOY request FAILED - - - - - - + + + + java.lang.Exception + + true + + + + + + 500 + + + DEPLOY request FAILED + + + + + + - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - REFRESH json schema request FAILED - - - - - - + + + + + + + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + REFRESH json schema request FAILED + + + + + + - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - REFRESH json schema request FAILED - - - - - - + + + + + + + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + REFRESH json schema request FAILED + + + + + + - - - - - - true - - - - - - + + + + + + true + + + + + + - - - - - java.lang.Exception - - true - - - - - - 500 - - - UNDEPLOY request FAILED - - - - - - + + + + java.lang.Exception + + true + + + + + + 500 + + + UNDEPLOY request FAILED + + + + + + - - - - - - true - - - - - + + + + + + true + + + + + - - - - - - java.lang.Exception - - true - - - - - - 500 - - - STOP request FAILED - - - - - - + + + + + java.lang.Exception + + true + + + + + + 500 + + + STOP request FAILED + + + + + + - - - - - - true - - - - + + + + + + true + + + + - + - - - - - - java.lang.Exception - - true - - - - - - 500 - - - RESTART request FAILED - - - - - - + + + + + java.lang.Exception + + true + + + + + + 500 + + + RESTART request FAILED + + + + + + - - - - - - true - - - - - - - false - - - - - ${exchangeProperty[loopObject].getMicroServicePolicies()} - - - ${body} - - - - false - - - - - - - ${exchangeProperty[loopObject].getOperationalPolicies()} - - - ${body} - - - - false - + + + + + + true + + + + + + + false + + + + + ${exchangeProperty[loopObject].getMicroServicePolicies()} + + + ${body} + + + + false + + + + + + + ${exchangeProperty[loopObject].getOperationalPolicies()} + + + ${body} + + + + false + - - - + + + - - 3000 - + + 3000 + - + - - - - - java.lang.Exception - - true - - - - - - 500 - - - SUBMIT request FAILED - - - - - - - - - - - - true - - - - - - - - - - ${exchangeProperty[loopObject].getMicroServicePolicies()} - - - ${body} - - - - false - - - - - - ${exchangeProperty[loopObject].getOperationalPolicies()} - - - ${body} - - - - false - - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - DELETE request FAILED - - - - - - + + + + java.lang.Exception + + true + + + + + + 500 + + + SUBMIT request FAILED + + + + + + + + + + + + true + + + + + + + + + + ${exchangeProperty[loopObject].getMicroServicePolicies()} + + + ${body} + + + + false + + + + + + ${exchangeProperty[loopObject].getOperationalPolicies()} + + + ${body} + + + + false + + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + DELETE request FAILED + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - java.lang.Exception - - true - - - - - - - - ${exchangeProperty[loopObject]} - - - 200 - - - - - + + + + java.lang.Exception + + true + + + + + + + + ${exchangeProperty[loopObject]} + + + 200 + + + + + + + + + + + + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + ADD Operational policy request FAILED for loop: ${header.loopName}, + ${exception.message}" + + - - - - - - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - ADD Operational policy request FAILED for loop: ${header.loopName}, ${exception.message}" - - - - - - - - - - - - - - - ${header.policyName} - - - ${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)} - - - false - - - - false - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - REMOVE Operational policy request FAILED - - - - - - + + + + + + + + + + + + ${header.policyName} + + + ${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)} + + + false + + + + false + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + REMOVE Operational policy request FAILED + + + + + + - - - - - - - - - java.lang.Exception - - true - - - - - - 500 - - - CREATE Loop from template FAILED - - - - - - + + + + + + + + java.lang.Exception + + true + + + + + + 500 + + + CREATE Loop from template FAILED + + + + + + - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Dictionary FAILED - - - - - + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Dictionary FAILED + + + + + - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Dictionary FAILED - - - - - - + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Dictionary FAILED + + + + + + - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Dictionary FAILED - - - - - - + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Dictionary FAILED + + + + + + - - - - - - ${body} - - - - - java.lang.Exception - - true - - - - - 500 - - - PUT Dictionary FAILED - - - - - + + + + + + ${body} + + + + + java.lang.Exception + + true + + + + + 500 + + + PUT Dictionary FAILED + + + + + - - - - - - - - ${body} - - - - - java.lang.Exception - - true - - - - - 500 - - - PUT Dictionary FAILED - - - - - + + + + + + + ${body} + + + + + java.lang.Exception + + true + + + + + 500 + + + PUT Dictionary FAILED + + + + + - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - DELETE Dictionary FAILED - - - - - + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + DELETE Dictionary FAILED + + + + + - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - DELETE Dictionary element FAILED - - - - - + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + DELETE Dictionary element FAILED + + + + + - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Policy models FAILED - - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Policy model FAILED - - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Policy model YAML FAILED - - - - - + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Policy models FAILED + + + + + + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Policy model FAILED + + + + + + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Policy model YAML FAILED + + + + + + + + + + + + + + ${body} + + + + + java.lang.Exception + + true + + + + + 500 + + + POST Policy model YAML FAILED + + + + + + + + + + + + + ${body} + + + + + java.lang.Exception + + true + + + + + 500 + + + MODIFY Policy model YAML FAILED + + + + + - - - - - - - - ${body} - - - - - java.lang.Exception - - true - - - - - 500 - - - POST Policy model YAML FAILED - - - - - - - - - - - - - ${body} - - - - - java.lang.Exception - - true - - - - - 500 - - - MODIFY Policy model YAML FAILED - - - - - + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET ALL templates FAILED + + + + + + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Template FAILED + + + + + + + + + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET All Template names FAILED + + + + + + + + + + + - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET ALL templates FAILED - - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET Template FAILED - - - - - - - - - - - - - - - java.lang.Exception - - true - - - - - 500 - - - GET All Template names FAILED - - - - - - - - - + + + ${body} + + + + ${body} + + + + + + + java.lang.Exception + + true + + + + + 500 + + + GET Policy model YAML FAILED + + + + + + + + + diff --git a/src/main/resources/clds/clds-users.json b/src/main/resources/clds/clds-users.json index fe305980b..5a7f43841 100644 --- a/src/main/resources/clds/clds-users.json +++ b/src/main/resources/clds/clds-users.json @@ -1,32 +1,33 @@ - [{ - "user":"admin", - "password":"$2a$10$H/e21kl04Dw9C978CHuM7OewyMGUN5WGzAAx7SgIaR4ix8.wTcssi", - "permissions": - [ - "org.onap.clamp.clds.cl|dev|read", - "org.onap.clamp.clds.cl|dev|update", - "org.onap.clamp.clds.cl.manage|dev|*", - "org.onap.clamp.clds.cl.event|dev|*", - "org.onap.clamp.clds.filter.vf|dev|*", - "org.onap.clamp.clds.template|dev|read", - "org.onap.clamp.clds.template|dev|update", - "org.onap.clamp.clds.tosca|dev|read", - "org.onap.clamp.clds.tosca|dev|update" - ] - }, - { - "user":"cs0008", - "password":"$2a$10$H/e21kl04Dw9C978CHuM7OewyMGUN5WGzAAx7SgIaR4ix8.wTcssi", - "permissions": - [ - "org.onap.clamp.clds.cl|dev|read", - "org.onap.clamp.clds.cl|dev|update", - "org.onap.clamp.clds.cl.manage|dev|*", - "org.onap.clamp.clds.filter.vf|dev|*", - "org.onap.clamp.clds.template|dev|read", - "org.onap.clamp.clds.template|dev|update", - "org.onap.clamp.clds.tosca|dev|read", - "org.onap.clamp.clds.tosca|dev|update" - ] - } +[ + { + "user": "admin", + "password": "$2a$10$H/e21kl04Dw9C978CHuM7OewyMGUN5WGzAAx7SgIaR4ix8.wTcssi", + "permissions": [ + "org.onap.clamp.clds.cl|dev|read", + "org.onap.clamp.clds.cl|dev|update", + "org.onap.clamp.clds.cl.manage|dev|*", + "org.onap.clamp.clds.cl.event|dev|*", + "org.onap.clamp.clds.filter.vf|dev|*", + "org.onap.clamp.clds.template|dev|read", + "org.onap.clamp.clds.template|dev|update", + "org.onap.clamp.clds.tosca|dev|read", + "org.onap.clamp.clds.tosca|dev|update", + "org.onap.clamp.clds.policies|dev|read", + "org.onap.clamp.clds.policies|dev|update" + ] + }, + { + "user": "cs0008", + "password": "$2a$10$H/e21kl04Dw9C978CHuM7OewyMGUN5WGzAAx7SgIaR4ix8.wTcssi", + "permissions": [ + "org.onap.clamp.clds.cl|dev|read", + "org.onap.clamp.clds.cl|dev|update", + "org.onap.clamp.clds.cl.manage|dev|*", + "org.onap.clamp.clds.filter.vf|dev|*", + "org.onap.clamp.clds.template|dev|read", + "org.onap.clamp.clds.template|dev|update", + "org.onap.clamp.clds.tosca|dev|read", + "org.onap.clamp.clds.tosca|dev|update" + ] + } ] diff --git a/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java index 8c06929e1..2f17c61bf 100644 --- a/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java +++ b/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,6 +23,8 @@ package org.onap.policy.clamp.clds.it; +import static org.apache.commons.io.FileUtils.copyInputStreamToFile; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.github.dockerjava.api.DockerClient; @@ -111,6 +113,13 @@ public class RobotItCase { } catch (InterruptedException e) { throw new Exception("Failed to retrieve logs of container " + id, e); } + + copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/output.xml").exec(), + new File("target/robotframework/output.xml")); + copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/log.html").exec(), + new File("target/robotframework/log.html")); + copyInputStreamToFile(client.copyArchiveFromContainerCmd(id, "/opt/robotframework/reports/report.html").exec(), + new File("target/robotframework/report.html")); client.stopContainerCmd(id); } } diff --git a/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java b/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java index b3fd3f19a..5da68f47f 100644 --- a/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java +++ b/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java @@ -94,8 +94,8 @@ public class PoliciesPdpMergerTest { @Test public void testUpdatePdpGroupOfPolicyModels() throws IOException { - JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("clds/policy-merger.json"), PoliciesPdpMerger - .mergePoliciesAndPdpGroupStates( + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("example/policy/policy-merger.json"), + PoliciesPdpMerger.mergePoliciesAndPdpGroupStates( ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policies/.file"), pdpGroupsJson), true); } diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 5a668dcf4..2a4caee98 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -152,15 +152,17 @@ clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! -clamp.config.security.permission.type.cl=permission-type-cl -clamp.config.security.permission.type.cl.manage=permission-type-cl-manage -clamp.config.security.permission.type.cl.event=permission-type-cl-event -clamp.config.security.permission.type.filter.vf=permission-type-filter-vf -clamp.config.security.permission.type.template=permission-type-template -clamp.config.security.permission.type.tosca=permission-type-tosca +clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl +clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage +clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event +clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf +clamp.config.security.permission.type.template=org.onap.clamp.clds.template +clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca +clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal + # Configuration settings for CDS clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host} clamp.config.cds.userName=ccsdkapps diff --git a/src/test/resources/example/policy/policy-merger.json b/src/test/resources/example/policy/policy-merger.json new file mode 100644 index 000000000..5c6bd5b6b --- /dev/null +++ b/src/test/resources/example/policy/policy-merger.json @@ -0,0 +1,215 @@ +{ + "policies": [ + { + "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0": { + "type": "onap.policies.monitoring.tcagen2", + "type_version": "1.0.0", + "properties": { + "tca.policy": { + "domain": "measurementsForVfScaling", + "metricsPerEventName": [ + { + "policyScope": "DCAE", + "thresholds": [ + { + "version": "1.0.2", + "severity": "MAJOR", + "thresholdValue": 200, + "closedLoopEventStatus": "ONSET", + "closedLoopControlName": "LOOP_test", + "direction": "LESS_OR_EQUAL", + "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta" + } + ], + "eventName": "vLoadBalancer", + "policyVersion": "v0.0.1", + "controlLoopSchemaType": "VM", + "policyName": "DCAE.Config_tca-hi-lo" + } + ] + } + }, + "name": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0", + "version": "1.0.0", + "metadata": { + "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0", + "policy-version": "1.0.0" + }, + "pdpGroupInfo": { + "pdpGroup": "pdpGroup2", + "pdpSubGroup": "subGroup2" + }, + "supportedPdpGroups": [ + { + "pdpGroup2": [ + "subGroup2", + "subGroup3" + ] + } + ] + } + }, + { + "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd": { + "type": "onap.policies.controlloop.operational.common.Drools", + "type_version": "1.0.0", + "properties": { + "abatement": false, + "operations": [ + { + "failure_retries": "final_failure_retries", + "id": "test1", + "failure_timeout": "final_failure_timeout", + "failure": "final_failure", + "operation": { + "payload": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": "{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}}" + }, + "target": { + "entityIds": { + "resourceID": "Vloadbalancerms..vdns..module-3", + "modelInvariantId": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "modelVersionId": "4fa73b49-8a6c-493e-816b-eb401567b720", + "modelName": "Vloadbalancerms..vdns..module-3", + "modelVersion": "1", + "modelCustomizationId": "bafcdab0-801d-4d81-9ead-f464640a38b1" + }, + "targetType": "VNF" + }, + "actor": "SDNR", + "operation": "BandwidthOnDemand" + }, + "failure_guard": "final_failure_guard", + "retries": 0, + "timeout": 0, + "failure_exception": "final_failure_exception", + "description": "test", + "success": "final_success" + } + ], + "trigger": "test1", + "timeout": 0, + "id": "LOOP_test" + }, + "name": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd", + "version": "1.0.0", + "metadata": { + "policy-id": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd", + "policy-version": "1.0.0" + }, + "pdpGroupInfo": { + "pdpGroup": "pdpGroup2", + "pdpSubGroup": "subGroup3" + }, + "supportedPdpGroups": [ + { + "pdpGroup2": [ + "subGroup2", + "subGroup3" + ] + } + ] + } + }, + { + "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP": { + "type": "onap.policies.Naming", + "type_version": "1.0.0", + "properties": { + "naming-models": [ + { + "naming-type": "VNF", + "naming-recipe": "AIC_CLOUD_REGION|DELIMITER|CONSTANT|DELIMITER|TIMESTAMP", + "name-operation": "to_lower_case()", + "naming-properties": [ + { + "property-name": "AIC_CLOUD_REGION" + }, + { + "property-name": "CONSTANT", + "property-value": "onap-nf" + }, + { + "property-name": "TIMESTAMP" + }, + { + "property-value": "-", + "property-name": "DELIMITER" + } + ] + }, + { + "naming-type": "VNFC", + "naming-recipe": "VNF_NAME|DELIMITER|NFC_NAMING_CODE|DELIMITER|SEQUENCE", + "name-operation": "to_lower_case()", + "naming-properties": [ + { + "property-name": "VNF_NAME" + }, + { + "property-name": "SEQUENCE", + "increment-sequence": { + "max": "zzz", + "scope": "ENTIRETY", + "start-value": "1", + "length": "3", + "increment": "1", + "sequence-type": "alpha-numeric" + } + }, + { + "property-name": "NFC_NAMING_CODE" + }, + { + "property-value": "-", + "property-name": "DELIMITER" + } + ] + }, + { + "naming-type": "VF-MODULE", + "naming-recipe": "VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER|VF_MODULE_TYPE|DELIMITER|SEQUENCE", + "name-operation": "to_lower_case()", + "naming-properties": [ + { + "property-name": "VNF_NAME" + }, + { + "property-value": "-", + "property-name": "DELIMITER" + }, + { + "property-name": "VF_MODULE_LABEL" + }, + { + "property-name": "VF_MODULE_TYPE" + }, + { + "property-name": "SEQUENCE", + "increment-sequence": { + "max": "zzz", + "scope": "PRECEEDING", + "start-value": "1", + "length": "3", + "increment": "1", + "sequence-type": "alpha-numeric" + } + } + ] + } + ], + "policy-instance-name": "ONAP_NF_NAMING_TIMESTAMP" + }, + "name": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "version": "1.0.0", + "metadata": { + "policy-id": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "policy-version": "1.0.0" + } + } + } + ] +} \ No newline at end of file diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index aeae64036..b52b16db4 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -114,6 +114,7 @@ clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf clamp.config.security.permission.type.template=org.onap.clamp.clds.template clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca +clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal diff --git a/src/test/resources/robotframework/robotframework-test.properties b/src/test/resources/robotframework/robotframework-test.properties index 665842b84..1e173f961 100644 --- a/src/test/resources/robotframework/robotframework-test.properties +++ b/src/test/resources/robotframework/robotframework-test.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -152,12 +152,13 @@ clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! -clamp.config.security.permission.type.cl=permission-type-cl -clamp.config.security.permission.type.cl.manage=permission-type-cl-manage -clamp.config.security.permission.type.cl.event=permission-type-cl-event -clamp.config.security.permission.type.filter.vf=permission-type-filter-vf -clamp.config.security.permission.type.template=permission-type-template -clamp.config.security.permission.type.tosca=permission-type-tosca +clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl +clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage +clamp.config.security.permission.type.cl.event=org.onap.clamp.clds.cl.event +clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf +clamp.config.security.permission.type.template=org.onap.clamp.clds.template +clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca +clamp.config.security.permission.type.policies=org.onap.clamp.clds.policies #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal diff --git a/src/test/resources/robotframework/tests/02_policy_queries.robot b/src/test/resources/robotframework/tests/02_policy_queries.robot new file mode 100644 index 000000000..e62e03476 --- /dev/null +++ b/src/test/resources/robotframework/tests/02_policy_queries.robot @@ -0,0 +1,21 @@ +*** Settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json +Library OperatingSystem +*** Variables *** +${login} admin +${passw} password +${reponse_pdp_group} pdpGroupInfo +*** Keywords *** +Create the sessions +*** Test Cases *** +Get Requests policies list ok + ${port} = Get Environment Variable CLAMP_PORT + ${auth} = Create List ${login} ${passw} + Create Session clamp http://localhost:${port} auth=${auth} disable_warnings=1 + Set Global Variable ${clamp_session} clamp + ${response_query}= Get Request ${clamp_session} /restservices/clds/v2/policies/list + Should Be Equal As Strings ${response_query.status_code} 200 + Should Contain ${response_query.text} ${reponse_pdp_group} \ No newline at end of file -- cgit 1.2.3-korg