aboutsummaryrefslogtreecommitdiffstats
path: root/sliapi/installer
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@linuxfoundation.org>2017-11-17 16:51:44 -0800
committerDan Timoney <dtimoney@att.com>2017-11-20 14:29:14 -0500
commit9cf0a1e191259f19cc7cbffdf57a96cd4e06ee1f (patch)
tree78c98992a11690411c0104b5bbec06196291fa9d /sliapi/installer
parent636c3a7d71ff65ef314d62dde67be8fda7d6a240 (diff)
Bump minor version
Bump minor version in preparation for Amsterdam branching. (part 2) Change-Id: Ib9f7cf7f98feb159ce1b136a3cd792820c99e659 Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
Diffstat (limited to 'sliapi/installer')
-rwxr-xr-xsliapi/installer/pom.xml2
1 files changed, 1 insertions, 1 deletions
diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml
index b3287b78..cddcf6dd 100755
--- a/sliapi/installer/pom.xml
+++ b/sliapi/installer/pom.xml
@@ -4,7 +4,7 @@
<parent>
<artifactId>sliapi</artifactId>
<groupId>org.onap.ccsdk.sli.core</groupId>
- <version>0.1.3-SNAPSHOT</version>
+ <version>0.2.0-SNAPSHOT</version>
</parent>
<artifactId>sliapi-installer</artifactId>
<packaging>pom</packaging>
e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-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 */ }
# ============LICENSE_START===================================================
#  Copyright (C) 2020 Nordix Foundation.
# ============================================================================
# Licensed 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.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
import json
import os
from test.support import EnvironmentVarGuard
from unittest import TestCase
from unittest.mock import patch

from mod import create_app, db
from mod.network_function import NetworkFunction
from mod.pmsh_utils import AppConfig
from mod.subscription import AdministrativeState
from mod.subscription_handler import SubscriptionHandler


class SubscriptionHandlerTest(TestCase):

    @classmethod
    def setUpClass(cls):
        cls.env = EnvironmentVarGuard()
        cls.env.set('AAI_SERVICE_PORT', '8443')
        cls.env.set('LOGGER_CONFIG', os.path.join(os.path.dirname(__file__), 'log_config.yaml'))
        cls.nfs = [NetworkFunction(nf_name='pnf_1'), NetworkFunction(nf_name='pnf_2')]

    @patch('mod.get_db_connection_url')
    @patch('mod.update_logging_config')
    @patch('mod.pmsh_utils.AppConfig._get_pmsh_config')
    @patch('mod.pmsh_utils._MrPub')
    @patch('mod.pmsh_utils.PeriodicTask')
    def setUp(self, mock_periodic_task, mock_mr_pub, mock_get_pmsh_config, mock_update_config,
              mock_get_db_url):
        mock_get_db_url.return_value = 'sqlite://'
        with open(os.path.join(os.path.dirname(__file__), 'data/cbs_data_1.json'), 'r') as data:
            self.cbs_data = json.load(data)
        mock_get_pmsh_config.return_value = self.cbs_data
        self.mock_mr_pub = mock_mr_pub
        self.mock_aai_event_thread = mock_periodic_task
        self.mock_policy_event_thread = mock_periodic_task
        self.app = create_app()
        self.app.app_context().push()
        db.create_all()
        self.app_conf = AppConfig()

    def tearDown(self):
        db.drop_all()
        db.session.remove()

    @patch('mod.subscription.Subscription.get_local_sub_admin_state')
    @patch('mod.logger.info')
    @patch('mod.aai_client.get_pmsh_nfs_from_aai')
    def test_execute_no_change_of_state(self, mock_get_aai, mock_logger, mock_get_sub_status):
        mock_get_sub_status.return_value = AdministrativeState.UNLOCKED.value
        mock_get_aai.return_value = self.nfs
        sub_handler = SubscriptionHandler(self.mock_mr_pub,
                                          self.app, self.app_conf,
                                          self.mock_aai_event_thread,
                                          self.mock_policy_event_thread)
        sub_handler.execute()
        mock_logger.assert_called_with('Administrative State did not change in the Config')

    @patch('mod.subscription.Subscription.get_local_sub_admin_state')
    @patch('mod.subscription.Subscription.activate_subscription')
    @patch('mod.aai_client.get_pmsh_nfs_from_aai')
    def test_execute_change_of_state_to_unlocked(self, mock_get_aai, mock_activate_sub,
                                                 mock_get_sub_status):
        mock_get_aai.return_value = self.nfs
        mock_get_sub_status.return_value = AdministrativeState.LOCKED.value
        self.mock_aai_event_thread.return_value.start.return_value = 'start_method'
        sub_handler = SubscriptionHandler(self.mock_mr_pub,
                                          self.app, self.app_conf,
                                          self.mock_aai_event_thread.return_value,
                                          self.mock_policy_event_thread)
        sub_handler.execute()
        self.assertEqual(AdministrativeState.UNLOCKED.value,
                         self.app_conf.subscription.administrativeState)
        mock_activate_sub.assert_called_with(self.nfs, self.mock_mr_pub, self.app_conf)
        self.mock_aai_event_thread.return_value.start.assert_called()

    @patch('mod.subscription.Subscription.get_local_sub_admin_state')
    @patch('mod.subscription.Subscription.deactivate_subscription')
    @patch('mod.aai_client.get_pmsh_nfs_from_aai')
    def test_execute_change_of_state_to_locked(self, mock_get_aai, mock_deactivate_sub,
                                               mock_get_sub_status):
        mock_get_sub_status.return_value = AdministrativeState.UNLOCKED.value
        self.app_conf.subscription.administrativeState = AdministrativeState.LOCKED.value
        self.app_conf.subscription.update_subscription_status()
        mock_get_aai.return_value = self.nfs
        self.mock_aai_event_thread.return_value.cancel.return_value = 'cancel_method'
        sub_handler = SubscriptionHandler(self.mock_mr_pub,
                                          self.app, self.app_conf,
                                          self.mock_aai_event_thread.return_value,
                                          self.mock_policy_event_thread)
        sub_handler.execute()
        mock_deactivate_sub.assert_called_with(self.mock_mr_pub, self.app_conf)
        self.mock_aai_event_thread.return_value.cancel.assert_called()

    @patch('mod.subscription.Subscription.activate_subscription')
    @patch('mod.logger.error')
    @patch('mod.aai_client.get_pmsh_nfs_from_aai')
    def test_execute_exception(self, mock_get_aai, mock_logger, mock_activate_sub):
        mock_get_aai.return_value = self.nfs
        mock_activate_sub.side_effect = Exception
        sub_handler = SubscriptionHandler(self.mock_mr_pub,
                                          self.app, self.app_conf,
                                          self.mock_aai_event_thread,
                                          self.mock_policy_event_thread)
        sub_handler.execute()
        mock_logger.assert_called_with('Error occurred during the activation/deactivation process ',
                                       exc_info=True)