def _setUp(self, allowAnon=False): self.config = _createDrupalAuthConfigFile(self.repoPath, allowAnon) self.app = Factory(self.config, self.pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory())
def testBasicPlugins(self): app = Factory(self.config) self.assertTrue(interfaces.IAuth.providedBy(app.getAuth())) self.assertTrue(interfaces.IRequestHandler.providedBy(app.getRequestHandler())) self.assertTrue(interfaces.IExceptionHandler.providedBy(app.getErrorHandler())) self.assertTrue(interfaces.IRepositoryRouter.providedBy(app.getRepositoryRouter()))
class AuthenticationTests(ApplicationTest): pluginPackages = { IAuth: authentication } def _generateRepositoryDirectory(self, name=None, dir=None): if name is None: return tempfile.mkdtemp('.git', 'tmp', dir) else: if dir is not None: path = dir + "/" + name + ".git" else: path = "/tmp/" + name + ".git" os.mkdir(path) return path def _testHTTP(self, user=None, name=None): self.repository.initialize() remoteRepository = self.createTemporaryRepository(name, self.repository.path, True) self.repository.addRemote("origin", formatRemote("http", self.http, remoteRepository.path.split('/')[-1], user)) self.generateComplicatedCommit() return remoteRepository def _testSSH(self, user, name=None): self.repository.initialize() remoteRepository = self.createTemporaryRepository(name, self.repository.path, True) self.repository.addRemote("origin", formatRemote("ssh", self.ssh, remoteRepository.path.split('/')[-1], user)) self.generateComplicatedCommit() return remoteRepository def _setUp(self, allowAnon=False): self.config = _createDrupalAuthConfigFile(self.repoPath, allowAnon) self.app = Factory(self.config, self.pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory()) def testInitialization(self): self._setUp() self.app._invariant() def tearDown(self): if self.ssh is not None: self.ssh.stopListening() if self.http is not None: self.http.stopListening() GitTestHelper.tearDown(self)
def testBasicExecution(self): app = Factory(self.config) ssh = reactor.listenTCP(0, app.createSSHFactory()) http = reactor.listenTCP(0, app.createHTTPFactory()) app._invariant() ssh.stopListening() http.stopListening()
def setUp(self): GitTestHelper.setUp(self) self.config = _createDefaultConfigFile(self.repoPath) pluginPackages = {IRepositoryRouter: plugins} self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory())
def setUp(self): GitTestHelper.setUp(self) self.config = _createDefaultConfigFile(self.repoPath) pluginPackages = { IRepositoryRouter: plugins } self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory())
class ApplicationTest(GitTestHelper): def setUp(self): GitTestHelper.setUp(self) self.config = _createDefaultConfigFile(self.repoPath) self.ssh = None self.http = None def startApplication(self, pluginPackages): self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory()) def tearDown(self): if self.ssh: self.ssh.stopListening() if self.http: self.http.stopListening() GitTestHelper.tearDown(self)
def testPluggedPlugins(self): pluginPackages = { IRequestHandler: plugins.default } app = Factory(self.config, pluginPackages) ssh = reactor.listenTCP(0, app.createSSHFactory()) http = reactor.listenTCP(0, app.createHTTPFactory()) app._invariant() self.assertTrue(app.getRequestHandler(), StubRequestHandler) ssh.stopListening() http.stopListening()
def startApplication(self, pluginPackages): self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory())
class RepositoryRouterTests(GitTestHelper): def setUp(self): GitTestHelper.setUp(self) self.config = _createDefaultConfigFile(self.repoPath) pluginPackages = {IRepositoryRouter: plugins} self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory()) def testInitialization(self): self.app._invariant() def testDefaultScheme(self): remoteRepository = self.createTemporaryRepository() path = self.app.getRepositoryRouter().route( self.app, ["DEFAULT", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) def testCustomScheme(self): projectPath = tempfile.mkdtemp() self.app.getConfig().add_section("project") self.app.getConfig().set("project", "repositoryPath", projectPath) remoteRepository = self.createTemporaryRepository(path=projectPath) path = self.app.getRepositoryRouter().route( self.app, ["project", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) shutil.rmtree(projectPath) def testMultipleCustomScheme(self): projectPath = tempfile.mkdtemp() sandboxPath = tempfile.mkdtemp() self.app.getConfig().add_section("project") self.app.getConfig().set("project", "repositoryPath", projectPath) self.app.getConfig().add_section("sandbox") self.app.getConfig().set("sandbox", "repositoryPath", sandboxPath) remoteProjectRepository = self.createTemporaryRepository( path=projectPath) path = self.app.getRepositoryRouter().route( self.app, ["project", remoteProjectRepository.path.split("/")[-1]]) self.assertEqual(path, remoteProjectRepository.path) remoteSandboxRepository = self.createTemporaryRepository( path=sandboxPath) path = self.app.getRepositoryRouter().route( self.app, ["sandbox", remoteSandboxRepository.path.split("/")[-1]]) self.assertEqual(path, remoteSandboxRepository.path) shutil.rmtree(projectPath) shutil.rmtree(sandboxPath) def testUnknownScheme(self): """This should default to the standard repository path.""" remoteRepository = self.createTemporaryRepository() path = self.app.getRepositoryRouter().route( self.app, ["project", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) def testUnknownRepository(self): path = self.app.getRepositoryRouter().route(self.app, ["DEFAULT", "drupal"]) self.assertEqual(path, None) def tearDown(self): self.ssh.stopListening() self.http.stopListening() GitTestHelper.tearDown(self)
class AuthenticationTests(ApplicationTest): pluginPackages = {IAuth: authentication} def _generateRepositoryDirectory(self, name=None, dir=None): if name is None: return tempfile.mkdtemp('.git', 'tmp', dir) else: if dir is not None: path = dir + "/" + name + ".git" else: path = "/tmp/" + name + ".git" os.mkdir(path) return path def _testHTTP(self, user=None, name=None): self.repository.initialize() remoteRepository = self.createTemporaryRepository( name, self.repository.path, True) self.repository.addRemote( "origin", formatRemote("http", self.http, remoteRepository.path.split('/')[-1], user)) self.generateComplicatedCommit() return remoteRepository def _testSSH(self, user, name=None): self.repository.initialize() remoteRepository = self.createTemporaryRepository( name, self.repository.path, True) self.repository.addRemote( "origin", formatRemote("ssh", self.ssh, remoteRepository.path.split('/')[-1], user)) self.generateComplicatedCommit() return remoteRepository def _setUp(self, allowAnon=False): self.config = _createDrupalAuthConfigFile(self.repoPath, allowAnon) self.app = Factory(self.config, self.pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory()) def testInitialization(self): self._setUp() self.app._invariant() def tearDown(self): if self.ssh is not None: self.ssh.stopListening() if self.http is not None: self.http.stopListening() GitTestHelper.tearDown(self)
class RepositoryRouterTests(GitTestHelper): def setUp(self): GitTestHelper.setUp(self) self.config = _createDefaultConfigFile(self.repoPath) pluginPackages = { IRepositoryRouter: plugins } self.app = Factory(self.config, pluginPackages) self.ssh = reactor.listenTCP(0, self.app.createSSHFactory()) self.http = reactor.listenTCP(0, self.app.createHTTPFactory()) def testInitialization(self): self.app._invariant() def testDefaultScheme(self): remoteRepository = self.createTemporaryRepository() path = self.app.getRepositoryRouter().route(self.app, ["DEFAULT", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) def testCustomScheme(self): projectPath = tempfile.mkdtemp() self.app.getConfig().add_section("project") self.app.getConfig().set("project", "repositoryPath", projectPath) remoteRepository = self.createTemporaryRepository(path=projectPath) path = self.app.getRepositoryRouter().route(self.app, ["project", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) shutil.rmtree(projectPath) def testMultipleCustomScheme(self): projectPath = tempfile.mkdtemp() sandboxPath = tempfile.mkdtemp() self.app.getConfig().add_section("project") self.app.getConfig().set("project", "repositoryPath", projectPath) self.app.getConfig().add_section("sandbox") self.app.getConfig().set("sandbox", "repositoryPath", sandboxPath) remoteProjectRepository = self.createTemporaryRepository(path=projectPath) path = self.app.getRepositoryRouter().route(self.app, ["project", remoteProjectRepository.path.split("/")[-1]]) self.assertEqual(path, remoteProjectRepository.path) remoteSandboxRepository = self.createTemporaryRepository(path=sandboxPath) path = self.app.getRepositoryRouter().route(self.app, ["sandbox", remoteSandboxRepository.path.split("/")[-1]]) self.assertEqual(path, remoteSandboxRepository.path) shutil.rmtree(projectPath) shutil.rmtree(sandboxPath) def testUnknownScheme(self): """This should default to the standard repository path.""" remoteRepository = self.createTemporaryRepository() path = self.app.getRepositoryRouter().route(self.app, ["project", remoteRepository.path.split("/")[-1]]) self.assertEqual(path, remoteRepository.path) def testUnknownRepository(self): path = self.app.getRepositoryRouter().route(self.app, ["DEFAULT", "drupal"]) self.assertEqual(path, None) def tearDown(self): self.ssh.stopListening() self.http.stopListening() GitTestHelper.tearDown(self)