Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 13 additions & 3 deletions spec/services/push_notification/http_push_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down