Sha256: bf32164b8dade1334ba7a137852af61dc60ec4ff9db7ebd265d3f38fd00eb0bd

Contents?: true

Size: 1.79 KB

Versions: 10

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe CASino::Listener::LoginCredentialRequestor do
  include CASino::Engine.routes.url_helpers
  let(:controller) { Struct.new(:cookies).new(cookies: {}) }
  let(:listener) { described_class.new(controller) }

  describe '#user_not_logged_in' do
    let(:login_ticket) { Object.new }
    it 'assigns the login ticket' do
      listener.user_not_logged_in(login_ticket)
      controller.instance_variable_get(:@login_ticket).should == login_ticket
    end

    it 'deletes an existing ticket-granting ticket cookie' do
      controller.cookies = { tgt: 'TGT-12345' }
      listener.user_not_logged_in(login_ticket)
      controller.cookies[:tgt].should be_nil
    end
  end

  describe '#user_logged_in' do
    context 'with a service url' do
      let(:url) { 'http://www.example.com/?ticket=ST-123' }
      it 'tells the controller to redirect the client' do
        controller.should_receive(:redirect_to).with(url, status: :see_other)
        listener.user_logged_in(url)
      end
    end

    context 'without a service url' do
      let(:url) { nil }
      it 'tells the controller to redirect to the session overview' do
        controller.should_receive(:redirect_to).with(sessions_path)
        listener.user_logged_in(url)
      end
    end
  end

  context '#service_not_allowed' do
    let(:service) { 'http://www.example.com/foo' }

    before(:each) do
      controller.stub(:render)
    end

    it 'tells the controller to render the service_not_allowed template' do
      controller.should_receive(:render).with('service_not_allowed', status: 403)
      listener.send(:service_not_allowed, service)
    end

    it 'assigns the not allowed service' do
      listener.send(:service_not_allowed, service)
      controller.instance_variable_get(:@service).should == service
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
casino-1.3.2 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.3.1 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.3.0 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.2.2 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.2.1 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.2.0 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.1.0 spec/controllers/listener/login_credential_requestor_spec.rb
casino-1.0.0 spec/controllers/listener/login_credential_requestor_spec.rb
casino-0.0.4 spec/controllers/listener/login_credential_requestor_spec.rb
casino-0.0.3 spec/controllers/listener/login_credential_requestor_spec.rb