Merge branch 'master' into install_integration

This commit is contained in:
Nico Schottelius 2014-02-10 21:34:35 +01:00
commit 219f3a99bf
5 changed files with 25 additions and 1 deletions

View file

@ -121,7 +121,8 @@ class CdistObject(object):
return os.path.join(type_name, object_id) return os.path.join(type_name, object_id)
def validate_object_id(self): def validate_object_id(self):
# FIXME: also check that there is no object ID when type is singleton? if self.cdist_type.is_singleton and self.object_id:
raise IllegalObjectIdError('singleton objects can\'t have a object_id')
"""Validate the given object_id and raise IllegalObjectIdError if it's not valid. """Validate the given object_id and raise IllegalObjectIdError if it's not valid.
""" """
@ -130,6 +131,8 @@ class CdistObject(object):
raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER) raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER)
if '//' in self.object_id: if '//' in self.object_id:
raise IllegalObjectIdError(self.object_id, 'object_id may not contain //') raise IllegalObjectIdError(self.object_id, 'object_id may not contain //')
if self.object_id == '.':
raise IllegalObjectIdError(self.object_id, 'object_id may not be a .')
# If no object_id and type is not singleton => error out # If no object_id and type is not singleton => error out
if not self.object_id and not self.cdist_type.is_singleton: if not self.object_id and not self.cdist_type.is_singleton:

View file

@ -2,6 +2,7 @@
# #
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2014 Daniel Heule (hda at sfs.biz)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -94,6 +95,17 @@ class ObjectIdTestCase(test.CdistTestCase):
core.CdistObject(cdist_type, object_base_path, illegal_object_id) core.CdistObject(cdist_type, object_base_path, illegal_object_id)
# if we get here, the test passed # if we get here, the test passed
def test_object_id_contains_only_dot(self):
cdist_type = core.CdistType(type_base_path, '__third')
illegal_object_id = '.'
with self.assertRaises(core.IllegalObjectIdError):
core.CdistObject(cdist_type, object_base_path, illegal_object_id)
def test_object_id_on_singleton_type(self):
cdist_type = core.CdistType(type_base_path, '__test_singleton')
illegal_object_id = 'object_id'
with self.assertRaises(core.IllegalObjectIdError):
core.CdistObject(cdist_type, object_base_path, illegal_object_id)
class ObjectTestCase(test.CdistTestCase): class ObjectTestCase(test.CdistTestCase):

View file

@ -5,6 +5,9 @@ Changelog
* Exception: No braces means author == Nico Schottelius * Exception: No braces means author == Nico Schottelius
3.0.8:
* Core: Enhance object id verification (Daniel Heule)
3.0.7: 2014-02-08 3.0.7: 2014-02-08
* Core: Allow dependencies to be created based execution order (Daniel Heule) * Core: Allow dependencies to be created based execution order (Daniel Heule)
* Core: Add tests for override (Daniel Heule) * Core: Add tests for override (Daniel Heule)

Binary file not shown.

View file

@ -1,6 +1,7 @@
from distutils.core import setup from distutils.core import setup
import cdist import cdist
import os import os
import re
def data_finder(data_dir): def data_finder(data_dir):
entries = [] entries = []
@ -10,6 +11,11 @@ def data_finder(data_dir):
if name == ".gitignore": if name == ".gitignore":
continue continue
# Skip vim swp files
swpfile = re.search(r'^\..*\.swp$', name)
if swpfile:
continue
entry = os.path.join(data_dir, name) entry = os.path.join(data_dir, name)
if os.path.isdir(entry): if os.path.isdir(entry):
entries.extend(data_finder(entry)) entries.extend(data_finder(entry))