Sha256: 5e12e32dcea813835445c7f1c92898c72f3d88ee0f50d4c5c2aa7526d4b177e3

Contents?: true

Size: 1.83 KB

Versions: 66

Compression:

Stored size: 1.83 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class OpenIdAuthenticationTest < Test::Unit::TestCase
  def setup
    @controller = Class.new do
      include OpenIdAuthentication
      def params() {} end
    end.new
  end

  def test_authentication_should_fail_when_the_identity_server_is_missing
    open_id_consumer = mock()
    open_id_consumer.expects(:begin).raises(OpenID::OpenIDError)
    @controller.expects(:open_id_consumer).returns(open_id_consumer)
    @controller.expects(:logger).returns(mock(:error => true))

    @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
      assert result.missing?
      assert_equal "Sorry, the OpenID server couldn't be found", result.message
    end
  end

  def test_authentication_should_be_invalid_when_the_identity_url_is_invalid
    @controller.send(:authenticate_with_open_id, "!") do |result, identity_url|
      assert result.invalid?, "Result expected to be invalid but was not"
      assert_equal "Sorry, but this does not appear to be a valid OpenID", result.message
    end
  end

  def test_authentication_should_fail_when_the_identity_server_times_out
    open_id_consumer = mock()
    open_id_consumer.expects(:begin).raises(Timeout::Error, "Identity Server took too long.")
    @controller.expects(:open_id_consumer).returns(open_id_consumer)
    @controller.expects(:logger).returns(mock(:error => true))

    @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
      assert result.missing?
      assert_equal "Sorry, the OpenID server couldn't be found", result.message
    end
  end

  def test_authentication_should_begin_when_the_identity_server_is_present
    @controller.expects(:begin_open_id_authentication)
    @controller.send(:authenticate_with_open_id, "http://someone.example.com")
  end
end

Version data entries

66 entries across 66 versions & 11 rubygems

Version Path
redmine_extensions-0.0.39 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.38 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.37 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.11 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.10 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.36 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.34 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.09 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.07 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.06 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.05 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.04 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.03 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.33 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.02 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.1.01 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.29 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.28 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.27 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb
redmine_extensions-0.0.24 spec/redmine/lib/plugins/open_id_authentication/test/open_id_authentication_test.rb