FC initializers: remove Hashie

This commit is contained in:
simon lehericey 2018-01-11 14:04:24 +01:00 committed by Simon Lehericey
parent ec69be0f7b
commit f8519c5345
6 changed files with 20 additions and 16 deletions

View file

@ -50,7 +50,7 @@ class Users::SessionsController < Sessions::SessionsController
case connected_with_france_connect
when 'particulier'
redirect_to FRANCE_CONNECT.particulier.logout_endpoint
redirect_to FRANCE_CONNECT[:particulier][:logout_endpoint]
return
end
end

View file

@ -1,6 +1,6 @@
class FranceConnectParticulierClient < OpenIDConnect::Client
def initialize(code = nil)
super(FRANCE_CONNECT.particulier)
super(FRANCE_CONNECT[:particulier])
if code.present?
self.authorization_code = code

View file

@ -11,6 +11,6 @@ class FranceConnectSaltService
end
def salt
Digest::MD5.hexdigest(model.france_connect_particulier_id + model.given_name + model.family_name + FRANCE_CONNECT.particulier.secret + DateTime.now.to_date.to_s)
Digest::MD5.hexdigest(model.france_connect_particulier_id + model.given_name + model.family_name + FRANCE_CONNECT[:particulier][:secret] + DateTime.now.to_date.to_s)
end
end

View file

@ -2,10 +2,11 @@ FRANCE_CONNECT = if !Rails.env.test?
file_path = "#{Rails.root}/config/france_connect.yml"
config_hash = YAML.safe_load(File.read(file_path))
.reduce({}) { |acc, (key, value)| acc[key.gsub('particulier_', '')] = value, acc }
.symbolize_keys
Hashie::Mash.new(particulier: config_hash)
{ particulier: config_hash }
else
Hashie::Mash.new({
{
particulier: {
identifier: 'plop',
secret: 'plip',
@ -15,5 +16,5 @@ else
userinfo_endpoint: 'https://bidon.com/endpoint',
logout_endpoint: 'https://bidon.com/endpoint',
}
})
}
end

View file

@ -118,7 +118,7 @@ describe Users::SessionsController, type: :controller do
let(:loged_in_with_france_connect) { 'particulier' }
it 'redirect to france connect logout page' do
expect(response).to redirect_to(FRANCE_CONNECT.particulier.logout_endpoint)
expect(response).to redirect_to(FRANCE_CONNECT[:particulier][:logout_endpoint])
end
end
@ -161,7 +161,7 @@ describe Users::SessionsController, type: :controller do
user.update_attributes(loged_in_with_france_connect: 'particulier')
sign_in user
delete :destroy
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT.particulier.logout_endpoint)
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT[:particulier][:logout_endpoint])
end
context "when associated administrateur" do

View file

@ -10,14 +10,17 @@ feature 'France Connect Particulier Connexion' do
let(:email) { 'plop@plop.com' }
let(:france_connect_particulier_id) { 'blabla' }
let(:user_info) { Hashie::Mash.new(france_connect_particulier_id: france_connect_particulier_id,
given_name: given_name,
family_name: family_name,
birthdate: birthdate,
birthplace: birthplace,
gender: gender,
email: email)
}
let(:user_info) do
{
france_connect_particulier_id: france_connect_particulier_id,
given_name: given_name,
family_name: family_name,
birthdate: birthdate,
birthplace: birthplace,
gender: gender,
email_france_connect: email
}
end
context 'when user is on login page' do
before do