Commit c901211
Changed files (6)
lib
saml
kit
cli
commands
spec
saml
kit
support
lib/saml/kit/cli/commands/metadata.rb
@@ -11,7 +11,7 @@ module Saml
desc 'list', "List each of the registered entityId's"
def list
if registry.count.zero?
- say "Please register metadata using `saml-kit metadata register <url>`"
+ say 'Please register metadata using `saml-kit metadata register <url>`'
end
registry.each do |x|
say x.entity_id, :green
spec/saml/kit/cli/commands/certificate_spec.rb
@@ -1,8 +1,8 @@
RSpec.describe Saml::Kit::Cli::Commands::Certificate do
- describe "keypair" do
- let(:passphrase) { "password" }
+ describe 'keypair' do
+ let(:passphrase) { 'password' }
- describe "generating a pem" do
+ describe 'generating a pem' do
let(:command) { "certificate keypair --passphrase #{passphrase}" }
specify { expect(status).to be_success }
@@ -15,7 +15,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
specify { expect(output).to include('DEK-Info: AES-256-CBC,') }
end
- describe "generating env format" do
+ describe 'generating env format' do
let(:command) { "certificate keypair --passphrase #{passphrase} --format env" }
specify { expect(status).to be_success }
@@ -25,7 +25,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
end
end
- describe "dump" do
+ describe 'dump' do
let(:command) { "certificate dump '#{base64_certificate}'" }
let(:base64_certificate) { x509.to_pem }
let(:x509) do
spec/saml/kit/cli/commands/decode_spec.rb
@@ -1,5 +1,5 @@
RSpec.describe Saml::Kit::Cli::Commands::Certificate do
- describe "#redirect" do
+ describe '#redirect' do
let(:command) { "decode redirect #{redirect_binding.serialize(builder)[0]}" }
let(:document) { builder.build }
let(:builder) do
@@ -17,7 +17,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
specify { expect(output).not_to include('Signature Value') }
end
- describe "#post" do
+ describe '#post' do
let(:command) { "decode post #{post_binding.serialize(builder)[1]['SAMLResponse']}" }
let(:document) { builder.build }
let(:user) { double(name_id_for: SecureRandom.uuid) }
@@ -36,7 +36,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
specify { expect(output).to include(document.signature.certificate.x509.to_text) }
end
- describe "#raw" do
+ describe '#raw' do
let(:command) { "decode raw #{tempfile}" }
let(:tempfile) { Tempfile.new('saml-kit').path }
let(:document) { Saml::Kit::AuthenticationRequest.build }
spec/saml/kit/cli/commands/metadata_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Metadata do
after { File.unlink(tempfile) if File.exist?(tempfile) }
- describe "#register" do
+ describe '#register' do
let(:command) { "metadata register #{entity_id}" }
specify { expect(status).to be_success }
@@ -14,35 +14,35 @@ RSpec.describe Saml::Kit::Cli::Commands::Metadata do
specify { expect(output).to match(/opening connection to saml-kit-proof.herokuapp.com:443.../) }
end
- describe "#show" do
+ describe '#show' do
let(:command) { "metadata show #{entity_id}" }
- context "when the entity_id is registered" do
+ context 'when the entity_id is registered' do
before { execute("metadata register #{entity_id}") }
specify { expect(status).to be_success }
specify { expect(output).to include(entity_id) }
end
- context "when the entity_id is not registered" do
+ context 'when the entity_id is not registered' do
specify { expect(status).to be_success }
specify { expect(output).to include("`#{entity_id}` is not registered") }
end
end
- describe "#list" do
- let(:command) { "metadata list" }
+ describe '#list' do
+ let(:command) { 'metadata list' }
- context "when a metadata is registered" do
+ context 'when a metadata is registered' do
before { execute("metadata register #{entity_id}") }
specify { expect(status).to be_success }
specify { expect(output).to include(entity_id) }
end
- context "when zero metadata is registered" do
+ context 'when zero metadata is registered' do
specify { expect(status).to be_success }
- specify { expect(output).to include("Please register metadata using `saml-kit metadata register <url>`") }
+ specify { expect(output).to include('Please register metadata using `saml-kit metadata register <url>`') }
end
end
end
spec/saml/kit/cli/commands/xml_digital_signature_spec.rb
@@ -1,8 +1,8 @@
RSpec.describe Saml::Kit::Cli::Commands::Certificate do
- describe "#verify" do
+ describe '#verify' do
let(:command) { "xmldsig verify #{tempfile}" }
let(:tempfile) { Tempfile.new('saml-kit').path }
- let(:entity_id) { SecureRandom.uuid }
+ let(:entity_id) { SecureRandom.uuid }
let(:configuration) do
Saml::Kit::Configuration.new do |config|
config.entity_id = entity_id
@@ -13,7 +13,7 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
before { IO.write(tempfile, xml) }
after { File.unlink(tempfile) }
- context "file is valid" do
+ context 'file is valid' do
let(:document) { Saml::Kit::AuthenticationRequest.build(configuration: configuration) }
let(:xml) { document.to_xml }
@@ -22,12 +22,12 @@ RSpec.describe Saml::Kit::Cli::Commands::Certificate do
specify { expect(output).to include("success #{tempfile} is valid") }
end
- context "file is invalid" do
+ 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") }
+ specify { expect(output).to include('error Digest value is invalid') }
end
end
end
spec/support/shell_helpers.rb
@@ -1,17 +1,18 @@
-RSpec.shared_context "shell execution" do
+RSpec.shared_context 'shell execution' do
subject { execute(command) }
+
let(:status) { subject[0] }
let(:output) { subject[1] }
- let(:env) { }
+ let(:env) {}
def execute(command, mute: false, env: self.env)
full_command = "#{env} bundle exec ruby ./exe/saml-kit #{command} 2>&1"
puts full_command unless mute
output = `#{full_command}`
- [$?, output]
+ [$CHILD_STATUS, output]
end
end
RSpec.configure do |config|
- config.include_context "shell execution"
+ config.include_context 'shell execution'
end