test/maestrano/sso/session_test.rb in maestrano-0.7.0 vs test/maestrano/sso/session_test.rb in maestrano-0.8.0

- old
+ new

@@ -99,21 +99,41 @@ end context "valid?" do setup do @sso_session = Maestrano::SSO::Session.new(@session) + Maestrano.configure { |c| c.sso.slo_enabled = true } end + + should "return true if Single Logout is disabled" do + Maestrano.configure { |c| c.sso.slo_enabled = false } + @sso_session.stubs(:remote_check_required?).returns(true) + @sso_session.stubs(:perform_remote_check).returns(false) + assert @sso_session.valid? + end + + should "return true if_session is enabled and session is nil" do + sso_session = Maestrano::SSO::Session.new(nil) + assert sso_session.valid?(if_session: true) + end + + should "return true if_session is enabled and session is empty" do + sso_session = Maestrano::SSO::Session.new({}) + assert sso_session.valid?(if_session: true) + end should "return true if no remote_check_required?" do @sso_session.stubs(:remote_check_required?).returns(false) assert @sso_session.valid? + assert @sso_session.valid?(if_session: true) end should "return true if remote_check_required? and valid" do @sso_session.stubs(:remote_check_required?).returns(true) @sso_session.stubs(:perform_remote_check).returns(true) assert @sso_session.valid? + assert @sso_session.valid?(if_session: true) end should "update maestrano session with recheck timestamp if remote_check_required? and valid" do recheck = (@sso_session.recheck + 600) @sso_session.recheck = recheck @@ -124,10 +144,16 @@ end should "return false if remote_check_required? and invalid" do @sso_session.stubs(:remote_check_required?).returns(true) @sso_session.stubs(:perform_remote_check).returns(false) - assert !@sso_session.valid? + assert_false @sso_session.valid? + assert_false @sso_session.valid?(if_session: true) + end + + should "return false if internal session is nil" do + sso_session = Maestrano::SSO::Session.new(nil) + assert_false @sso_session.valid? end end end end \ No newline at end of file