From 5cb8f92a815f518053928104abf5f7034cce6f73 Mon Sep 17 00:00:00 2001 From: Tanguy PATTE Date: Tue, 6 Oct 2015 11:32:57 +0200 Subject: [PATCH] start test on france connect client --- Gemfile.lock | 3 --- app/models/france_connect_client.rb | 17 ++++++++--------- spec/models/france_connect_client_spec.rb | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 spec/models/france_connect_client_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 516ad3e33..25e3f8612 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -422,6 +422,3 @@ DEPENDENCIES unicorn web-console (~> 2.0) webmock - -BUNDLED WITH - 1.10.4 diff --git a/app/models/france_connect_client.rb b/app/models/france_connect_client.rb index 1dae10435..565a9a402 100644 --- a/app/models/france_connect_client.rb +++ b/app/models/france_connect_client.rb @@ -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 diff --git a/spec/models/france_connect_client_spec.rb b/spec/models/france_connect_client_spec.rb new file mode 100644 index 000000000..007bc3264 --- /dev/null +++ b/spec/models/france_connect_client_spec.rb @@ -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 \ No newline at end of file