test/unit/file_mio_test.rb in masterview-0.2.5 vs test/unit/file_mio_test.rb in masterview-0.3.0
- old
+ new
@@ -3,12 +3,17 @@
require 'test/unit'
currentPath = File.dirname(__FILE__)
require File.join( currentPath, '../../lib/masterview/io' )
class TestFileMIO < Test::Unit::TestCase
- include MasterView
+ # bring test subjects into the local name space
+ MIOTrees = MasterView::MIO::MIOTrees
+ FileMIOTree = MasterView::MIO::FileMIOTree
+ FileMIO = MasterView::MIO::FileMIO
+ InvalidIOPathError = MasterView::InvalidIOPathError
+
MVTestDir = File.expand_path( File.join(File.dirname(__FILE__), '..' ) )
TemplateDir = "#{MVTestDir}/tmp/template"
TemplateErbDir = "#{MVTestDir}/tmp/erb"
TestFileMIOTemplatePathname = Pathname.new(TemplateDir)
@@ -37,21 +42,21 @@
# Test Cases
#------------------------------------------------------------------------------
# ensure that sandbox limits writing to files outside of root path even if dot dot exists in path
def test_sandbox_dotdot
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '../bad') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/../dog/../../foo') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/../../foo') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/cat/../../../dog') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '/bad/foo') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '/bad') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '../bad.cat') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/../dot/../../foo.cat') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/../../foo.cat') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( 'bad/cat/../../../dog.cat') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '/bad/foo.cat') }
- assert_raise(InvalidPathError){ f = IOMgr.template.path( '/bad.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '../bad') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../dog/../../foo') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../../foo') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/cat/../../../dog') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '/bad/foo') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '/bad') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '../bad.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../dot/../../foo.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/../../foo.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( 'bad/cat/../../../dog.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '/bad/foo.cat') }
+ assert_raise(InvalidIOPathError){ f = IOMgr.template.path( '/bad.cat') }
end
def test_create_foo
verify_mio_handler_paths( 'foo', IOMgr.template, TemplateDir )
end