1 # -*- coding: utf-8 -*-
3 # Copyright 2018 Whitestack, LLC
4 # *************************************************************
6 # This file is part of OSM Monitoring module
7 # All Rights Reserved to Whitestack, LLC
9 # Licensed under the Apache License, Version 2.0 (the "License"); you may
10 # not use this file except in compliance with the License. You may obtain
11 # a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18 # License for the specific language governing permissions and limitations
21 # For those usages not covered by the Apache License, Version 2.0 please
22 # contact: bdiaz@whitestack.com or glavado@whitestack.com
25 """Test an end to end Openstack vim_account requests."""
31 from osm_mon
.core
.auth
import AuthManager
32 from osm_mon
.core
.database
import DatabaseManager
34 log
= logging
.getLogger(__name__
)
37 class VimAccountTest(unittest
.TestCase
):
39 self
.auth_manager
= AuthManager()
40 self
.database_manager
= DatabaseManager()
41 self
.database_manager
.create_tables()
43 def test_create_edit_delete_vim_account(self
):
44 """Test vim_account creation message from KafkaProducer."""
45 # Set-up message, producer and consumer for tests
49 "vim_type": "openstack",
50 "vim_url": "auth_url",
52 "vim_password": "password",
53 "vim_tenant_name": "tenant",
59 self
.auth_manager
.store_auth_credentials(create_payload
)
61 creds
= self
.auth_manager
.get_credentials('test_id')
63 self
.assertIsNotNone(creds
)
64 self
.assertEqual(creds
.name
, create_payload
['name'])
65 self
.assertEqual(json
.loads(creds
.config
), create_payload
['config'])
67 # Set-up message, producer and consumer for tests
70 "name": "test_name_edited",
71 "vim_type": "openstack",
72 "vim_url": "auth_url",
74 "vim_password": "password",
75 "vim_tenant_name": "tenant",
78 "foo_edited": "bar_edited"
82 self
.auth_manager
.store_auth_credentials(edit_payload
)
84 creds
= self
.auth_manager
.get_credentials('test_id')
86 self
.assertEqual(creds
.name
, edit_payload
['name'])
87 self
.assertEqual(json
.loads(creds
.config
), edit_payload
['config'])
93 self
.auth_manager
.delete_auth_credentials(delete_payload
)
95 creds
= self
.auth_manager
.get_credentials('test_id')
96 self
.assertIsNone(creds
)