Commit 91d6740
Changed files (4)
spec/saml/kit/authentication_request_spec.rb
@@ -209,7 +209,7 @@ RSpec.describe Saml::Kit::AuthenticationRequest do
expect(result).to be_instance_of(described_class)
result.registry = instance_double(Saml::Kit::DefaultRegistry, metadata_for: Saml::Kit::ServiceProviderMetadata.build)
expect(result).to be_valid
- expect(result.to_xml).not_to include("NameIDPolicy")
+ expect(result.to_xml).not_to include('NameIDPolicy')
end
end
spec/saml/kit/metadata_spec.rb
@@ -85,35 +85,35 @@ RSpec.describe Saml::Kit::Metadata do
end
end
- describe "validations" do
+ describe 'validations' do
it 'is invalid, when the digest value is invalid' do
xml = described_class.build_xml do |x|
- x.entity_id = "original"
+ x.entity_id = 'original'
x.sign_with(::Xml::Kit::KeyPair.generate(use: :signing))
x.build_identity_provider do |y|
- y.add_single_sign_on_service(FFaker::Internet.uri("https"), binding: :http_post)
+ y.add_single_sign_on_service(FFaker::Internet.uri('https'), binding: :http_post)
end
end
- subject = described_class.from(xml.gsub("original", "altered"))
+ subject = described_class.from(xml.gsub('original', 'altered'))
expect(subject).not_to be_valid
- expect(subject.errors[:digest_value]).to include("is invalid.")
+ expect(subject.errors[:digest_value]).to include('is invalid.')
end
it 'is invalid when the signature is invalid' do
xml = described_class.build_xml do |x|
x.sign_with(::Xml::Kit::KeyPair.generate(use: :signing))
x.build_identity_provider do |y|
- y.add_single_sign_on_service(FFaker::Internet.uri("https"), binding: :http_post)
+ y.add_single_sign_on_service(FFaker::Internet.uri('https'), binding: :http_post)
end
end
document = Nokogiri::XML(xml)
- node = document.at_xpath("/*/ds:Signature/ds:SignatureValue", ds: Xml::Kit::Namespaces::XMLDSIG)
- node.content = Base64.encode64("invalid")
+ node = document.at_xpath('/*/ds:Signature/ds:SignatureValue', ds: Xml::Kit::Namespaces::XMLDSIG)
+ node.content = Base64.encode64('invalid')
subject = described_class.from(document.to_s)
expect(subject).not_to be_valid
- expect(subject.errors[:signature]).to include("is invalid.")
+ expect(subject.errors[:signature]).to include('is invalid.')
end
end
end
spec/saml/kit/response_spec.rb
@@ -531,17 +531,17 @@ XML
end
it 'excludes comments from the name id' do
- user.name_id = "shiro@voltron.com<!-- CVE-2017-11428 -->.evil.com"
+ user.name_id = 'shiro@voltron.com<!-- CVE-2017-11428 -->.evil.com'
subject = described_class.build(user, request)
- expect(subject.name_id).to eql("shiro@voltron.com<!-- CVE-2017-11428 -->.evil.com")
- expect(subject.name_id).not_to eql("shiro@voltron.com")
+ expect(subject.name_id).to eql('shiro@voltron.com<!-- CVE-2017-11428 -->.evil.com')
+ expect(subject.name_id).not_to eql('shiro@voltron.com')
end
it 'parses the name id safely (CVE-2017-11428)' do
- raw = IO.read("spec/fixtures/response_node_text_attack.xml.base64")
+ raw = IO.read('spec/fixtures/response_node_text_attack.xml.base64')
subject = Saml::Kit::Bindings::HttpPost.new(location: '').deserialize('SAMLResponse' => raw)
- expect(subject.name_id).to eql("support@onelogin.com")
- expect(subject.attributes[:surname]).to eql("smith")
+ expect(subject.name_id).to eql('support@onelogin.com')
+ expect(subject.attributes[:surname]).to eql('smith')
end
it 'returns the single attributes' do
@@ -556,14 +556,12 @@ XML
end
end
- describe "#build" do
+ describe '#build' do
it 'can build a response without a request' do
configuration = Saml::Kit::Configuration.new do |config|
- config.entity_id = FFaker::Internet.uri("https")
- end
- sp = Saml::Kit::Metadata.build do |x|
- x.build_service_provider
+ config.entity_id = FFaker::Internet.uri('https')
end
+ sp = Saml::Kit::Metadata.build(&:build_service_provider)
allow(configuration.registry).to receive(:metadata_for).with(configuration.entity_id).and_return(sp)
result = described_class.build(user, configuration: configuration)
expect(result).to be_instance_of(described_class)
spec/saml/kit/signature_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Saml::Kit::Signature do
it 'is invalid when the schema of the signature is invalid' do
signature_element = signed_document.at_xpath('//ds:Signature')
element = signature_element.at_xpath('./ds:SignedInfo', ds: Xml::Kit::Namespaces::XMLDSIG)
- element.name = "BLAH"
+ element.name = 'BLAH'
subject = described_class.new(signature_element)
expect(subject).not_to be_valid
expect(subject.errors[:base]).to include("1:0: ERROR: Element '{http://www.w3.org/2000/09/xmldsig#}BLAH': This element is not expected. Expected is ( {http://www.w3.org/2000/09/xmldsig#}SignedInfo ).")