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.3.5 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.3.5.rc1 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.rc2 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.rc1 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre14 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre13 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre12 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre11 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre10 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre9 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre8 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre7 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre6 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre5 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre4 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre3 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre2 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.4.0.pre1 spec/kontena/cli/services/secrets/link_command_spec.rb
kontena-cli-1.3.4 spec/kontena/cli/services/secrets/link_command_spec.rb