Commit f817feb
Changed files (2)
lib
saml
kit
cli
commands
spec
saml
kit
cli
commands
lib/saml/kit/cli/commands/metadata.rb
@@ -10,6 +10,9 @@ 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>`"
+ end
registry.each do |x|
say x.entity_id, :green
end
spec/saml/kit/cli/commands/metadata_spec.rb
@@ -1,13 +1,13 @@
RSpec.describe Saml::Kit::Cli::Commands::Metadata do
let(:entity_id) { 'https://saml-kit-proof.herokuapp.com/metadata' }
+ let(:env) { "SAMLKITRC=#{tempfile}" }
+ let(:tempfile) { Tempfile.new('saml-kit').path }
+
+ after { File.unlink(tempfile) if File.exist?(tempfile) }
describe "#register" do
- let(:env) { "SAMLKITRC=#{tempfile}" }
- let(:tempfile) { Tempfile.new('saml-kit').path }
let(:command) { "metadata register #{entity_id}" }
- after { File.unlink(tempfile) }
-
specify { expect(status).to be_success }
specify { expect(output).to include(entity_id) }
specify { expect(output).to match(/EntityDescriptor/) }
@@ -15,26 +15,34 @@ RSpec.describe Saml::Kit::Cli::Commands::Metadata do
end
describe "#show" do
- before :each do
- env = "SAMLKITRC=#{Tempfile.new('saml-kit').path}"
- execute("metadata register #{entity_id}", env: env)
- end
-
let(:command) { "metadata show #{entity_id}" }
- specify { expect(status).to be_success }
- specify { expect(output).to include(entity_id) }
- end
+ context "when the entity_id is registered" do
+ before { execute("metadata register #{entity_id}") }
- describe "#list" do
- before :each do
- env = "SAMLKITRC=#{Tempfile.new('saml-kit').path}"
- execute("metadata register #{entity_id}", env: env)
+ specify { expect(status).to be_success }
+ specify { expect(output).to include(entity_id) }
+ end
+
+ 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" }
- specify { expect(status).to be_success }
- specify { expect(output).to include(entity_id) }
+ 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
+ specify { expect(status).to be_success }
+ specify { expect(output).to include("Please register metadata using `saml-kit metadata register <url>`") }
+ end
end
end