Sha256: 98b1b78637006c3beba3f43ea1be1c4b1e406a19ea967fe6809e738779baf586
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' describe Devise::Strategies::SamlAuthenticatable do subject(:strategy) { described_class.new(env, :user) } let(:env) { {} } let(:response) { double(:response, :settings= => nil, is_valid?: true) } before do allow(OneLogin::RubySaml::Response).to receive(:new).and_return(response) end let(:saml_config) { OneLogin::RubySaml::Settings.new } before do allow(strategy).to receive(:get_saml_config).and_return(saml_config) end let(:mapping) { double(:mapping, to: user_class) } let(:user_class) { double(:user_class, authenticate_with_saml: user) } let(:user) { double(:user) } before do allow(strategy).to receive(:mapping).and_return(mapping) end let(:params) { {} } before do allow(strategy).to receive(:params).and_return(params) end context "with a SAMLResponse parameter" do let(:params) { {SAMLResponse: ""} } it "is valid" do expect(strategy).to be_valid end it "authenticates with the response" do expect(OneLogin::RubySaml::Response).to receive(:new).with(params[:SAMLResponse]) expect(response).to receive(:settings=).with(saml_config) expect(user_class).to receive(:authenticate_with_saml).with(response) expect(strategy).to receive(:success!).with(user) strategy.authenticate! end context "and the SAML response is not valid" do before do allow(response).to receive(:is_valid?).and_return(false) end it "fails to authenticate" do expect(strategy).to receive(:fail!).with(:invalid) strategy.authenticate! end end end it "is not valid without a SAMLResponse parameter" do expect(strategy).not_to be_valid end it "is permanent" do expect(strategy).to be_store end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devise_saml_authenticatable-1.0 | spec/devise_saml_authenticatable/strategy_spec.rb |
devise_saml_authenticatable-0.1.0 | spec/devise_saml_authenticatable/strategy_spec.rb |