Modifies MON to use mongodb directly for vim info and do vim pass decryption on demand
[osm/MON.git] / osm_mon / tests / unit / server / test_server_service.py
index 9c4dcd1..f3b1120 100644 (file)
 # For those usages not covered by the Apache License, Version 2.0 please
 # contact: bdiaz@whitestack.com or glavado@whitestack.com
 ##
-import json
 from unittest import TestCase, mock
 
 from osm_mon.core.common_db import CommonDbClient
 from osm_mon.core.config import Config
-from osm_mon.core.database import VimCredentialsRepository, VimCredentials
-from osm_mon.server.service import ServerService
 
 
 @mock.patch.object(CommonDbClient, "__init__", lambda *args, **kwargs: None)
@@ -35,50 +32,6 @@ class ServerServiceTest(TestCase):
         super().setUp()
         self.config = Config()
 
-    @mock.patch.object(CommonDbClient, "decrypt_vim_password")
-    @mock.patch.object(VimCredentialsRepository, "upsert")
-    @mock.patch('osm_mon.core.database.db')
-    def test_upsert_vim_account(self, db, upsert_credentials, decrypt_vim_password):
-        def _mock_decrypt_vim_password(password: str, schema_version: str, vim_uuid: str):
-            return password.replace('encrypted', 'decrypted')
-
-        decrypt_vim_password.side_effect = _mock_decrypt_vim_password
-
-        mock_config = {
-            'admin_password': 'encrypted_admin_password',
-            'nsx_password': 'encrypted_nsx_password',
-            'vcenter_password': 'encrypted_vcenter_password'
-        }
-
-        mock_expected_config = {
-            'admin_password': 'decrypted_admin_password',
-            'nsx_password': 'decrypted_nsx_password',
-            'vcenter_password': 'decrypted_vcenter_password'
-        }
-
-        service = ServerService(self.config)
-        service.upsert_vim_account('test_uuid', 'test_name', 'test_type', 'test_url', 'test_user', 'encrypted_password',
-                                   'test_tenant_name', '1.1', mock_config)
-
-        upsert_credentials.assert_called_with(
-            uuid=mock.ANY,
-            name='test_name',
-            type='test_type',
-            url='test_url',
-            user='test_user',
-            password='decrypted_password',
-            tenant_name='test_tenant_name',
-            config=json.dumps(mock_expected_config)
-        )
-
-    @mock.patch.object(VimCredentialsRepository, "get")
-    @mock.patch('osm_mon.core.database.db')
-    def test_delete_vim_account(self, db, get_credentials):
-        mock_creds = mock.Mock()
-        get_credentials.return_value = mock_creds
-
-        service = ServerService(self.config)
-        service.delete_vim_account('test_uuid')
-
-        get_credentials.assert_called_with(VimCredentials.uuid == 'test_uuid')
-        mock_creds.delete_instance.assert_called_with()
+    def test_create_alarm(self):
+        # TODO
+        pass