Horizon escapes special characters in openrc.sh
Adding the safe filter makes it possible to have tenant names with special charaters rendered into the openrc.sh file without escaping those characters. Added a new unittest for templates Change-Id: I56ec047da467b721bd1b57d2c97d05717e83f468
This commit is contained in:
parent
47db76554e
commit
3a9b0da489
@ -12,7 +12,7 @@ export OS_AUTH_URL={{ auth_url }}
|
|||||||
# With the addition of Keystone we have standardized on the term **tenant**
|
# With the addition of Keystone we have standardized on the term **tenant**
|
||||||
# as the entity that owns the resources.
|
# as the entity that owns the resources.
|
||||||
export OS_TENANT_ID={{ tenant_id }}
|
export OS_TENANT_ID={{ tenant_id }}
|
||||||
export OS_TENANT_NAME="{{ tenant_name }}"
|
export OS_TENANT_NAME="{{ tenant_name|safe }}"
|
||||||
|
|
||||||
# In addition to the owning entity (tenant), openstack stores the entity
|
# In addition to the owning entity (tenant), openstack stores the entity
|
||||||
# performing the action as the **user**.
|
# performing the action as the **user**.
|
||||||
|
39
openstack_dashboard/test/tests/templates.py
Normal file
39
openstack_dashboard/test/tests/templates.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2012 OpenStack, LLC.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 os import path
|
||||||
|
from openstack_dashboard.test import helpers as test
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
|
|
||||||
|
class FakeUser(object):
|
||||||
|
username = "Super S"
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateRenderTest(test.TestCase):
|
||||||
|
""" Tests for templates render """
|
||||||
|
|
||||||
|
def test_openrc_html_escape(self):
|
||||||
|
context = {
|
||||||
|
"user": FakeUser(),
|
||||||
|
"tenant_id": "some-cool-id",
|
||||||
|
"auth_url": "http://tests.com",
|
||||||
|
"tenant_name": "ENG Perf R&D"}
|
||||||
|
out = render_to_string('settings/project/openrc.sh.template', context)
|
||||||
|
|
||||||
|
self.assertFalse("&" in out)
|
||||||
|
self.assertTrue("ENG Perf R&D" in out)
|
Loading…
x
Reference in New Issue
Block a user