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
5 changes: 3 additions & 2 deletions app/services/service_provider_updater.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
class ServiceProviderUpdater
PROTECTED_ATTRIBUTES = [
:id,
:approved,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monfresh what was the reason for making approved a protected attribute here? I think this may have resulted in a bug where we can't create new approved SPs from the dashboard app

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zachmargolis is correct -- the approved flag should be a pass-through from the dashboard.

Copy link
Copy Markdown
Contributor Author

@monfresh monfresh Mar 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. I'm assuming the approved flag can only be set by admins on the dashboard, and that we prevent people from manually changing the form such that it submits the approved attribute?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR coming soon

:created_at,
:updated_at,
:id,
:native,
:updated_at,
].to_set.freeze

def run
Expand Down
36 changes: 36 additions & 0 deletions spec/models/service_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,40 @@
end
end
end

describe '#live?' do
context 'when the service provider is not approved' do
it 'returns false' do
sp = create(:service_provider, issuer: 'foo')

expect(sp.live?).to be false
end
end

context 'when the service provider is approved but not active' do
it 'returns false' do
sp = ServiceProvider.from_issuer('http://localhost:3000')
sp.update(active: false)

expect(sp.live?).to be false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a live? method rather than just using active? ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's because we want to have the ability to approve SPs once we go live rather than automatically allow any SP that gets published on the dashboard. Currently, live? is not being used, but we want to be able to use it in the future. https://github.com/18F/identity-idp/blob/master/app/services/saml_request_validator.rb#L31

end
end

context 'when the service provider is active and approved' do
it 'returns true' do
sp = ServiceProvider.from_issuer('http://localhost:3000')

expect(sp.live?).to be true
end
end

context 'when the service provider is active but not approved' do
it 'returns false' do
sp = ServiceProvider.from_issuer('http://localhost:3000')
sp.update(approved: false)

expect(sp.live?).to be false
end
end
end
end
3 changes: 3 additions & 0 deletions spec/services/service_provider_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
cert: saml_test_sp_cert,
active: true,
native: true,
approved: true,
},
{
id: 'small number',
Expand Down Expand Up @@ -75,6 +76,7 @@
expect(sp.updated_at).to_not eq dashboard_service_providers.first[:updated_at]
expect(sp.created_at).to_not eq dashboard_service_providers.first[:created_at]
expect(sp.native).to eq false
expect(sp.approved).to eq false
end

it 'updates existing dashboard-provided Service Providers' do
Expand All @@ -92,6 +94,7 @@
expect(sp.updated_at).to_not eq dashboard_service_providers.first[:updated_at]
expect(sp.created_at).to_not eq dashboard_service_providers.first[:created_at]
expect(sp.native).to eq false
expect(sp.approved).to eq false
end

it 'removes inactive Service Providers' do
Expand Down