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
4 changes: 4 additions & 0 deletions app/decorators/identity_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def event_partial
'accounts/identity_item'
end

def failure_to_proof_url
identity.sp_metadata[:failure_to_proof_url]
end

def return_to_sp_url
identity.sp_metadata[:return_to_sp_url]
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/null_service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def logo; end

def friendly_name; end

def failure_to_proof_url; end

def return_to_sp_url; end

def redirect_uris
Expand Down
1 change: 1 addition & 0 deletions config/service_providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test:
assertion_consumer_logout_service_url: 'http://example.com/test/saml/decode_slo_request'
block_encryption: 'aes256-cbc'
sp_initiated_login_url: 'https://example.com/auth/saml/login'
failure_to_proof_url: 'https://example.com/'
friendly_name: 'Test SP'
cert: 'saml_test_sp'
logo: 'generic.svg'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddFailureToProofUrlToServiceProvider < ActiveRecord::Migration[5.1]
def up
add_column :service_providers, :failure_to_proof_url, :text
end

def down
remove_column :service_providers, :failure_to_proof_url
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180720152009) do
ActiveRecord::Schema.define(version: 20180728122856) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -179,6 +179,7 @@
t.boolean "native", default: false, null: false
t.string "redirect_uris", default: [], array: true
t.integer "agency_id"
t.text "failure_to_proof_url"
t.index ["issuer"], name: "index_service_providers_on_issuer", unique: true
end

Expand Down
45 changes: 34 additions & 11 deletions spec/decorators/identity_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,49 @@
describe IdentityDecorator do
include ActionView::Helpers::TagHelper

let(:user) { create(:user) }
let(:service_provider) { 'http://localhost:3000' }
let(:identity) { create(:identity, :active, user: user, service_provider: service_provider) }
describe '#return_to_sp_url' do
let(:user) { create(:user) }
let(:service_provider) { 'http://localhost:3000' }
let(:identity) { create(:identity, :active, user: user, service_provider: service_provider) }

subject { IdentityDecorator.new(identity) }
subject { IdentityDecorator.new(identity) }

describe '#return_to_sp_url' do
context 'for an sp without a return URL' do
context 'for an sp with a return URL' do
it 'returns the return url for the sp' do
return_to_sp_url = ServiceProvider.from_issuer(service_provider).return_to_sp_url
expect(subject.return_to_sp_url).to eq(return_to_sp_url)
end
context 'for an sp with a return URL' do
it 'returns the return url for the sp' do
return_to_sp_url = ServiceProvider.from_issuer(service_provider).return_to_sp_url
expect(subject.return_to_sp_url).to eq(return_to_sp_url)
end
end

context 'for an sp without a return URL' do
let(:service_provider) { 'https://rp2.serviceprovider.com/auth/saml/metadata' }

it 'returns nil' do
expect(subject.return_to_sp_url).to eq(nil)
end
end
end

describe '#failure_to_proof_url' do
let(:user) { create(:user) }
let(:service_provider) { 'https://rp1.serviceprovider.com/auth/saml/metadata' }
let(:identity) { create(:identity, :active, user: user, service_provider: service_provider) }

subject { IdentityDecorator.new(identity) }

context 'for an sp with a failure to proof url' do
it 'returns the failure_to_proof_url for the sp' do
failure_to_proof_url = ServiceProvider.from_issuer(service_provider).failure_to_proof_url
expect(subject.failure_to_proof_url).to eq(failure_to_proof_url)
end
end

context 'for an sp without a failure to proof URL' do
let(:service_provider) { 'http://localhost:3000' }

it 'returns nil' do
expect(subject.failure_to_proof_url).to eq(nil)
end
end
end
end
6 changes: 6 additions & 0 deletions spec/models/null_service_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
end
end

describe '#failure_to_proof_url' do
it 'returns nil' do
expect(subject.failure_to_proof_url).to be_nil
end
end

describe '#issuer' do
it 'returns the issuer argument' do
expect(subject.issuer).to eq 'foo'
Expand Down