Check VIM juju paas config

It must contain :

- paas_provider
- ca_cert_content
- cloud
- cloud_credentials

Change-Id: I8ce9918f81afd120c7a3d4e1e05fe27fac3508ad
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Mark Beierl <mark.beierl@canonical.com>
diff --git a/osm_nbi/tests/test_admin_topics.py b/osm_nbi/tests/test_admin_topics.py
index 6c8083f..57551c7 100755
--- a/osm_nbi/tests/test_admin_topics.py
+++ b/osm_nbi/tests/test_admin_topics.py
@@ -1620,11 +1620,18 @@
     def check_invalid_indata_raises_exception(self, indata, mock_common_vim_wim_sdn):
         with self.assertRaises(EngineException) as error:
             self.topic.check_conflict_on_new(self.fake_session, indata)
-        mock_common_vim_wim_sdn.assert_called_once_with(self.fake_session, indata)
-        error_msg = "Invalid paas_provider for VIM account '{}'.".format(indata["name"])
+        mock_common_vim_wim_sdn.assert_called_with(self.fake_session, indata)
+        error_msg = "Invalid config for VIM account '{}'.".format(indata["name"])
         self.assertEqual(str(error.exception), error_msg)
 
     def test_check_conflict_on_new_vim_type_paas(self, mock_common_vim_wim_sdn):
+        valid_juju_paas_config = {
+            "paas_provider": "juju",
+            "ca_cert_content": "file_content",
+            "cloud": "microk8s",
+            "cloud_credentials": "cloud_credential_name",
+            "authorized_keys": "keys",
+        }
         indata = {
             "name": "juju_paas",
             "vim_type": "paas",
@@ -1633,26 +1640,11 @@
             "vim_user": "some_user",
             "vim_password": "some_password",
             "vim_tenant_name": "null",
-            "config": {"paas_provider": "juju"},
+            "config": valid_juju_paas_config,
         }
         self.topic.check_conflict_on_new(self.fake_session, indata)
         mock_common_vim_wim_sdn.assert_called_once_with(self.fake_session, indata)
 
-    def test_check_conflict_on_new_vim_type_paas_incorrect_provider(
-        self, mock_common_vim_wim_sdn
-    ):
-        indata = {
-            "name": "juju_paas",
-            "vim_type": "paas",
-            "description": None,
-            "vim_url": "http://0.0.0.0:0",
-            "vim_user": "some_user",
-            "vim_password": "some_password",
-            "vim_tenant_name": "null",
-            "config": {"paas_provider": "some_provider"},
-        }
-        self.check_invalid_indata_raises_exception(indata, mock_common_vim_wim_sdn)
-
     def test_check_conflict_on_new_vim_type_paas_config_missing(
         self, mock_common_vim_wim_sdn
     ):
@@ -1667,22 +1659,65 @@
         }
         self.check_invalid_indata_raises_exception(indata, mock_common_vim_wim_sdn)
 
-    def test_check_conflict_on_new_vim_type_paas_provider_missing(
+    def test_check_conflict_on_new_vim_type_paas_invalid_config(
         self, mock_common_vim_wim_sdn
     ):
-        indata = {
-            "name": "juju_paas",
-            "vim_type": "paas",
-            "description": None,
-            "vim_url": "http://0.0.0.0:0",
-            "vim_user": "some_user",
-            "vim_password": "some_password",
-            "vim_tenant_name": "null",
-            "config": {"some_param": None},
-        }
-        self.check_invalid_indata_raises_exception(indata, mock_common_vim_wim_sdn)
+        invalid_configs = [
+            {
+                "paas_provider": "some_paas_provider",
+                "ca_cert_content": "file_content",
+                "cloud": "microk8s",
+                "cloud_credentials": "cloud_credential_name",
+            },
+            {
+                "ca_cert_content": "file_content",
+                "cloud": "microk8s",
+                "cloud_credentials": "cloud_credential_name",
+            },
+            {
+                "paas_provider": "juju",
+                "cloud": "microk8s",
+                "cloud_credentials": "cloud_credential_name",
+            },
+            {
+                "paas_provider": "juju",
+                "ca_cert_content": "file_content",
+                "cloud_credentials": "cloud_credential_name",
+            },
+            {
+                "paas_provider": "juju",
+                "ca_cert_content": "file_content",
+                "cloud": "microk8s",
+            },
+            {
+                "some_param": None,
+            },
+            {},
+        ]
+        for config in invalid_configs:
+            with self.subTest():
+                indata = {
+                    "name": "juju_paas",
+                    "vim_type": "paas",
+                    "description": None,
+                    "vim_url": "http://0.0.0.0:0",
+                    "vim_user": "some_user",
+                    "vim_password": "some_password",
+                    "vim_tenant_name": "null",
+                    "config": config,
+                }
+                self.check_invalid_indata_raises_exception(
+                    indata, mock_common_vim_wim_sdn
+                )
 
     def test_kafka_message_is_not_sent_if_paas_vim(self, mock_common_vim_wim_sdn):
+        valid_juju_paas_config = {
+            "paas_provider": "juju",
+            "ca_cert_content": "file_content",
+            "cloud": "microk8s",
+            "cloud_credentials": "cloud_credential_name",
+            "authorized_keys": "keys",
+        }
         indata = {
             "name": "juju_paas",
             "vim_type": "paas",
@@ -1691,7 +1726,7 @@
             "vim_user": "some_user",
             "vim_password": "some_password",
             "vim_tenant_name": "null",
-            "config": {"paas_provider": "juju"},
+            "config": valid_juju_paas_config,
         }
         rollback = []
         self.topic.temporal = Mock()