Commit 4770d21
Changed files (3)
lib
saml
spec
lib/saml/kit/metadata.rb
@@ -27,6 +27,14 @@ module Saml
end
end
+ def encryption_certificates
+ certificates.find_all { |x| x[:use] == "encryption" }
+ end
+
+ def signing_certificates
+ certificates.find_all { |x| x[:use] == "signing" }
+ end
+
def to_xml
@xml
end
lib/saml/kit/service_provider_metadata.rb
@@ -5,6 +5,16 @@ module Saml
super("SPSSODescriptor", xml)
end
+ def assertion_consumer_services
+ xpath = "/md:EntityDescriptor/md:SPSSODescriptor/md:AssertionConsumerService"
+ find_all(xpath).map do |item|
+ {
+ binding: item.attribute("Binding").value,
+ location: item.attribute("Location").value,
+ }
+ end
+ end
+
private
class Builder
spec/saml/service_provider_metadata_spec.rb
@@ -43,11 +43,13 @@ RSpec.describe Saml::Kit::ServiceProviderMetadata do
describe described_class do
let(:entity_id) { FFaker::Movie.title }
- let(:acs_url) { "https://#{FFaker::Internet.domain_name}/acs" }
+ let(:acs_post_url) { "https://#{FFaker::Internet.domain_name}/post" }
+ let(:acs_redirect_url) { "https://#{FFaker::Internet.domain_name}/redirect" }
let(:builder) { described_class::Builder.new }
subject do
builder.entity_id = entity_id
- builder.add_acs_url(acs_url)
+ builder.add_acs_url(acs_post_url, binding: :post)
+ builder.add_acs_url(acs_redirect_url, binding: :http_redirect)
builder.build
end
@@ -61,5 +63,12 @@ RSpec.describe Saml::Kit::ServiceProviderMetadata do
}
])
end
+
+ it 'returns each acs url and binding' do
+ expect(subject.assertion_consumer_services).to match_array([
+ { location: acs_post_url, binding: Saml::Kit::Namespaces::Bindings::POST },
+ { location: acs_redirect_url, binding: Saml::Kit::Namespaces::Bindings::HTTP_REDIRECT },
+ ])
+ end
end
end