diff --git a/app/models/service_provider.rb b/app/models/service_provider.rb index af1454ff779..fa1ba8cb174 100644 --- a/app/models/service_provider.rb +++ b/app/models/service_provider.rb @@ -27,7 +27,11 @@ class ServiceProvider < ApplicationRecord scope(:active, -> { where(active: true) }) scope( :with_push_notification_urls, - -> { where.not(push_notification_url: nil).where.not(push_notification_url: '') }, + -> { + where.not(push_notification_url: nil). + where.not(push_notification_url: ''). + where(active: true) + }, ) IAA_INTERNAL = 'LGINTERNAL' diff --git a/spec/services/push_notification/http_push_spec.rb b/spec/services/push_notification/http_push_spec.rb index c4d0cf79759..6e3e08b2c8b 100644 --- a/spec/services/push_notification/http_push_spec.rb +++ b/spec/services/push_notification/http_push_spec.rb @@ -5,8 +5,8 @@ let(:user) { create(:user) } - let(:sp_with_push_url) { create(:service_provider, push_notification_url: 'http://foo.bar/push') } - let(:sp_no_push_url) { create(:service_provider, push_notification_url: nil) } + let(:sp_with_push_url) { create(:service_provider, active: true, push_notification_url: 'http://foo.bar/push') } + let(:sp_no_push_url) { create(:service_provider, active: true, push_notification_url: nil) } let!(:sp_with_push_url_identity) do IdentityLinker.new(user, sp_with_push_url).link_identity @@ -128,7 +128,7 @@ end context 'with a timeout when posting to one url' do - let(:third_sp) { create(:service_provider, push_notification_url: 'http://sp.url/push') } + let(:third_sp) { create(:service_provider, active: true, push_notification_url: 'http://sp.url/push') } before do IdentityLinker.new(user, third_sp).link_identity @@ -182,6 +182,16 @@ end end + context 'when a service provider is no longer active' do + before { sp_with_push_url.update!(active: false) } + + it 'does not notify that SP' do + deliver + + expect(WebMock).not_to have_requested(:get, sp_with_push_url.push_notification_url) + end + end + context 'when a user has revoked access to an SP' do before do identity = user.identities.find_by(service_provider: sp_with_push_url.issuer)