Merge "Fix error msg for wrong auth_url in functional"
diff --git a/common/config.py b/common/config.py
index 39c0846..6d35600 100644
--- a/common/config.py
+++ b/common/config.py
@@ -21,10 +21,15 @@
 
     cfg.StrOpt('username',
                default=os.environ.get('OS_USERNAME'),
-               help="Username to use for API requests."),
+               help="Username to use for non admin API requests."),
     cfg.StrOpt('password',
                default=os.environ.get('OS_PASSWORD'),
-               help="API key to use when authenticating.",
+               help="Non admin API key to use when authenticating.",
+               secret=True),
+    cfg.StrOpt('admin_username',
+               help="Username to use for admin API requests."),
+    cfg.StrOpt('admin_password',
+               help="Admin API key to use when authentication.",
                secret=True),
     cfg.StrOpt('tenant_name',
                default=(os.environ.get('OS_PROJECT_NAME') or
diff --git a/functional/functional_base.py b/functional/functional_base.py
index 452e055..9f76011 100644
--- a/functional/functional_base.py
+++ b/functional/functional_base.py
@@ -10,6 +10,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from oslo_utils import reflection
+
 from heat_integrationtests.common import test
 
 
@@ -21,7 +23,7 @@
         self.client = self.orchestration_client
 
     def check_skip(self):
-        test_cls_name = self.__class__.__name__
+        test_cls_name = reflection.get_class_name(self, fully_qualified=False)
         test_method_name = '.'.join([test_cls_name, self._testMethodName])
         test_skipped = (self.conf.skip_functional_test_list and (
             test_cls_name in self.conf.skip_functional_test_list or
diff --git a/functional/test_encryption_vol_type.py b/functional/test_encryption_vol_type.py
index e1a3e76..2679990 100644
--- a/functional/test_encryption_vol_type.py
+++ b/functional/test_encryption_vol_type.py
@@ -42,11 +42,14 @@
 class EncryptionVolTypeTest(functional_base.FunctionalTestsBase):
     def setUp(self):
         super(EncryptionVolTypeTest, self).setUp()
+        if not self.conf.admin_username or not self.conf.admin_password:
+            self.skipTest('No admin creds found, skipping')
         self.conf = config.init_conf()
         # cinder security policy usage of volume type is limited
         # to being used by administrators only.
-        # Temporarily set username as admin for this test case.
-        self.conf.username = 'admin'
+        # Temporarily switch to admin
+        self.conf.username = self.conf.admin_username
+        self.conf.password = self.conf.admin_password
         self.manager = clients.ClientManager(self.conf)
         self.client = self.manager.orchestration_client
         self.volume_client = self.manager.volume_client
diff --git a/functional/test_immutable_parameters.py b/functional/test_immutable_parameters.py
index b8c498d..d223b14 100644
--- a/functional/test_immutable_parameters.py
+++ b/functional/test_immutable_parameters.py
@@ -126,7 +126,7 @@
                 stack_identifier,
                 template=immutable_true,
                 parameters=update_parameters)
-        except heat_exceptions.HTTPInternalServerError as exc:
+        except heat_exceptions.HTTPBadRequest as exc:
             exp = ('The following parameters are immutable and may not be '
                    'updated: param1')
             self.assertIn(exp, str(exc))
diff --git a/functional/test_unicode_template.py b/functional/test_unicode_template.py
new file mode 100644
index 0000000..924c110
--- /dev/null
+++ b/functional/test_unicode_template.py
@@ -0,0 +1,113 @@
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from heat_integrationtests.functional import functional_base
+
+
+class StackUnicodeTemplateTest(functional_base.FunctionalTestsBase):
+
+    random_template = u'''
+heat_template_version: 2014-10-16
+description: \u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0
+parameters:
+  \u53c2\u6570:
+    type: number
+    default: 10
+    label: \u6807\u7b7e
+    description: \u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0
+resources:
+  \u8d44\u6e90:
+    type: OS::Heat::RandomString
+    properties:
+      length: {get_param: \u53c2\u6570}
+outputs:
+  \u8f93\u51fa:
+    description: \u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0
+    value: {get_attr: [\u8d44\u6e90, value]}
+'''
+
+    def setUp(self):
+        super(StackUnicodeTemplateTest, self).setUp()
+
+    def _assert_results(self, result):
+        self.assertTrue(result['disable_rollback'])
+        self.assertIsNone(result['parent'])
+        self.assertEqual(u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+                         result['template_description'])
+        self.assertEqual(u'10', result['parameters'][u'\u53c2\u6570'])
+
+    def _assert_preview_results(self, result):
+        self._assert_results(result)
+        res = result['resources'][0]
+        self.assertEqual('/resources/%s' % res['resource_name'],
+                         res['resource_identity']['path'])
+
+    def _assert_create_results(self, result):
+        self._assert_results(result)
+        output = result['outputs'][0]
+        self.assertEqual(u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+                         output['description'])
+        self.assertEqual(u'\u8f93\u51fa', output['output_key'])
+        self.assertIsNotNone(output['output_value'])
+
+    def _assert_resource_results(self, result):
+        self.assertEqual(u'\u8d44\u6e90', result['resource_name'])
+        self.assertEqual('OS::Heat::RandomString',
+                         result['resource_type'])
+
+    def test_template_validate_basic(self):
+        ret = self.client.stacks.validate(template=self.random_template)
+        expected = {
+            'Description': u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+            'Parameters': {
+                u'\u53c2\u6570': {
+                    'Default': 10,
+                    'Description': u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+                    'Label': u'\u6807\u7b7e',
+                    'NoEcho': 'false',
+                    'Type': 'Number'}
+            }
+        }
+        self.assertEqual(expected, ret)
+
+    def test_template_validate_override_default(self):
+        env = {'parameters': {u'\u53c2\u6570': 5}}
+        ret = self.client.stacks.validate(template=self.random_template,
+                                          environment=env)
+        expected = {
+            'Description': u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+            'Parameters': {
+                u'\u53c2\u6570': {
+                    'Default': 10,
+                    'Value': 5,
+                    'Description': u'\u8fd9\u662f\u4e00\u4e2a\u63cf\u8ff0',
+                    'Label': u'\u6807\u7b7e',
+                    'NoEcho': 'false',
+                    'Type': 'Number'}
+            }
+        }
+        self.assertEqual(expected, ret)
+
+    def test_stack_preview(self):
+        result = self.client.stacks.preview(
+            template=self.random_template,
+            stack_name=self._stack_rand_name(),
+            disable_rollback=True).to_dict()
+        self._assert_preview_results(result)
+
+    def test_create_stack(self):
+        stack_identifier = self.stack_create(template=self.random_template)
+        stack = self.client.stacks.get(stack_identifier)
+        self._assert_create_results(stack.to_dict())
+        rl = self.client.resources.list(stack_identifier)
+        self.assertEqual(1, len(rl))
+        self._assert_resource_results(rl[0].to_dict())
diff --git a/scenario/scenario_base.py b/scenario/scenario_base.py
index 66069ff..d41c9a1 100644
--- a/scenario/scenario_base.py
+++ b/scenario/scenario_base.py
@@ -10,6 +10,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from oslo_utils import reflection
+
 from heat_integrationtests.common import test
 
 
@@ -59,7 +61,7 @@
         return stack_id
 
     def check_skip(self):
-        test_cls_name = self.__class__.__name__
+        test_cls_name = reflection.get_class_name(self, fully_qualified=False)
         test_method_name = '.'.join([test_cls_name, self._testMethodName])
         test_skipped = (self.conf.skip_scenario_test_list and (
             test_cls_name in self.conf.skip_scenario_test_list or