Sha256: 653c30c46b2149070a78e5a8817d20b4260a13df938754869bf43a0f808f8465
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'rubygems' require 'bacon' require 'rack' require ::File.dirname(__FILE__) + '/cerberus' Bacon.summary_on_exit describe 'cerberus' do secret_app = lambda {|env| [200, {'Content-Type'=>'text/plain'}, env['rack.session'].inspect] } app = Rack::Session::Cookie.new(Cerberus.new(secret_app, {}) {|login,pass| [login,pass]==['mario','bros']}) req = Rack::MockRequest.new(app) cookie = '' should 'Stop request if you are not already logged in or currently successfully logging' do res = req.get('/') res.status.should==401 res = req.post('/', :params => {'cerberus_login' => 'fake', 'cerberus_pass' => 'fake'}) res.status.should==401 end should 'Give access with the appropriate login and pass' do res = req.get('/', :params => {'cerberus_login' => 'mario', 'cerberus_pass' => 'bros'}) cookie = res["Set-Cookie"] res.status.should==200 end should 'Use session for persistent login' do res = req.get('/', "HTTP_COOKIE" => cookie) res.status.should==200 res.body.should=='{"cerberus_user"=>"mario"}' cookie = res["Set-Cookie"] req.get('/', "HTTP_COOKIE" => cookie).status.should==200 end should 'Logout via /logout path' do res = req.get('/logout', "HTTP_COOKIE" => cookie) res.status.should==401 cookie = res["Set-Cookie"] res = req.get('/', "HTTP_COOKIE" => cookie) res.status.should==401 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rack-cerberus-0.1.1 | spec.rb |
rack-cerberus-0.1.0 | spec.rb |