Sha256: f75f33fc3ffed59350354600ce5fb6e9886b8589d2b2cbf754e09346a30c451c

Contents?: true

Size: 1.33 KB

Versions: 20

Compression:

Stored size: 1.33 KB

Contents

require 'kontena/cli/certificate/export_command'

describe Kontena::Cli::Certificate::ExportCommand do
  include ClientHelpers
  include OutputHelpers
  include FixturesHelpers

  let(:subject) { described_class.new("kontena") }

  let(:ca_pem) { fixture('certificates/test/ca.pem') }
  let(:cert_pem) { fixture('certificates/test/cert.pem') }
  let(:key_pem) { fixture('certificates/test/key.pem') }

  let(:certificate) {
    {
      'id' => 'test/test.example.com',
      'subject' => 'test.example.com',
      'certificate' => cert_pem,
      'chain' => ca_pem,
      'private_key' => key_pem,
    }
  }

  before do
    allow(client).to receive(:get).with('certificates/test-grid/test.example.com/export').and_return(certificate)
  end

  it "outputs the cert bundle" do
    expect{subject.run(['test.example.com'])}.to output(cert_pem + ca_pem + key_pem).to_stdout
  end

  describe '--cert' do
    it "outputs the cert bundle" do
      expect{subject.run(['--cert', 'test.example.com'])}.to output(cert_pem).to_stdout
    end
  end

  describe '--chain' do
    it "outputs the cert bundle" do
      expect{subject.run(['--chain', 'test.example.com'])}.to output(ca_pem).to_stdout
    end
  end

  describe '--key' do
    it "outputs the cert bundle" do
      expect{subject.run(['--key', 'test.example.com'])}.to output(key_pem).to_stdout
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
kontena-cli-1.5.4 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.4.rc1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.3 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.2 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.rc1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.pre5 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.pre4 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.pre3 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.pre2 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.5.0.pre1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.3 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.3.rc1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.2 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.2.rc1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.2.pre1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.1.rc1 spec/kontena/cli/certificates/export_command_spec.rb
kontena-cli-1.4.1.pre1 spec/kontena/cli/certificates/export_command_spec.rb