Sha256: 7a6adbace2ff15d39a1553384b5c4c98e9d2683bcc02dd411571486d941c91db

Contents?: true

Size: 1.4 KB

Versions: 64

Compression:

Stored size: 1.4 KB

Contents

require "kontena/cli/services/secrets/link_command"

describe Kontena::Cli::Services::Secrets::LinkCommand do

  include ClientHelpers

  describe '#execute' do
    it 'requires service as param' do
      expect {
        subject.run([])
      }.to raise_error(Clamp::UsageError)
    end

    it 'requires secret as param' do
      expect {
        subject.run(['service'])
      }.to raise_error(Clamp::UsageError)
    end

    it 'sends secrets to master' do
      data = {
        secrets: [
          {secret: 'MY_PASSWORD', name: 'PASSWORD', type: 'env'}
        ]
      }
      allow(client).to receive(:get).with("services/test-grid/null/foo").and_return({
        'secrets' => []
      })
      expect(client).to receive(:put).with("services/test-grid/null/foo", data)
      subject.run(['foo', 'MY_PASSWORD:PASSWORD:env'])
    end

    it 'appends secret to existing list' do
      original = {
        'secrets' => [
          {'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'}
        ]
      }
      data = {
        secrets: [
          {'secret' => 'FOO', 'name' => 'BAR', 'type' => 'env'},
          {secret: 'MY_PASSWORD', name: 'PASSWORD', type: 'env'}
        ]
      }
      allow(client).to receive(:get).with("services/test-grid/null/foo").and_return(original)
      expect(client).to receive(:put).with("services/test-grid/null/foo", data)
      subject.run(['foo', 'MY_PASSWORD:PASSWORD:env'])
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

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