Sha256: b2614c328494f27033de304e20abbd443444eae0d37e1be1cedeb5fc8e120fe9

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe OpenIDConnect::Discovery::Principal do
  describe '.parse' do
    {
      'server.example.com' => OpenIDConnect::Discovery::Principal::URI,
      'http://server.example.com' => OpenIDConnect::Discovery::Principal::URI,
      'nov@server.example.com' => OpenIDConnect::Discovery::Principal::Email
    }.each do |input, klass|
      describe input do
        it do
          OpenIDConnect::Discovery::Principal.parse(input).should be_a klass
        end
      end
    end
  end

  describe '#discover!' do
    let(:request) { OpenIDConnect::Discovery::Principal.new.discover! }

    it 'should do SWD discovery' do
      SWD.should_receive(:discover!)
      request
    end

    context 'when port specified' do
      it do
        SWD.should_receive(:discover!).with(
          principal: "https://example.com:8080",
          service: "http://openid.net/specs/connect/1.0/issuer",
          host: "example.com",
          port: 8080,
          cache: {}
        )
        OpenIDConnect::Discovery::Principal.parse('example.com:8080').discover!
      end
    end

    context 'when discovery failed' do
      it do
        SWD.should_receive(:discover!).and_raise(SWD::Exception)
        expect { request }.to raise_error OpenIDConnect::Discovery::DiscoveryFailed
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
openid_connect-0.4.1 spec/openid_connect/discovery/principal_spec.rb
openid_connect-0.4.0 spec/openid_connect/discovery/principal_spec.rb
openid_connect-0.3.7 spec/openid_connect/discovery/principal_spec.rb
openid_connect-0.3.6 spec/openid_connect/discovery/principal_spec.rb
openid_connect-0.3.5 spec/openid_connect/discovery/principal_spec.rb
openid_connect-0.3.4 spec/openid_connect/discovery/principal_spec.rb