spec/routes/auth_spec.rb in osso-0.0.5.pre.epsilon vs spec/routes/auth_spec.rb in osso-0.0.5.pre.eta

- old
+ new

@@ -1,10 +1,13 @@ # frozen_string_literal: true require 'spec_helper' describe Osso::Auth do + before do + described_class.set(:views, spec_views) + end describe 'get /auth/saml/:uuid' do describe 'for an Okta SAML provider' do let(:enterprise) { create(:enterprise_with_okta) } let(:okta_provider) { enterprise.identity_providers.first } it 'uses omniauth saml' do @@ -106,11 +109,11 @@ nil, { 'omniauth.auth' => OmniAuth.config.mock_auth[:saml], }, ) - expect(okta_provider.reload.status).to eq('ACTIVE') + expect(okta_provider.reload.status).to eq('active') end end end describe 'for an (Azure) ADFS SAML provider' do @@ -141,11 +144,11 @@ { 'omniauth.auth' => OmniAuth.config.mock_auth[:saml], }, ) - expect(azure_provider.reload.status).to eq('ACTIVE') + expect(azure_provider.reload.status).to eq('active') end end describe 'on subsequent authentications' do let!(:enterprise) { create(:enterprise_with_azure) } @@ -177,32 +180,33 @@ let!(:azure_provider) { enterprise.provider } it 'raises an error when email is missing' do mock_saml_omniauth(email: nil, id: SecureRandom.uuid) - expect do - post( + + response = post( "/auth/saml/#{azure_provider.id}/callback", nil, { 'omniauth.auth' => OmniAuth.config.mock_auth[:saml], }, ) - end.to raise_error(Osso::Error::MissingSamlEmailAttributeError) - end + expect(response.body).to eq('Osso::Error::MissingSamlEmailAttributeError') + end + it 'raises an error when id is missing' do mock_saml_omniauth(email: Faker::Internet.email, id: nil) - expect do - post( + response = post( "/auth/saml/#{azure_provider.id}/callback", nil, { 'omniauth.auth' => OmniAuth.config.mock_auth[:saml], }, ) - end.to raise_error(Osso::Error::MissingSamlIdAttributeError) + + expect(response.body).to eq('Osso::Error::MissingSamlIdAttributeError') end end end end