Sha256: d717ca273b40d139b6d01e15334b356b6b4f1084a7717904c611c1305c1b9541

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Conjur::Command::Variables, logged_in: true do
  let(:collection_url) { "https://core.example.com/variables" }

  let(:base_payload) { { mime_type: 'text/json', kind: 'password' } }

  describe_command "variable:create -m text/json -k password" do
    it "lets the server assign the id" do
     RestClient::Request.should_receive(:execute).with(
        method: :post,
        url: collection_url,
        headers: {},
        payload: base_payload
      ).and_return(post_response('assigned-id'))

      expect { invoke }.to write({ id: 'assigned-id' }).to(:stdout)
    end
  end
  describe_command "variable:create -m text/json -k password the-id" do
    it "propagates the user-assigned id" do
     RestClient::Request.should_receive(:execute).with(
        method: :post,
        url: collection_url,
        headers: {},
        payload: base_payload.merge({ id: 'the-id' })
      ).and_return(post_response('the-id'))

      expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
    end
  end


  describe_command "variable:create" do
    it "provides default values for optional parameters mime_type and kind" do
      RestClient::Request.should_receive(:execute).with(
        method: :post,
        url: collection_url,
        headers: {},
        payload: { mime_type: 'text/plain', kind: 'secret'}
        ).and_return(post_response('the-id'))
      expect { invoke }.to write # invoke_silently
    end
  end



end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
conjur-cli-4.8.0 spec/command/variables_spec.rb
conjur-cli-4.7.5 spec/command/variables_spec.rb
conjur-cli-4.7.4 spec/command/variables_spec.rb
conjur-cli-4.7.3 spec/command/variables_spec.rb
conjur-cli-4.7.2 spec/command/variables_spec.rb
conjur-cli-4.7.1 spec/command/variables_spec.rb
conjur-cli-4.7.0 spec/command/variables_spec.rb
conjur-cli-4.6.1 spec/command/variables_spec.rb
conjur-cli-4.5.1 spec/command/variables_spec.rb
conjur-cli-4.5.0 spec/command/variables_spec.rb
conjur-cli-4.4.0 spec/command/variables_spec.rb