def test_04_existing_file_modified_over_limit(self): repo = self.create_repo() conf = repo.conf pattern = '\.txt$' dot() conf.set_max_file_size_exclusion_regex(pattern) conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = { '512-then-1025-bytes.txt': bulk_chargen(512) } repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/512-then-1025-bytes.txt') svn.ci('trunk', m='Permitted...') dot() tree = { '512-then-1025-bytes.txt': bulk_chargen(1025) } repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.ci('trunk', m='Permitted...')
def test_01_under_then_over(self): repo = self.create_repo() conf = repo.conf dot() conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = { '512-then-1025-bytes.txt': bulk_chargen(512) } repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/512-then-1025-bytes.txt') svn.ci('trunk', m='Permitted...') dot() tree = { '512-then-1025-bytes.txt': bulk_chargen(1025) } repo.build(tree, prefix='trunk') error = format_file_exceeds_max_size_error(1025, 1024) with chdir(repo.wc): dot() with ensure_blocked(self, error): svn.ci('trunk', m='At limit')
def test_04_existing_file_modified_over_limit(self): repo = self.create_repo() conf = repo.conf pattern = '\.txt$' dot() conf.set_max_file_size_exclusion_regex(pattern) conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = {'512-then-1025-bytes.txt': bulk_chargen(512)} repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/512-then-1025-bytes.txt') svn.ci('trunk', m='Permitted...') dot() tree = {'512-then-1025-bytes.txt': bulk_chargen(1025)} repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.ci('trunk', m='Permitted...')
def test_01_under_then_over(self): repo = self.create_repo() conf = repo.conf dot() conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = {'512-then-1025-bytes.txt': bulk_chargen(512)} repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/512-then-1025-bytes.txt') svn.ci('trunk', m='Permitted...') dot() tree = {'512-then-1025-bytes.txt': bulk_chargen(1025)} repo.build(tree, prefix='trunk') error = format_file_exceeds_max_size_error(1025, 1024) with chdir(repo.wc): dot() with ensure_blocked(self, error): svn.ci('trunk', m='At limit')
def test_02_set_repo_readonly(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin is_repo_readonly = evnadmin.is_repo_readonly set_repo_readonly = evnadmin.set_repo_readonly unset_repo_readonly = evnadmin.unset_repo_readonly dot() expected = 'no' actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) tree = {'test1.txt': bulk_chargen(100)} repo.build(tree, prefix='trunk') dot() with chdir(repo.wc): dot() svn.add('trunk/test1.txt') dot() svn.ci('trunk', m='Adding test1.txt') dot() set_repo_readonly(repo.path) dot() expected = 'yes' actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) dot() tree = { 'test2.txt': bulk_chargen(200), } repo.build(tree, prefix='trunk') error = 'This repository cannot be committed to at the present time' with ensure_blocked(self, error): with chdir(repo.wc): dot() svn.add('trunk/test2.txt') dot() svn.ci('trunk', m='Adding test2.txt') dot() unset_repo_readonly(repo.path) dot() expected = 'no' actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) dot() with chdir(repo.wc): dot() dot() svn.ci('trunk', m='Adding test2.txt')
def test_02_set_repo_readonly(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin is_repo_readonly = evnadmin.is_repo_readonly set_repo_readonly = evnadmin.set_repo_readonly unset_repo_readonly = evnadmin.unset_repo_readonly dot() expected = "no" actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) tree = {"test1.txt": bulk_chargen(100)} repo.build(tree, prefix="trunk") dot() with chdir(repo.wc): dot() svn.add("trunk/test1.txt") dot() svn.ci("trunk", m="Adding test1.txt") dot() set_repo_readonly(repo.path) dot() expected = "yes" actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) dot() tree = {"test2.txt": bulk_chargen(200)} repo.build(tree, prefix="trunk") error = "This repository cannot be committed to at the present time" with ensure_blocked(self, error): with chdir(repo.wc): dot() svn.add("trunk/test2.txt") dot() svn.ci("trunk", m="Adding test2.txt") dot() unset_repo_readonly(repo.path) dot() expected = "no" actual = is_repo_readonly(repo.path) self.assertEqual(expected, actual) dot() with chdir(repo.wc): dot() dot() svn.ci("trunk", m="Adding test2.txt")
def test_03_rename(self): repo = self.create_repo() conf = repo.conf svn = repo.svn dot() tree = { 'test.txt': bulk_chargen(100), } repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/test.txt') dot() svn.ci('trunk/test.txt', m='Adding test.txt...') dot() error = e.BlockedFileExtension with chdir(repo.wc): svn.mv('trunk/test.txt', 'trunk/test.dll') dot() with ensure_blocked(self, error): svn.ci('trunk', m='Renaming test.txt to test.dll...') dot()
def test_01_under_limit(self): repo = self.create_repo() conf = repo.conf conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = { '1000-bytes.txt': bulk_chargen(1000), '1023-bytes.txt': bulk_chargen(1023), } repo.build(tree, prefix='trunk') with chdir(repo.wc): dot() svn.add('trunk/1000-bytes.txt') dot() svn.add('trunk/1023-bytes.txt') svn.ci('trunk', m='Adding files under limit...')
def test_02_add_new(self): repo = self.create_repo() conf = repo.conf svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = { 'test.dll': bulk_chargen(100), } repo.build(tree, prefix='trunk') error = e.BlockedFileExtension with chdir(repo.wc): dot() svn.add('trunk/test.dll') with ensure_blocked(self, error): svn.ci('trunk/test.dll', m='Adding test.dll...')
def test_01_over_limit(self): repo = self.create_repo() conf = repo.conf conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() over = 1025 tree = {'over.txt': bulk_chargen(over)} repo.build(tree, prefix='trunk') error = format_file_exceeds_max_size_error(over, 1024) with chdir(repo.wc): dot() svn.add('trunk/over.txt') with ensure_blocked(self, error): svn.ci('trunk', m='Over limit')
def test_01_over_limit(self): repo = self.create_repo() conf = repo.conf conf.set_max_file_size_in_bytes(1024) svn = repo.svn #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() over = 1025 tree = { 'over.txt': bulk_chargen(over) } repo.build(tree, prefix='trunk') error = format_file_exceeds_max_size_error(over, 1024) with chdir(repo.wc): dot() svn.add('trunk/over.txt') with ensure_blocked(self, error): svn.ci('trunk', m='Over limit')
def test_02_non_exempt(self): repo = self.create_repo() conf = repo.conf conf.set('main', 'exempt-symlinks-from-blocked-file-extensions', '0') conf.save() svn = repo.svn dot() self.assertFalse(conf.exempt_symlinks_from_blocked_file_extensions) dot() tree = { 'target': bulk_chargen(100) } repo.build(tree, prefix='trunk') trunk = join_path(repo.wc, 'trunk') error = e.BlockedFileExtension with chdir(trunk): dot() os.symlink('target', 'target.so') svn.add('target.so') with ensure_blocked(self, error): svn.ci('target.so', m='Adding symlink.')
def test_02_non_exempt(self): repo = self.create_repo() conf = repo.conf conf.set('main', 'exempt-symlinks-from-blocked-file-extensions', '0') conf.save() svn = repo.svn dot() self.assertFalse(conf.exempt_symlinks_from_blocked_file_extensions) dot() tree = {'target': bulk_chargen(100)} repo.build(tree, prefix='trunk') trunk = join_path(repo.wc, 'trunk') error = e.BlockedFileExtension with chdir(trunk): dot() os.symlink('target', 'target.so') svn.add('target.so') with ensure_blocked(self, error): svn.ci('target.so', m='Adding symlink.')
def test_01_exempt(self): repo = self.create_repo() conf = repo.conf svn = repo.svn dot() self.assertTrue(conf.exempt_symlinks_from_blocked_file_extensions) #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = {'target': bulk_chargen(100)} repo.build(tree, prefix='trunk') trunk = join_path(repo.wc, 'trunk') error = e.BlockedFileExtension with chdir(trunk): dot() os.symlink('target', 'target.so') self.assertTrue(os.path.islink('target.so')) svn.add('target') svn.add('target.so') svn.ci('.', m='Adding target + symlink.') dot() svn.mv('target', 'target.dll') with ensure_blocked(self, error): svn.ci('.', m='Renaming target...') dot() svn.revert('target', 'target.dll') dot() os.rename('target.so', 'target.exe') self.assertTrue(os.path.islink('target.exe')) #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') svn.rm('target.so') svn.add('target.exe') svn.ci('.', m='Renaming target.so to target.exe.')
def test_01_exempt(self): repo = self.create_repo() conf = repo.conf svn = repo.svn dot() self.assertTrue(conf.exempt_symlinks_from_blocked_file_extensions) #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') dot() tree = { 'target': bulk_chargen(100) } repo.build(tree, prefix='trunk') trunk = join_path(repo.wc, 'trunk') error = e.BlockedFileExtension with chdir(trunk): dot() os.symlink('target', 'target.so') self.assertTrue(os.path.islink('target.so')) svn.add('target') svn.add('target.so') svn.ci('.', m='Adding target + symlink.') dot() svn.mv('target', 'target.dll') with ensure_blocked(self, error): svn.ci('.', m='Renaming target...') dot() svn.revert('target', 'target.dll') dot() os.rename('target.so', 'target.exe') self.assertTrue(os.path.islink('target.exe')) #evnadmin = repo.evnadmin #evnadmin.enable_remote_debug(repo.path, hook='pre-commit') svn.rm('target.so') svn.add('target.exe') svn.ci('.', m='Renaming target.so to target.exe.')
def test_01(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin dot() error = e.TagDirectoryCreatedManually with ensure_blocked(self, error): svn.mkdir(repo.ra('/tags/1.x/'), m='Create tag manually') dot() evnadmin.disable(repo.name) svn.mkdir(repo.ra('/tags/1.x/'), m='Create tag manually2') dot() evn_props_r2_expected = { 'errors': { '/tags/1.x/': [e.TagDirectoryCreatedManually], }, 'roots': { '/trunk/': { 'created': 1 }, }, } evnadmin.enable(repo.name) self.assertEqual(repo.revprops_at(2)['evn'], evn_props_r2_expected) dot() evnadmin.set_repo_readonly(repo.name) dot() evnadmin.add_root_hint( repo.name, path='/tags/1.x/', revision='2', root_type='tag', ) evnadmin.analyze(repo.name) dot() evnadmin.unset_repo_readonly(repo.name) dot() evn_props_r2_expected = { 'roots': { '/trunk/': { 'created': 1 }, '/tags/1.x/': { 'created': 2, 'copies': {}, 'creation_method': 'created', }, }, } self.assertEqual(repo.revprops_at(2)['evn'], evn_props_r2_expected) dot() svn.up(repo.wc) dot() error = e.TagModified tagdir = join_path(repo.wc, 'tags/1.x') with chdir(tagdir): tree = {'test.txt': bulk_chargen(100)} repo.build(tree, prefix='tags/1.x') dot() svn.add('test.txt') with ensure_blocked(self, error): dot() svn.ci('test.txt', m='Modifying tag') dot() error = e.TagRemoved with ensure_blocked(self, error): svn.rm(repo.ra('tags/1.x'), m='Deleting tag.') dot() error = e.TagRenamed with ensure_blocked(self, error): svn.mv(repo.ra('tags/1.x'), repo.ra('tags/2.x'), m='Renaming tag.') dot() error = e.TagCopied with ensure_blocked(self, error): svn.copy(repo.ra('tags/1.x'), repo.ra('tags/2.x'), m='Copying tag.')
def test_01(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin evnadmin.disable(repo.path) dot() tree = {'foo/moo/bar.txt': bulk_chargen(100)} repo.build(tree, prefix='branches') with chdir(repo.wc): # r2 svn.add('branches/foo') svn.ci('branches/foo', m='Initializing foo component.') dot() evnadmin.enable(repo.path) error = 'valid root subtree path renamed to valid root path' with ensure_blocked(self, error): svn.mv(repo.ra('/branches/foo/moo'), repo.ra('/branches/bar/'), m='Branch') dot() evnadmin.disable(repo.path) # r3 svn.mv(repo.ra('/branches/foo/moo/'), repo.ra('/branches/bar/'), m='Branch') dot() evn_props_r3_expected = { 'errors': { '/branches/bar/': [error], }, 'roots': { '/trunk/': { 'created': 1 }, }, } evnadmin.enable(repo.name) self.assertEqual(repo.revprops_at(3)['evn'], evn_props_r3_expected) dot() evnadmin.set_repo_readonly(repo.name) dot() evnadmin.add_root_hint( repo.name, path='/branches/bar/', revision='3', root_type='branch', ) evnadmin.enable(repo.name) dot() evnadmin.unset_repo_readonly(repo.name) dot() evn_props_r3_expected = { 'roots': { '/trunk/': { 'created': 1 }, '/branches/bar/': { 'copies': {}, 'created': 3, 'creation_method': 'renamed', 'renamed_from': ('/branches/foo/moo/', 2), }, }, } self.assertEqual(repo.revprops_at(3)['evn'], evn_props_r3_expected)
def test_01(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin dot() error = e.TagDirectoryCreatedManually with ensure_blocked(self, error): svn.mkdir(repo.ra('/tags/1.x/'), m='Create tag manually') dot() evnadmin.disable(repo.name) svn.mkdir(repo.ra('/tags/1.x/'), m='Create tag manually2') dot() evn_props_r2_expected = { 'errors': { '/tags/1.x/': [ e.TagDirectoryCreatedManually ], }, 'roots': { '/trunk/': { 'created': 1 }, }, } evnadmin.enable(repo.name) self.assertEqual(repo.revprops_at(2)['evn'], evn_props_r2_expected) dot() evnadmin.set_repo_readonly(repo.name) dot() evnadmin.add_root_hint( repo.name, path='/tags/1.x/', revision='2', root_type='tag', ) evnadmin.analyze(repo.name) dot() evnadmin.unset_repo_readonly(repo.name) dot() evn_props_r2_expected = { 'roots': { '/trunk/': { 'created': 1 }, '/tags/1.x/': { 'created': 2, 'copies': {}, 'creation_method': 'created', }, }, } self.assertEqual(repo.revprops_at(2)['evn'], evn_props_r2_expected) dot() svn.up(repo.wc) dot() error = e.TagModified tagdir = join_path(repo.wc, 'tags/1.x') with chdir(tagdir): tree = { 'test.txt': bulk_chargen(100) } repo.build(tree, prefix='tags/1.x') dot() svn.add('test.txt') with ensure_blocked(self, error): dot() svn.ci('test.txt', m='Modifying tag') dot() error = e.TagRemoved with ensure_blocked(self, error): svn.rm(repo.ra('tags/1.x'), m='Deleting tag.') dot() error = e.TagRenamed with ensure_blocked(self, error): svn.mv(repo.ra('tags/1.x'), repo.ra('tags/2.x'), m='Renaming tag.') dot() error = e.TagCopied with ensure_blocked(self, error): svn.copy(repo.ra('tags/1.x'), repo.ra('tags/2.x'), m='Copying tag.')
def test_01(self): repo = self.create_repo() svn = repo.svn evnadmin = repo.evnadmin evnadmin.disable(repo.path) dot() tree = { 'foo/moo/bar.txt': bulk_chargen(100) } repo.build(tree, prefix='branches') with chdir(repo.wc): # r2 svn.add('branches/foo') svn.ci('branches/foo', m='Initializing foo component.') dot() evnadmin.enable(repo.path) error = 'valid root subtree path renamed to valid root path' with ensure_blocked(self, error): svn.mv(repo.ra('/branches/foo/moo'), repo.ra('/branches/bar/'), m='Branch') dot() evnadmin.disable(repo.path) # r3 svn.mv(repo.ra('/branches/foo/moo/'), repo.ra('/branches/bar/'), m='Branch') dot() evn_props_r3_expected = { 'errors': { '/branches/bar/': [ error ], }, 'roots': { '/trunk/': { 'created': 1 }, }, } evnadmin.enable(repo.name) self.assertEqual(repo.revprops_at(3)['evn'], evn_props_r3_expected) dot() evnadmin.set_repo_readonly(repo.name) dot() evnadmin.add_root_hint( repo.name, path='/branches/bar/', revision='3', root_type='branch', ) evnadmin.enable(repo.name) dot() evnadmin.unset_repo_readonly(repo.name) dot() evn_props_r3_expected = { 'roots': { '/trunk/': { 'created': 1 }, '/branches/bar/': { 'copies': {}, 'created': 3, 'creation_method': 'renamed', 'renamed_from': ('/branches/foo/moo/', 2), }, }, } self.assertEqual(repo.revprops_at(3)['evn'], evn_props_r3_expected)