diff options
| author | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-08 14:52:59 +0000 |
|---|---|---|
| committer | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-08 14:52:59 +0000 |
| commit | 8f3bd02517e55faa15481069b05708c78920af44 (patch) | |
| tree | a98f744329f7f46038c51b8205618d20888a2453 /test | |
| parent | 543a0737339ffc3bfd5ad6439eaa63fe5196059d (diff) | |
| download | ruby-8f3bd02517e55faa15481069b05708c78920af44.tar.gz ruby-8f3bd02517e55faa15481069b05708c78920af44.tar.xz ruby-8f3bd02517e55faa15481069b05708c78920af44.zip | |
* lib/cgi/session.rb (FileStore): use marshalized data.
* test/cgi/session_dir: add a session directory in test.
* test/cgi/test_cgi_session.rb: add a test.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rwxr-xr-x | test/cgi/test_cgi_session.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_session.rb b/test/cgi/test_cgi_session.rb new file mode 100755 index 000000000..918338c87 --- /dev/null +++ b/test/cgi/test_cgi_session.rb @@ -0,0 +1,59 @@ +require 'test/unit' +require 'cgi' +require 'cgi/session' +require 'stringio' +def d(obj) + STDERR.write(obj.inspect+"\n") +end + + +class CGISessionTest < Test::Unit::TestCase + + + def setup + FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*")) + end + + + def teardown + @environ.each do |key, val| ENV.delete(key) end + $stdout = STDOUT +# FileUtils.rm(Dir::glob(File.dirname(__FILE__)+"/session_dir/*")) + end + + def test_cgi_session_core + @environ = { + 'REQUEST_METHOD' => 'GET', + # 'QUERY_STRING' => 'id=123&id=456&id=&str=%40h+%3D%7E+%2F%5E%24%2F', + # 'HTTP_COOKIE' => '_session_id=12345; name1=val1&val2;', + 'SERVER_SOFTWARE' => 'Apache 2.2.0', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + } + ENV.update(@environ) + cgi = CGI.new + session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir") + session["key1"]="value1" + session["key2"]="\x8F\xBC\x8D]".force_encoding("SJIS") + assert_equal("value1",session["key1"]) + assert_equal("\x8F\xBC\x8D]".force_encoding("SJIS"),session["key2"]) + session.close + $stdout = StringIO.new + cgi.out{""} + + @environ = { + 'REQUEST_METHOD' => 'GET', + # 'HTTP_COOKIE' => "_session_id=#{session_id}", + 'QUERY_STRING' => "_session_id=#{session.session_id}", + 'SERVER_SOFTWARE' => 'Apache 2.2.0', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + } + ENV.update(@environ) + cgi = CGI.new + session = CGI::Session.new(cgi,"tmpdir"=>File.dirname(__FILE__)+"/session_dir") + $stdout = StringIO.new + assert_equal("value1",session["key1"]) + assert_equal("\x8F\xBC\x8D]".force_encoding("SJIS"),session["key2"]) + session.close + + end +end |
