start test on france connect client

This commit is contained in:
Tanguy PATTE 2015-10-06 11:32:57 +02:00
parent fd60692ade
commit 5cb8f92a81
3 changed files with 25 additions and 12 deletions

View file

@ -422,6 +422,3 @@ DEPENDENCIES
unicorn
web-console (~> 2.0)
webmock
BUNDLED WITH
1.10.4

View file

@ -1,20 +1,19 @@
class FranceConnectClient < OpenIDConnect::Client
def initialize params={}
@redirect_uri = 'http://localhost:3000/france_connect/callback'
@authorization_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/authorize'
@token_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/token'
@userinfo_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/userinfo'
redirect_uri = 'http://localhost:3000/france_connect/callback'
authorization_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/authorize'
token_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/token'
userinfo_endpoint = 'https://fce.integ01.dev-franceconnect.fr/api/v1/userinfo'
super(
identifier: FRANCE_CONNECT.identifier,
secret: FRANCE_CONNECT.secret,
redirect_uri: @redirect_uri,
authorization_endpoint: @authorization_endpoint,
token_endpoint: @token_endpoint,
userinfo_endpoint: @userinfo_endpoint
redirect_uri: redirect_uri,
authorization_endpoint: authorization_endpoint,
token_endpoint: token_endpoint,
userinfo_endpoint: userinfo_endpoint
)
self.authorization_code = params[:code] if params.has_key? :code
end
end

View file

@ -0,0 +1,17 @@
require 'spec_helper'
describe FranceConnectClient do
describe '.initialize' do
it 'create an openid client' do
expect(described_class).to be < OpenIDConnect::Client
end
context 'when given code in params' do
let(:code) { 'plop' }
subject { described_class.new(code: code) }
it 'set authorisation code' do
expect_any_instance_of(described_class).to receive(:authorization_code=)
described_class.new(code: code)
end
end
end
end