blob: 5ec8a27e2941b3741385c942641040d9df7843ed [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
James Combs96606b32015-06-29 15:21:05 +000046 def test_db_encryption(self):
Sabeen Syed36eb8242015-08-19 03:57:45 +000047 # Create a stack with the value of 'foo' to be encrypted
James Combs96606b32015-06-29 15:21:05 +000048 foo_param = 'my_encrypted_foo'
Sabeen Syed36eb8242015-08-19 03:57:45 +000049 parameters = {
50 "image": self.conf.minimal_image_ref,
51 "flavor": self.conf.minimal_instance_type,
52 'network': self.conf.fixed_network_name,
53 "foo": foo_param
54 }
55
James Combs96606b32015-06-29 15:21:05 +000056 stack_identifier = self.stack_create(
57 template=self.template,
Sabeen Syed36eb8242015-08-19 03:57:45 +000058 parameters=parameters
James Combs96606b32015-06-29 15:21:05 +000059 )
60 stack = self.client.stacks.get(stack_identifier)
61
62 # Verify the output value for 'foo' parameter
63 for out in stack.outputs:
64 if out['output_key'] == 'encrypted_foo_param':
65 self.assertEqual(foo_param, out['output_value'])