def setUp(self): super(ModificationTestCase, self).setUp() testRoot = os.path.join(os.path.dirname(__file__), "modify") #configFileName = os.path.join(testRoot, "caldavd.plist") #config.load(configFileName) usersFile = os.path.join(testRoot, "users-groups.xml") config.DirectoryService.params.xmlFile = usersFile # Copy xml file containing locations/resources to a temp file because # we're going to be modifying it during testing origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__), "modify", "resources-locations.xml")) copyResourcesFile = FilePath(self.mktemp()) origResourcesFile.copyTo(copyResourcesFile) config.ResourceService.params.xmlFile = copyResourcesFile config.ResourceService.Enabled = True augmentsFile = os.path.join(testRoot, "augments.xml") config.AugmentService.params.xmlFiles = (augmentsFile,)
def setUp(self): super(ManagePrincipalsTestCase, self).setUp() testRoot = os.path.join(os.path.dirname(__file__), "principals") templateName = os.path.join(testRoot, "caldavd.plist") with open(templateName) as templateFile: template = templateFile.read() databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid())) newConfig = template % { "ServerRoot": os.path.abspath(config.ServerRoot), "DataRoot": os.path.abspath(config.DataRoot), "DatabaseRoot": databaseRoot, "DocumentRoot": os.path.abspath(config.DocumentRoot), "LogRoot": os.path.abspath(config.LogRoot), } configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist")) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) origUsersFile = FilePath( os.path.join( os.path.dirname(__file__), "principals", "users-groups.xml" ) ) copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml")) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath( os.path.join( os.path.dirname(__file__), "principals", "resources-locations.xml" ) ) copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml")) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath( os.path.join( os.path.dirname(__file__), "principals", "augments.xml" ) ) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) # Make sure trial puts the reactor in the right state, by letting it # run one reactor iteration. (Ignore me, please.) d = Deferred() reactor.callLater(0, d.callback, True) return d
def setUp(self): super(ManagePrincipalsTestCase, self).setUp() # Since this test operates on proxy db, we need to assign the service: calendaruserproxy.ProxyDBService = calendaruserproxy.ProxySqliteDB(os.path.abspath(self.mktemp())) config.GlobalAddressBook.Enabled = False testRoot = os.path.join(os.path.dirname(__file__), "principals") templateName = os.path.join(testRoot, "caldavd.plist") templateFile = open(templateName) template = templateFile.read() templateFile.close() databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid())) newConfig = template % { "ServerRoot" : os.path.abspath(config.ServerRoot), "DataRoot" : os.path.abspath(config.DataRoot), "DatabaseRoot" : databaseRoot, "DocumentRoot" : os.path.abspath(config.DocumentRoot), "LogRoot" : os.path.abspath(config.LogRoot), } configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist")) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) origUsersFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "users-groups.xml")) copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml")) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "resources-locations.xml")) copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml")) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "augments.xml")) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) # Make sure trial puts the reactor in the right state, by letting it # run one reactor iteration. (Ignore me, please.) d = Deferred() reactor.callLater(0, d.callback, True) return d
def setUp(self): super(RunCommandTestCase, self).setUp() testRoot = os.path.join(os.path.dirname(__file__), "gateway") templateName = os.path.join(testRoot, "caldavd.plist") templateFile = open(templateName) template = templateFile.read() templateFile.close() databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid())) newConfig = template % { "ServerRoot" : os.path.abspath(config.ServerRoot), "DatabaseRoot" : databaseRoot, "WritablePlist" : os.path.join(os.path.abspath(config.ConfigRoot), "caldavd-writable.plist"), } configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist")) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) origUsersFile = FilePath(os.path.join(os.path.dirname(__file__), "gateway", "users-groups.xml")) copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml")) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__), "gateway", "resources-locations.xml")) copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml")) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath(os.path.join(os.path.dirname(__file__), "gateway", "augments.xml")) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) # Make sure trial puts the reactor in the right state, by letting it # run one reactor iteration. (Ignore me, please.) d = Deferred() reactor.callLater(0, d.callback, True) return d
def setUp(self): super(ManagePrincipalsTestCase, self).setUp() config.GlobalAddressBook.Enabled = False testRoot = os.path.join(os.path.dirname(__file__), "principals") templateName = os.path.join(testRoot, "caldavd.plist") templateFile = open(templateName) template = templateFile.read() templateFile.close() newConfig = template % { "ServerRoot" : os.path.abspath(config.ServerRoot), } configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist")) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) origUsersFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "users-groups.xml")) copyUsersFile = FilePath(os.path.join(config.DataRoot, "accounts.xml")) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "resources-locations.xml")) copyResourcesFile = FilePath(os.path.join(config.DataRoot, "resources.xml")) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath(os.path.join(os.path.dirname(__file__), "principals", "augments.xml")) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) # Make sure trial puts the reactor in the right state, by letting it # run one reactor iteration. (Ignore me, please.) d = Deferred() reactor.callLater(0, d.callback, True) return d
def setUp(self): super(DeprovisionTestCase, self).setUp() testRootPath = FilePath(__file__).sibling("deprovision") template = testRootPath.child("caldavd.plist").getContent() newConfig = template % { "ServerRoot" : os.path.abspath(config.ServerRoot), } configFilePath = FilePath(os.path.join(config.ConfigRoot, "caldavd.plist")) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) origUsersFile = FilePath(__file__).sibling( "deprovision").child("users-groups.xml") copyUsersFile = FilePath(config.DataRoot).child("accounts.xml") origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath(__file__).sibling( "deprovision").child("resources-locations.xml") copyResourcesFile = FilePath(config.DataRoot).child("resources.xml") origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath(__file__).sibling( "deprovision").child("augments.xml") copyAugmentFile = FilePath(config.DataRoot).child("augments.xml") origAugmentFile.copyTo(copyAugmentFile) self.rootResource = getRootResource(config) self.directory = self.rootResource.getDirectory() # Make sure trial puts the reactor in the right state, by letting it # run one reactor iteration. (Ignore me, please.) d = Deferred() reactor.callLater(0, d.callback, True) return d
def setUp(self): self.serverRoot = self.mktemp() os.mkdir(self.serverRoot) self.absoluteServerRoot = os.path.abspath(self.serverRoot) configRoot = os.path.join(self.absoluteServerRoot, "Config") if not os.path.exists(configRoot): os.makedirs(configRoot) dataRoot = os.path.join(self.absoluteServerRoot, "Data") if not os.path.exists(dataRoot): os.makedirs(dataRoot) documentRoot = os.path.join(self.absoluteServerRoot, "Documents") if not os.path.exists(documentRoot): os.makedirs(documentRoot) logRoot = os.path.join(self.absoluteServerRoot, "Logs") if not os.path.exists(logRoot): os.makedirs(logRoot) runRoot = os.path.join(self.absoluteServerRoot, "Run") if not os.path.exists(runRoot): os.makedirs(runRoot) config.reset() testRoot = os.path.join(os.path.dirname(__file__), "gateway") templateName = os.path.join(testRoot, "caldavd.plist") with open(templateName) as templateFile: template = templateFile.read() databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid())) newConfig = template % { "ServerRoot": self.absoluteServerRoot, "DataRoot": dataRoot, "DatabaseRoot": databaseRoot, "DocumentRoot": documentRoot, "ConfigRoot": configRoot, "LogRoot": logRoot, "RunRoot": runRoot, "WritablePlist": os.path.join( os.path.abspath(configRoot), "caldavd-writable.plist" ), } configFilePath = FilePath( os.path.join(configRoot, "caldavd.plist") ) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) config.Memcached.Pools.Default.ClientEnabled = False config.Memcached.Pools.Default.ServerEnabled = False ClientFactory.allowTestCache = True memcacher.Memcacher.allowTestCache = True memcacher.Memcacher.reset() config.DirectoryAddressBook.Enabled = False config.UsePackageTimezones = True origUsersFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "users-groups.xml" ) ) copyUsersFile = FilePath( os.path.join(config.DataRoot, "accounts.xml") ) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "resources-locations.xml" ) ) copyResourcesFile = FilePath( os.path.join(config.DataRoot, "resources.xml") ) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "augments.xml" ) ) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) self.notifierFactory = StubNotifierFactory() self.store = yield theStoreBuilder.buildStore(self, self.notifierFactory) self.directory = directoryFromConfig(config, self.store)
def setUp(self): self.serverRoot = self.mktemp() os.mkdir(self.serverRoot) self.absoluteServerRoot = os.path.abspath(self.serverRoot) configRoot = os.path.join(self.absoluteServerRoot, "Config") if not os.path.exists(configRoot): os.makedirs(configRoot) dataRoot = os.path.join(self.absoluteServerRoot, "Data") if not os.path.exists(dataRoot): os.makedirs(dataRoot) documentRoot = os.path.join(self.absoluteServerRoot, "Documents") if not os.path.exists(documentRoot): os.makedirs(documentRoot) logRoot = os.path.join(self.absoluteServerRoot, "Logs") if not os.path.exists(logRoot): os.makedirs(logRoot) runRoot = os.path.join(self.absoluteServerRoot, "Run") if not os.path.exists(runRoot): os.makedirs(runRoot) config.reset() testRoot = os.path.join(os.path.dirname(__file__), "gateway") templateName = os.path.join(testRoot, "caldavd.plist") templateFile = open(templateName) template = templateFile.read() templateFile.close() databaseRoot = os.path.abspath("_spawned_scripts_db" + str(os.getpid())) newConfig = template % { "ServerRoot": self.absoluteServerRoot, "DataRoot": dataRoot, "DatabaseRoot": databaseRoot, "DocumentRoot": documentRoot, "ConfigRoot": configRoot, "LogRoot": logRoot, "RunRoot": runRoot, "WritablePlist": os.path.join( os.path.abspath(configRoot), "caldavd-writable.plist" ), } configFilePath = FilePath( os.path.join(configRoot, "caldavd.plist") ) configFilePath.setContent(newConfig) self.configFileName = configFilePath.path config.load(self.configFileName) config.Memcached.Pools.Default.ClientEnabled = False config.Memcached.Pools.Default.ServerEnabled = False ClientFactory.allowTestCache = True memcacher.Memcacher.allowTestCache = True memcacher.Memcacher.reset() config.DirectoryAddressBook.Enabled = False config.UsePackageTimezones = True origUsersFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "users-groups.xml" ) ) copyUsersFile = FilePath( os.path.join(config.DataRoot, "accounts.xml") ) origUsersFile.copyTo(copyUsersFile) origResourcesFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "resources-locations.xml" ) ) copyResourcesFile = FilePath( os.path.join(config.DataRoot, "resources.xml") ) origResourcesFile.copyTo(copyResourcesFile) origAugmentFile = FilePath( os.path.join( os.path.dirname(__file__), "gateway", "augments.xml" ) ) copyAugmentFile = FilePath(os.path.join(config.DataRoot, "augments.xml")) origAugmentFile.copyTo(copyAugmentFile) self.notifierFactory = StubNotifierFactory() self.store = yield theStoreBuilder.buildStore(self, self.notifierFactory) self.directory = directoryFromConfig(config, self.store)