summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2018-09-12 17:09:23 +0530
committerOren Kleks <orenkle@amdocs.com>2018-09-13 11:52:43 +0000
commit79ba4fbed10cabac5c32ba91e57fa55253005c37 (patch)
tree30d53122e265dc12f58d18353f23c476ef7a993b /openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests
parentc58f445fcef56a6440f3b21d54b390700623c48c (diff)
Bugfix - Action mandatory param validation
Fix for actions getting created without passing mandatory parameters Change-Id: I3e332d92d0ad99b85d945ab25d7406e916642314 Issue-ID: SDC-1755 Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java7
1 files changed, 2 insertions, 5 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
index 23f11843b8..2927a7fdd3 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
@@ -97,7 +97,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -1040,10 +1039,8 @@ public class ActionsImpl implements Actions {
if (StringUtils.isEmpty(requestJSON) || requestJSON.equals(REQUEST_EMPTY_BODY)) {
requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY);
} else {
- if(requestType == ActionConstants.REQUEST_TYPE_CREATE_ACTION){
- //placeholder for future implementation
- }
- if(requestType == ActionConstants.REQUEST_TYPE_UPDATE_ACTION){
+ if(requestType == ActionConstants.REQUEST_TYPE_CREATE_ACTION
+ || requestType == ActionConstants.REQUEST_TYPE_UPDATE_ACTION){
//Semantic request specific validations
Action action = JsonUtil.json2Object(requestJSON, Action.class);
if(StringUtils.isEmpty(action.getName())){
weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# -*- coding: utf8 -*-
# ============LICENSE_START====================================================
# org.onap.vvp/validation-scripts
# ===================================================================
# Copyright © 2019 AT&T Intellectual Property. All rights reserved.
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# under the Apache License, Version 2.0 (the "License");
# you may not use this software 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.
#
#
#
# Unless otherwise specified, all documentation contained herein is licensed
# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
#             https://creativecommons.org/licenses/by/4.0/
#
# Unless required by applicable law or agreed to in writing, documentation
# 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.
#
# ============LICENSE_END============================================
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
#

"""
resources:
{vm-type}_server_{vm-type_index}
"""
import pytest

from .structures import Heat
from .structures import ContrailV2VirtualMachineInterfaceProcessor
from .helpers import validates

VERSION = "2.0.0"


def run_test(heat_template, regex_name, network_flavor):
    """run test
    """
    heat = Heat(filepath=heat_template)
    heat_object_class = ContrailV2VirtualMachineInterfaceProcessor
    resource_type = heat_object_class.resource_type
    resources = heat.get_resource_by_type(resource_type=resource_type)
    if not resources:
        pytest.skip("No %s resources found" % resource_type)
    bad = []
    heat_object = heat_object_class()
    rid_pattern = heat_object.get_rid_patterns()[regex_name]
    for rid, resource in resources.items():
        flavor = heat_object.get_network_flavor(resource)
        if flavor != network_flavor:
            continue
        name = heat_object.get_rid_match_tuple(rid)[0]
        if name == regex_name:
            continue
        bad.append(rid)
    assert not bad, "%s resource ids %s must match %s" % (
        network_flavor,
        bad,
        [rid_pattern],
    )


# pylint: disable=invalid-name


@validates("R-96253")
def test_contrail_instance_ip_resource_id_external(heat_template):
    """
    A VNF's Heat Orchestration Template's Resource
    OS::ContrailV2::VirtualMachineInterface that is attaching to an
    external network
    Resource ID **MUST** use the naming convention

    {vm-type}_{vm-type_index}_{network-role}_vmi_{vmi_index}
    """
    run_test(
        heat_template,
        regex_name="vmi_external",
        network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_external,
    )


@validates("R-50468")
def test_contrail_instance_ip_resource_id_internal(heat_template):
    """
    A VNF's Heat Orchestration Template's Resource
    OS::ContrailV2::VirtualMachineInterface that is attaching to an
    internal network
    Resource ID **MUST** use the naming convention

    {vm-type}_{vm-type_index}_int_{network-role}_vmi_{vmi_index}
    """
    run_test(
        heat_template,
        regex_name="vmi_internal",
        network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_internal,
    )


@validates("R-54458")
def test_contrail_instance_ip_resource_id_subint(heat_template):
    """
    A VNF's Heat Orchestration Template's Resource
    OS::ContrailV2::VirtualMachineInterface that is attaching to an
    sub-interface network
    Resource ID **MUST** use the naming convention

    {vm-type}_{vm-type_index}_subint_{network-role}_vmi_{vmi_index}
    """
    run_test(
        heat_template,
        regex_name="vmi_subint",
        network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_subint,
    )