blob: 21dc925a014ce72921c0a5a1b797cbc69ac26732 [file] [log] [blame]
James Combs96606b32015-06-29 15:21:05 +00001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
Rabi Mishra477efc92015-07-31 13:01:45 +053013from heat_integrationtests.functional import functional_base
James Combs96606b32015-06-29 15:21:05 +000014
15
Rabi Mishra477efc92015-07-31 13:01:45 +053016class EncryptedParametersTest(functional_base.FunctionalTestsBase):
James Combs96606b32015-06-29 15:21:05 +000017
18 template = '''
Sabeen Syed36eb8242015-08-19 03:57:45 +000019heat_template_version: 2014-10-16
James Combs96606b32015-06-29 15:21:05 +000020parameters:
Sabeen Syed36eb8242015-08-19 03:57:45 +000021 image:
22 type: string
23 flavor:
24 type: string
25 network:
26 type: string
James Combs96606b32015-06-29 15:21:05 +000027 foo:
28 type: string
Sabeen Syed36eb8242015-08-19 03:57:45 +000029 description: 'parameter with encryption turned on'
James Combs96606b32015-06-29 15:21:05 +000030 hidden: true
31 default: secret
Sabeen Syed36eb8242015-08-19 03:57:45 +000032resources:
33 server_with_encrypted_property:
34 type: OS::Nova::Server
35 properties:
36 name: { get_param: foo }
37 image: { get_param: image }
38 flavor: { get_param: flavor }
39 networks: [{network: {get_param: network} }]
James Combs96606b32015-06-29 15:21:05 +000040outputs:
41 encrypted_foo_param:
Sabeen Syed36eb8242015-08-19 03:57:45 +000042 description: 'encrypted param'
43 value: { get_param: foo }
James Combs96606b32015-06-29 15:21:05 +000044'''
45
46 def setUp(self):
47 super(EncryptedParametersTest, self).setUp()
James Combs96606b32015-06-29 15:21:05 +000048
49 def test_db_encryption(self):
Sabeen Syed36eb8242015-08-19 03:57:45 +000050 # Create a stack with the value of 'foo' to be encrypted
James Combs96606b32015-06-29 15:21:05 +000051 foo_param = 'my_encrypted_foo'
Sabeen Syed36eb8242015-08-19 03:57:45 +000052 parameters = {
53 "image": self.conf.minimal_image_ref,
54 "flavor": self.conf.minimal_instance_type,
55 'network': self.conf.fixed_network_name,
56 "foo": foo_param
57 }
58
James Combs96606b32015-06-29 15:21:05 +000059 stack_identifier = self.stack_create(
60 template=self.template,
Sabeen Syed36eb8242015-08-19 03:57:45 +000061 parameters=parameters
James Combs96606b32015-06-29 15:21:05 +000062 )
63 stack = self.client.stacks.get(stack_identifier)
64
65 # Verify the output value for 'foo' parameter
66 for out in stack.outputs:
67 if out['output_key'] == 'encrypted_foo_param':
68 self.assertEqual(foo_param, out['output_value'])