require 'spec_helper'
module SamlIdp
describe MetadataBuilder do
it "has a valid fresh" do
expect(subject.fresh).to_not be_empty
end
it "signs valid xml" do
expect(Saml::XML::Document.parse(subject.signed).valid_signature?(Default::FINGERPRINT)).to be_truthy
end
it "includes logout element" do
subject.configurator.single_logout_service_post_location = 'https://example.com/saml/logout'
subject.configurator.single_logout_service_redirect_location = 'https://example.com/saml/logout'
expect(subject.fresh).to match('')
expect(subject.fresh).to match('')
end
it 'will not includes empty logout endpoint' do
subject.configurator.single_logout_service_post_location = ''
subject.configurator.single_logout_service_redirect_location = nil
expect(subject.fresh).not_to match('')
expect(subject.fresh).to match('')
end
it 'will not includes empty sso element' do
subject.configurator.single_service_post_location = ''
subject.configurator.single_service_redirect_location = nil
expect(subject.fresh).not_to match('ACME CorporationRoadRunnermailto:acme@example.com1-800-555-5555')
end
it "no fields" do
expect(subject.fresh).to match('')
end
it "just email" do
subject.configurator.technical_contact.email_address = "acme@example.com"
expect(subject.fresh).to match('mailto:acme@example.com')
end
end
it "includes logout element as HTTP Redirect" do
subject.configurator.single_logout_service_redirect_location = 'https://example.com/saml/logout'
expect(subject.fresh).to match('')
end
end
end