main
 1# frozen_string_literal: true
 2
 3RSpec.describe Saml::Kit::Cli::Commands::Metadata do
 4  let(:entity_id) { 'https://saml-kit-proof.herokuapp.com/metadata' }
 5  let(:env) { "SAMLKITRC=#{tempfile}" }
 6  let(:tempfile) { Tempfile.new('saml-kit').path }
 7
 8  after { File.unlink(tempfile) if File.exist?(tempfile) }
 9
10  describe '#register' do
11    let(:command) { "metadata register #{entity_id}" }
12
13    specify { expect(status).to be_success }
14    specify { expect(output).to include(entity_id) }
15    specify { expect(output).to match(/EntityDescriptor/) }
16    specify { expect(output).to match(/opening connection to saml-kit-proof.herokuapp.com:443.../) }
17  end
18
19  describe '#show' do
20    let(:command) { "metadata show #{entity_id}" }
21
22    context 'when the entity_id is registered' do
23      before { execute("metadata register #{entity_id}") }
24      specify { expect(status).to be_success }
25      specify { expect(output).to include(entity_id) }
26    end
27
28    context 'when the entity_id is not registered' do
29      specify { expect(status).to be_success }
30      specify { expect(output).to include("`#{entity_id}` is not registered") }
31    end
32  end
33
34  describe '#list' do
35    let(:command) { 'metadata list' }
36
37    context 'when a metadata is registered' do
38      before { execute("metadata register #{entity_id}") }
39
40      specify { expect(status).to be_success }
41      specify { expect(output).to include(entity_id) }
42    end
43
44    context 'when zero metadata is registered' do
45      specify { expect(status).to be_success }
46      specify { expect(output).to include('Register metadata using `saml-kit metadata register <url>`') }
47    end
48  end
49end