This commit is contained in:
Mathieu Magnin 2024-12-12 15:25:54 +01:00
parent 6595b2a7c5
commit 9e03f94085
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
2 changed files with 34 additions and 0 deletions

View file

@ -96,6 +96,16 @@ describe Users::SessionsController, type: :controller do
expect(controller.current_user).to be(nil)
end
end
context 'when email domain is in mandatory list' do
let(:email) { 'user@beta.gouv.fr' }
it 'redirects to agent connect with force parameter' do
expect(AgentConnectService).to receive(:enabled?).and_return(true)
subject
expect(response).to redirect_to(agent_connect_path(force_agent_connect: true))
expect(flash[:alert]).to eq("La connexion des agents passe à présent systématiquement par AgentConnect")
end
end
end
describe '#destroy' do

View file

@ -16,4 +16,28 @@ describe AgentConnectService do
expect(subject).to eq("https://agent-connect.fr/logout?id_token_hint=id_token&post_logout_redirect_uri=http%3A%2F%2Ftest.host%2Flogout")
end
end
describe '.email_domain_is_in_mandatory_list?' do
subject { described_class.email_domain_is_in_mandatory_list?(email) }
context 'when email domain is beta.gouv.fr' do
let(:email) { 'user@beta.gouv.fr' }
it { is_expected.to be true }
end
context 'when email domain is modernisation.gouv.fr' do
let(:email) { 'user@modernisation.gouv.fr' }
it { is_expected.to be true }
end
context 'when email domain is not in the mandatory list' do
let(:email) { 'user@example.com' }
it { is_expected.to be false }
end
context 'when email contains whitespace' do
let(:email) { ' user@beta.gouv.fr ' }
it { is_expected.to be true }
end
end
end