James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 1 | # 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 Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 13 | from heat_integrationtests.functional import functional_base |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 14 | |
| 15 | |
Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 16 | class EncryptedParametersTest(functional_base.FunctionalTestsBase): |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 17 | |
| 18 | template = ''' |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 19 | heat_template_version: 2014-10-16 |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 20 | parameters: |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 21 | image: |
| 22 | type: string |
| 23 | flavor: |
| 24 | type: string |
| 25 | network: |
| 26 | type: string |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 27 | foo: |
| 28 | type: string |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 29 | description: 'parameter with encryption turned on' |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 30 | hidden: true |
| 31 | default: secret |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 32 | resources: |
| 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 Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 40 | outputs: |
| 41 | encrypted_foo_param: |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 42 | description: 'encrypted param' |
| 43 | value: { get_param: foo } |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 44 | ''' |
| 45 | |
| 46 | def setUp(self): |
| 47 | super(EncryptedParametersTest, self).setUp() |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 48 | |
| 49 | def test_db_encryption(self): |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 50 | # Create a stack with the value of 'foo' to be encrypted |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 51 | foo_param = 'my_encrypted_foo' |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 52 | 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 Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 59 | stack_identifier = self.stack_create( |
| 60 | template=self.template, |
Sabeen Syed | 36eb824 | 2015-08-19 03:57:45 +0000 | [diff] [blame] | 61 | parameters=parameters |
James Combs | 96606b3 | 2015-06-29 15:21:05 +0000 | [diff] [blame] | 62 | ) |
| 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']) |