Sha256: c02bb988691ee49e5faa6f8c80263f085337f9dbb57204238714a43f575552d0

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

RSpec.describe "CSR" do
  describe "fetching a CSR" do
    it "fetches the CSR for specified order" do
      command = %w(csr fetch 123456)
      allow(Digicert::CLI::CSR).to receive_message_chain(:new, :fetch)

      _output = capture_stdout { Digicert::CLI.start(command) }

      expect(Digicert::CLI::CSR).to have_received(:new).with(order_id: "123456")
    end
  end

  describe "generating CSR" do
    context "with existing order" do
      it "generates a new CSR for an existing order" do
        allow(Digicert::CLI::CSR).to receive_message_chain(:new, :generate)
        command = %w(csr generate -o 123456 --key ./spec/fixtures/rsa4096.key)

        _output = capture_stdout { Digicert::CLI.start(command) }

        expect(Digicert::CLI::CSR).to have_received(:new).with(
          order_id: "123456", key: "./spec/fixtures/rsa4096.key",
        )
      end
    end

    context "with provided details" do
      it "generates a new CSR with the details" do
        command = %w(
          csr generate
          --organization_id 1234
          --common_name ribosetest.com
          --key ./spec/fixtures/rsa4096.key
          --san site1.ribosetest.com site2.ribosetest.com
        )

        allow(Digicert::CLI::CSR).to receive_message_chain(:new, :generate)
        _output = capture_stdout { Digicert::CLI.start(command) }

        expect(Digicert::CLI::CSR).to have_received(:new).with(
          organization_id: "1234",
          common_name: "ribosetest.com",
          key: "./spec/fixtures/rsa4096.key",
          san: ["site1.ribosetest.com", "site2.ribosetest.com"],
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
digicert-cli-1.0.0 spec/acceptance/csr_spec.rb
digicert-cli-0.5.2 spec/acceptance/csr_spec.rb
digicert-cli-0.5.1 spec/acceptance/csr_spec.rb
digicert-cli-0.5.0 spec/acceptance/csr_spec.rb