diff options
| author | mokha <mokha@cisco.com> | 2018-03-05 17:07:30 -0700 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2018-03-05 17:07:30 -0700 |
| commit | 2213fa732a8a45b187fbae1299fd515c2edde478 (patch) | |
| tree | 802cf11218ce29de23863d5d7ead59edf2452013 | |
| parent | 1e2105b91720c2acb1b5b2c5d85e993a4ae72e7d (diff) | |
add spec for invalid xmldsig.
| -rw-r--r-- | spec/saml/kit/cli/commands/xml_digital_signature_spec.rb | 10 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/spec/saml/kit/cli/commands/xml_digital_signature_spec.rb b/spec/saml/kit/cli/commands/xml_digital_signature_spec.rb index e608404..891f9ad 100644 --- a/spec/saml/kit/cli/commands/xml_digital_signature_spec.rb +++ b/spec/saml/kit/cli/commands/xml_digital_signature_spec.rb @@ -2,8 +2,10 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do describe "#verify" do let(:command) { "xmldsig verify #{tempfile}" } let(:tempfile) { Tempfile.new('saml-kit').path } + let(:entity_id) { SecureRandom.uuid } let(:configuration) do Saml::Kit::Configuration.new do |config| + config.entity_id = entity_id config.generate_key_pair_for(use: :signing) end end @@ -19,5 +21,13 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do specify { expect(output).to include(document.to_xml(pretty: true)) } specify { expect(output).to include("success #{tempfile} is valid") } end + + context "file is invalid" do + let(:document) { Saml::Kit::AuthenticationRequest.build(configuration: configuration) } + let(:xml) { document.to_xml.gsub(/#{entity_id}/, 'hacked') } + + specify { expect(status).to be_success } + specify { expect(output).to include("error Digest value is invalid") } + end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 59c306e..dd6145d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require 'bundler/setup' require 'saml/kit/cli' +require 'securerandom' require 'tempfile' require_relative 'support/shell_helpers.rb' |
