Disable FC Enterprise

This commit is contained in:
Xavier J 2016-01-11 17:19:25 +01:00
parent a7af7e4a9f
commit 5540a786db
4 changed files with 151 additions and 153 deletions

View file

@ -9,16 +9,14 @@
%strong
France Connect
.row
.col-md-6.col-lg-6
%a.btn.btn-default.btn-lg.btn-primary.btn_fc#btn_fcp{href: '/france_connect/particulier'}
%div{style:'margin-left:35px'}
Particulier
%a.btn.btn-default.btn-lg.btn-primary.btn_fc#btn_fcp{href: '/france_connect/particulier'}
%div{style:'margin-left:35px'}
Particulier
.col-md-6.col-lg-6
%a.btn.btn-default.btn-lg.btn-danger.btn_fc#btn_fce{href: '/france_connect/entreprise'}
%div{style:'margin-left:35px'}
Entreprise
-#.col-md-6.col-lg-6
-# %a.btn.btn-default.btn-lg.btn-danger.btn_fc#btn_fce{href: '/france_connect/entreprise'}
-# %div{style:'margin-left:35px'}
-# Entreprise
%hr
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
%h4

View file

@ -16,8 +16,8 @@ Rails.application.routes.draw do
root 'root#index'
namespace :france_connect do
get 'entreprise' => 'entreprise#login'
get 'entreprise/callback' => 'entreprise#callback'
# get 'entreprise' => 'entreprise#login'
# get 'entreprise/callback' => 'entreprise#callback'
get 'particulier' => 'particulier#login'
get 'particulier/callback' => 'particulier#callback'

View file

@ -1,61 +1,61 @@
require 'spec_helper'
describe FranceConnect::EntrepriseController, type: :controller do
describe '.login' do
it 'redirect to france connect serveur' do
get :login
expect(response.status).to eq(302)
end
end
describe '.callback' do
context 'when param code is missing' do
it 'redirect to login page' do
get :callback
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when params code is present' do
let(:code) { 'plop' }
let(:email) { 'patator@cake.com' }
let(:siret) { '41123069100049' }
let(:user_info) { Hashie::Mash.new(email: email, siret: siret) }
context 'when code is correct' do
let(:email) { 'patator@cake.com' }
let(:current_user) { User.find_by_email(email) }
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_info)
get :callback, code: code
end
it 'current user have attribut loged_in_with_france_connect at enterprise' do
expect(current_user.loged_in_with_france_connect).to eq 'entreprise'
end
let(:stored_location) { '/plip/plop' }
it 'redirect to stored location' do
subject.store_location_for(:user, stored_location)
get :callback, code: code
expect(response).to redirect_to(stored_location)
end
end
context 'when code is not correct' do
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
get :callback, code: code
end
it 'redirect to login page' do
expect(response).to redirect_to(new_user_session_path)
end
it 'display error message' do
expect(flash[:alert]).to be_present
end
end
end
end
end
# require 'spec_helper'
#
# describe FranceConnect::EntrepriseController, type: :controller do
#
# describe '.login' do
# it 'redirect to france connect serveur' do
# get :login
# expect(response.status).to eq(302)
# end
# end
#
# describe '.callback' do
# context 'when param code is missing' do
# it 'redirect to login page' do
# get :callback
# expect(response).to redirect_to(new_user_session_path)
# end
# end
# context 'when params code is present' do
# let(:code) { 'plop' }
# let(:email) { 'patator@cake.com' }
# let(:siret) { '41123069100049' }
# let(:user_info) { Hashie::Mash.new(email: email, siret: siret) }
# context 'when code is correct' do
# let(:email) { 'patator@cake.com' }
# let(:current_user) { User.find_by_email(email) }
#
# before do
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_info)
# get :callback, code: code
# end
#
# it 'current user have attribut loged_in_with_france_connect at enterprise' do
# expect(current_user.loged_in_with_france_connect).to eq 'entreprise'
# end
# let(:stored_location) { '/plip/plop' }
# it 'redirect to stored location' do
# subject.store_location_for(:user, stored_location)
# get :callback, code: code
# expect(response).to redirect_to(stored_location)
# end
# end
#
# context 'when code is not correct' do
# before do
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
# get :callback, code: code
# end
#
# it 'redirect to login page' do
# expect(response).to redirect_to(new_user_session_path)
# end
#
# it 'display error message' do
# expect(flash[:alert]).to be_present
# end
# end
# end
# end
# end
#

View file

@ -1,81 +1,81 @@
require 'spec_helper'
feature 'France Connect Connexion' do
context 'when user is on login page' do
before do
visit new_user_session_path
end
scenario 'link to France Connect is present' do
expect(page).to have_css('a#btn_fce')
end
context 'and click on france connect link' do
let(:code) { 'plop' }
context 'when authentification is ok' do
before do
allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(Hashie::Mash.new(email: 'patator@cake.com'))
page.find_by_id('btn_fce').click
end
scenario 'he is redirected to france connect' do
expect(page).to have_content('Mes dossiers')
end
end
context 'when authentification is not ok' do
before do
allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
page.find_by_id('btn_fce').click
end
scenario 'he is redirected to login page' do
expect(page).to have_css('a#btn_fce')
end
scenario 'error message is displayed' do
expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion'))
end
end
end
end
feature 'redirection' do
before do
visit initial_path
end
context 'when he use france connect' do
let(:code) { 'my_code' }
let(:email) { 'plop@plop.com' }
let(:siret) { '00000000000000' }
let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) }
before do
allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_infos)
page.find_by_id('btn_fce').click
end
context 'when starting page is dossiers list' do
let(:initial_path) { users_dossiers_path }
scenario 'he is redirected to dossier list' do
expect(page).to have_css('#users_index')
end
end
context 'when starting page is procedure' do
let(:procedure) { create(:procedure) }
let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) }
scenario 'he is redirected to siret page' do
expect(page).to have_css('#users_siret_index')
end
scenario 'the siret is already written in form' do
expect(page.find_by_id('dossier_siret').value).to have_content(siret)
end
end
end
end
end
# require 'spec_helper'
#
# feature 'France Connect Connexion' do
# context 'when user is on login page' do
#
# before do
# visit new_user_session_path
# end
#
# scenario 'link to France Connect is present' do
# expect(page).to have_css('a#btn_fce')
# end
#
# context 'and click on france connect link' do
# let(:code) { 'plop' }
#
# context 'when authentification is ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(Hashie::Mash.new(email: 'patator@cake.com'))
# page.find_by_id('btn_fce').click
# end
#
# scenario 'he is redirected to france connect' do
# expect(page).to have_content('Mes dossiers')
# end
# end
#
# context 'when authentification is not ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
# page.find_by_id('btn_fce').click
# end
#
# scenario 'he is redirected to login page' do
# expect(page).to have_css('a#btn_fce')
# end
#
# scenario 'error message is displayed' do
# expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion'))
# end
# end
# end
# end
#
#
# feature 'redirection' do
# before do
# visit initial_path
# end
# context 'when he use france connect' do
# let(:code) { 'my_code' }
# let(:email) { 'plop@plop.com' }
# let(:siret) { '00000000000000' }
# let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) }
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_infos)
# page.find_by_id('btn_fce').click
# end
# context 'when starting page is dossiers list' do
# let(:initial_path) { users_dossiers_path }
# scenario 'he is redirected to dossier list' do
# expect(page).to have_css('#users_index')
# end
# end
# context 'when starting page is procedure' do
# let(:procedure) { create(:procedure) }
# let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) }
# scenario 'he is redirected to siret page' do
# expect(page).to have_css('#users_siret_index')
# end
#
# scenario 'the siret is already written in form' do
# expect(page.find_by_id('dossier_siret').value).to have_content(siret)
# end
# end
# end
# end
# end