2020-11-12 16:09:21 +01:00
|
|
|
|
describe SamlIdpController do
|
2022-08-18 11:39:43 +02:00
|
|
|
|
before do
|
|
|
|
|
allow_any_instance_of(SamlIdpController).to receive(:validate_saml_request).and_return(valid_saml_request)
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-12 16:09:21 +01:00
|
|
|
|
describe '#new' do
|
|
|
|
|
let(:action) { get :new }
|
|
|
|
|
|
2022-08-18 11:39:43 +02:00
|
|
|
|
context 'with invalid saml request' do
|
|
|
|
|
let(:valid_saml_request) { false }
|
|
|
|
|
it { expect(action).to have_http_status(:forbidden) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with valid saml request' do
|
|
|
|
|
let(:valid_saml_request) { true }
|
2020-11-12 16:09:21 +01:00
|
|
|
|
|
2022-08-18 11:39:43 +02:00
|
|
|
|
it { expect(action).to have_http_status(:ok) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
describe '#create' do
|
|
|
|
|
let(:action) { post :create }
|
|
|
|
|
|
|
|
|
|
context 'with invalid saml request' do
|
|
|
|
|
let(:valid_saml_request) { false }
|
|
|
|
|
it { expect(action).to have_http_status(:forbidden) }
|
2020-11-12 16:09:21 +01:00
|
|
|
|
end
|
|
|
|
|
|
2022-08-18 11:39:43 +02:00
|
|
|
|
context 'with valid saml request' do
|
|
|
|
|
let(:valid_saml_request) { true }
|
|
|
|
|
|
|
|
|
|
context 'without superadmin connected' do
|
|
|
|
|
it { expect(action).to redirect_to root_path }
|
|
|
|
|
|
|
|
|
|
it "display alert" do
|
|
|
|
|
action
|
|
|
|
|
expect(flash[:alert]).to eq("Vous n’êtes pas autorisé à accéder à ce service.")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with superadmin connected' do
|
|
|
|
|
let(:superadmin) { create(:super_admin) }
|
|
|
|
|
before { sign_in superadmin }
|
2020-11-12 16:09:21 +01:00
|
|
|
|
|
2022-08-18 11:39:43 +02:00
|
|
|
|
it 'encode saml response' do
|
|
|
|
|
expect(subject).to receive(:idp_make_saml_response).with(superadmin)
|
|
|
|
|
action
|
|
|
|
|
end
|
2020-11-12 16:09:21 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|