aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests/test_heat_parameter_section.py
diff options
context:
space:
mode:
Diffstat (limited to 'ice_validator/tests/test_heat_parameter_section.py')
-rw-r--r--ice_validator/tests/test_heat_parameter_section.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ice_validator/tests/test_heat_parameter_section.py b/ice_validator/tests/test_heat_parameter_section.py
index e5792fc..2aab7d3 100644
--- a/ice_validator/tests/test_heat_parameter_section.py
+++ b/ice_validator/tests/test_heat_parameter_section.py
@@ -39,8 +39,12 @@
#
from .helpers import validates
import pytest
+import re
import yaml
+# one or more (alphanumeric or underscore)
+RE_VALID_PARAMETER_NAME = re.compile(r'[\w_]+$')
+
def test_parameter_valid_keys(yaml_file):
'''
@@ -88,3 +92,24 @@ def test_default_values(yaml_file):
invalid_params.append(str(v1))
assert not set(invalid_params)
+
+
+@validates('R-25877')
+def test_parameter_names(yaml_file):
+ '''
+ A VNF's Heat Orchestration Template's parameter name
+ (i.e., <param name>) **MUST** contain only alphanumeric
+ characters and underscores ('_').
+ '''
+ with open(yaml_file) as fh:
+ yml = yaml.load(fh)
+
+ # skip if parameters are not defined
+ if "parameters" not in yml:
+ pytest.skip("No parameters specified in the heat template")
+
+ for key in yml['parameters']:
+ assert RE_VALID_PARAMETER_NAME.match(key), (
+ '%s parameter "%s" not alphanumeric or underscore' % (
+ yaml_file,
+ key))