blob: 8718f78296df068006c27d707c706c456872ce0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
RSpec.describe Saml::Kit::Cli::Commands::Decode do
describe '#redirect' do
let(:command) { "decode redirect #{redirect_binding.serialize(builder)[0]}" }
let(:document) { builder.build }
let(:builder) do
Saml::Kit::AuthenticationRequest.builder do |x|
x.sign_with(Xml::Kit::KeyPair.generate(use: :signing))
end
end
let(:redirect_binding) do
Saml::Kit::Bindings::HttpRedirect.new(location: 'https://www.example.com/')
end
specify { expect(status).to be_success }
specify { expect(output).to include(document.to_xml(pretty: true)) }
specify { expect(output).to include("Decoded #{document.send(:name)}") }
specify { expect(output).not_to include('Signature Value') }
end
describe '#post' do
let(:post_binding) do
Saml::Kit::Bindings::HttpPost.new(location: 'https://www.example.com/')
end
context "when the document is a Response" do
let(:command) { "decode post #{post_binding.serialize(builder)[1]['SAMLResponse']}" }
let(:builder) do
Saml::Kit::Response.builder(user) do |x|
x.sign_with(Xml::Kit::KeyPair.generate(use: :signing))
end
end
let(:user) { double(name_id_for: SecureRandom.uuid) }
let(:document) { builder.build }
specify { expect(status).to be_success }
specify { expect(output).to include(document.to_xml(pretty: true)) }
specify { expect(output).to include("Decoded #{document.send(:name)}") }
specify { expect(output).to include(document.signature.certificate.x509.to_text) }
end
context "when the document is a LogoutRequest" do
let(:command) { "decode post #{post_binding.serialize(builder)[1]['SAMLRequest']}" }
let(:builder) { Saml::Kit::LogoutRequest.builder(user) }
let(:user) { double(name_id_for: SecureRandom.uuid) }
let(:document) { builder.build }
specify { expect(status).to be_success }
specify { expect(output).to include(document.to_xml(pretty: true)) }
specify { expect(output).to include("Decoded #{document.send(:name)}") }
specify { expect(output).to include(user.name_id_for) }
end
end
describe '#raw' do
let(:command) { "decode raw #{tempfile}" }
let(:tempfile) { Tempfile.new('saml-kit').path }
let(:document) { Saml::Kit::AuthenticationRequest.build }
before { IO.write(tempfile, document.to_xml) }
after { File.unlink(tempfile) }
specify { expect(status).to be_success }
specify { expect(output).to include(document.to_xml(pretty: true)) }
specify { expect(output).to include("Decoded #{document.send(:name)}") }
end
end
|