[Nitro] two way crypt function
Trans
transfire at gmail.com
Sun Nov 11 15:00:25 EST 2007
On Nov 11, 1:07 pm, "George Moschovitis"
<george.moschovi... at gmail.com> wrote:
> I have added all the debugging aids. This bug is random and I still cannot
> understand why it happens.
> the offending code is:
>
> lib/raw/context/session/cookie.rb
Add this to the end of that file:
if __FILE__ == $0
BEGIN {
require "facets"
require "facets/random"
require "cgi"
require "raw/context/session"
require "raw/controller/cookie"
}
require "test/unit"
class TestCookie < Test::Unit::TestCase
class MockContext
def initialize
@cookies = {}
@data = {}
end
def cookies
@data
end
def add_cookie(cookie)
@cookies[cookie.name] = cookie
@data[cookie.name] = cookie.value
end
end
def setup
@cookie_store = Raw::CookieSessionStore.new
end
def test_simple
context = MockContext.new
input = "RABBIT DATA"
@cookie_store.put(input, context)
output = @cookie_store.get(context)
assert_equal(input, output)
end
context = MockContext.new
maxsize = 1000
1000.times do |i|
input = String.random((rand * maxsize).to_i, /[\w\W]/)
define_method("test_#{i}") do
@cookie_store.put(input, context)
output = @cookie_store.get(context)
assert_equal(input, output)
end
end
end
end
I ran it a few times now and it's working fine. So that should narrow
the possibilities.
My guess as the moment is Bill's #1. The cookies must be changing
somehow when it moves through the browser.
Perhaps you are not the only one using the cookie name?
Also, going the encryption route won't buy you anything if you still
plan to have the JSON formatted data available to the browser.
T.
More information about the Nitro-general
mailing list