def testCreate(self): class DummySource(source.Source): name = 'dummy' source_factory.RegisterImplementation(DummySource) dummy_config = {'name': 'dummy'} dummy_source = source_factory.Create(dummy_config) self.assertEqual(DummySource, type(dummy_source))
def testRegister(self): number_of_sources = len(source_factory._source_implementations) class DummySource(source.Source): name = 'dummy' source_factory.RegisterImplementation(DummySource) self.assertEqual(number_of_sources + 1, len(source_factory._source_implementations)) self.assertEqual(DummySource, source_factory._source_implementations['dummy'])
def setUp(self): super(TestVerifyCommand, self).setUp() class DummyConfig(object): pass class DummySource(source.Source): name = 'dummy' def Verify(self): return 0 # Instead of a DummyCache, we will override cache_factory.Create so # we can return a pmock cache object. self.original_caches_create = cache_factory.Create self.original_sources_create = source_factory.Create # Add dummy source to the set if implementations of sources. source_factory.RegisterImplementation(DummySource) # Create a config with a section for a passwd map. self.conf = DummyConfig() self.conf.options = {config.MAP_PASSWORD: config.MapOptions()} self.conf.options[config.MAP_PASSWORD].cache = {'name': 'dummy'} self.conf.options[config.MAP_PASSWORD].source = {'name': 'dummy'} self.original_verify_configuration = config.VerifyConfiguration self.original_getmap = nss.GetMap self.original_getpwall = pwd.getpwall self.original_getgrall = grp.getgrall # Setup maps used by VerifyMap testing. big_map = passwd.PasswdMap() map_entry1 = passwd.PasswdMapEntry() map_entry1.name = 'foo' map_entry1.uid = 10 map_entry1.gid = 10 big_map.Add(map_entry1) map_entry2 = passwd.PasswdMapEntry() map_entry2.name = 'bar' map_entry2.uid = 20 map_entry2.gid = 20 big_map.Add(map_entry2) small_map = passwd.PasswdMap() small_map.Add(map_entry1) self.big_map = big_map self.small_map = small_map
def setUp(self): class DummyConfig(object): pass class DummySource(source.Source): name = 'dummy' def Verify(self): return 0 # Add dummy source to the set if implementations of sources source_factory.RegisterImplementation(DummySource) self.conf = DummyConfig() self.conf.options = {config.MAP_PASSWORD: config.MapOptions()} self.conf.options[config.MAP_PASSWORD].cache = {'name': 'dummy'} self.conf.options[config.MAP_PASSWORD].source = {'name': 'dummy'} self.original_verify_configuration = config.VerifyConfiguration
def setUp(self): super(TestStatusCommand, self).setUp() class DummyConfig(object): pass class DummySource(source.Source): name = 'dummy' def Verify(self): return 0 # stub out parts of update.MapUpdater class DummyUpdater(map_updater.MapUpdater): def GetModifyTimestamp(self): return 1 def GetUpdateTimestamp(self): return 2 # Add dummy source to the set if implementations of sources source_factory.RegisterImplementation(DummySource) self.conf = DummyConfig() self.conf.timestamp_dir = 'TEST_DIR' self.conf.options = { config.MAP_PASSWORD: config.MapOptions(), config.MAP_AUTOMOUNT: config.MapOptions() } self.conf.options[config.MAP_PASSWORD].cache = {'name': 'dummy'} self.conf.options[config.MAP_PASSWORD].source = {'name': 'dummy'} self.conf.options[config.MAP_AUTOMOUNT].cache = {'name': 'dummy'} self.conf.options[config.MAP_AUTOMOUNT].source = {'name': 'dummy'} self.original_verify_configuration = config.VerifyConfiguration self.original_create = cache_factory.Create self.original_updater = map_updater.MapUpdater # stub this out for all tests map_updater.MapUpdater = DummyUpdater