1 require File.join(File.dirname(__FILE__), 'spec_helper')
3 # This is just a comment test
5 describe Rots::ServerApp do
7 describe "when the request is not an OpenID request" do
9 it "should return a helpful message saying that is an OpenID endpoint" do
10 request = Rack::MockRequest.new(Rots::ServerApp.new({'sreg' => {}},
11 {:storage => File.join(*%w(. tmp rots)) }))
12 response = request.get("/")
14 response.body.should == "<html><body><h1>ROTS => This is an OpenID endpoint</h1></body></html>"
19 describe "when the request is an OpenID request" do
22 @request = Rack::MockRequest.new(Rots::ServerApp.new({
23 'identity' => 'john.doe',
25 'email' => "john@doe.com",
26 'nickname' => 'johndoe',
27 'fullname' => "John Doe",
28 'dob' => "1985-09-21",
31 {:storage => File.join(*%w(. tmp rots))}
36 describe "and it is a check_id request" do
38 describe "and is immediate" do
40 it "should return an openid.mode equal to setup_needed" do
41 response = checkid_immediate(@request)
42 params = openid_params(response)
43 params['openid.mode'].should == 'setup_needed'
48 describe "and is not immediate" do
50 describe "with a success flag" do
52 it "should return an openid.mode equal to id_res" do
53 response = checkid_setup(@request, 'openid.success' => 'true')
54 params = openid_params(response)
55 params['openid.mode'].should == 'id_res'
60 describe "without a success flag" do
62 it "should return an openid.mode equal to cancel" do
63 response = checkid_setup(@request)
64 params = openid_params(response)
65 params['openid.mode'].should == 'cancel'
70 describe "using SREG extension with a success flag" do
72 it "should return an openid.mode equal to id_res" do
73 response = checkid_setup(@request, 'openid.success' => 'true')
74 params = openid_params(response)
75 params['openid.mode'].should == 'id_res'
78 it "should return all the sreg fields" do
79 response = checkid_setup(@request, {
80 'openid.success' => true,
81 'openid.ns.sreg' => OpenID::SReg::NS_URI,
82 'openid.sreg.required' => 'email,nickname,fullname',
83 'openid.sreg.optional' => 'dob,gender'
85 params = openid_params(response)
86 params['openid.sreg.email'].should == "john@doe.com"
87 params['openid.sreg.nickname'].should == 'johndoe'
88 params['openid.sreg.fullname'].should == "John Doe"
89 params['openid.sreg.dob'].should == "1985-09-21"
90 params['openid.sreg.gender'].should == "M"