def test_filter_setuptest_filter_setuptest_filter_setuptest_filter_setup
@properties['documents'] = [
{ 'document' => 'Page',
'arguments' => [
"Hello world.\n",
'text/html'
],
'mount_path' => '/',
'mount_mask' => nil,
'virtual_host' => nil
},
{ 'document' => 'Page',
'arguments' => [
"Hello virtual world.\n",
'text/html'
],
'mount_path' => '/',
'mount_mask' => nil,
'virtual_host' => 'baz'
}
]
page = Object.new
class << page
include RUNIT::Assert
def doc_name
'Page'
end
def doc_args
[ [ 'content', :text, nil ],
[ 'content-type', :string, 'text/html' ]
]
end
def new(content, content_type)
assert(content == "Hello world.\n" ||
content == "Hello virtual world.\n")
assert_equal('text/html', content_type)
:dummy_page_document
end
end
@factory.add_document(page)
@properties['filters'] = [
{ 'filter' => 'ERB',
'arguments' => [
1
],
'attach_path' => '/foo',
'attach_mask' => %"\.rhtml?($|/)",
'virtual_host' => nil
},
{ 'filter' => 'SSI',
'arguments' => [
{ 'config' => true,
'include' => true,
'echo' => true,
'fsize' => true,
'flastmod' => true,
'exec' => true
}
],
'attach_path' => '/bar',
'attach_mask' => %"\.shtml?($|/)",
'virtual_host' => 'baz'
}
]
erb = Object.new
class << erb
include RUNIT::Assert
def filter_name
'ERB'
end
def filter_args
[ [ 'safe level', :number, 1 ] ]
end
def new(safe_level)
assert_equal(1, safe_level)
:dummy_ERB_document
end
end
@factory.add_filter(erb)
ssi = Object.new
class << ssi
include RUNIT::Assert
def filter_name
'SSI'
end
def filter_args
[ [ 'SSI commands', :checkset,
[ [ 'config', true ],
[ 'include', true ],
[ 'echo', true ],
[ 'fsize', true ],
[ 'flastmod', true ],
[ 'exec', true ]
]
]
]
end
def new(cmds)
assert_equal({ 'config' => true,
'include' => true,
'echo' => true,
'fsize' => true,
'flastmod' => true,
'exec' => true
}, cmds)
:dummy_SSI_document
end
end
@factory.add_filter(ssi)
build_control
@control.server_setup(self)
assert_equal(2, @attach_call)
assert_equal(1, @virtual_attach_call)
assert_equal(:dummy_ERB_document, @folder.find('/foo/index.rhtml')[0].filter)
assert_equal('/foo', @folder.find('/foo/index.rhtml')[1])
assert_equal(:dummy_SSI_document, @folder.virtual_find('baz:8888', '/bar/index.shtml')[0].filter)
assert_equal('/bar', @folder.virtual_find('baz:8888', '/bar/index.shtml')[1])
end