Sha256: 1970f08f64a8818312bf71fb1aa0355ce104d678318e5661c37590e11763d0a1

Contents?: true

Size: 1.41 KB

Versions: 32

Compression:

Stored size: 1.41 KB

Contents

require 'kontena/cli/nodes/env_command'

describe Kontena::Cli::Nodes::EnvCommand do
  include ClientHelpers
  include OutputHelpers

  context 'for a node created with a token' do
    let :node_token do
      {
        "id" => 'test-grid/node-4',
        "token" => 'TPnBKanfXJpi47CCvuv+Gq319AXvXBi0LL/8grXrhPr9MyqcXHsWbUy0Q3stmPGHhjaqubi5ZCwa7LbnSvZ/Iw=='
      }
    end

    before do
      expect(client).to receive(:get).with('nodes/test-grid/node-4/token').and_return(node_token)
    end

    it 'shows the node env' do
      expect{subject.run(['node-4'])}.to output_lines [
        'KONTENA_URI=ws://someurl.example.com/',
        'KONTENA_NODE_TOKEN=TPnBKanfXJpi47CCvuv+Gq319AXvXBi0LL/8grXrhPr9MyqcXHsWbUy0Q3stmPGHhjaqubi5ZCwa7LbnSvZ/Iw==',
      ]
    end

    it 'shows the --token' do
      expect{subject.run(['--token', 'node-4'])}.to output_lines [
        'TPnBKanfXJpi47CCvuv+Gq319AXvXBi0LL/8grXrhPr9MyqcXHsWbUy0Q3stmPGHhjaqubi5ZCwa7LbnSvZ/Iw==',
      ]
    end
  end

  context 'for a node without any token' do
    before do
      expect(client).to receive(:get).with('nodes/test-grid/node-1/token').and_raise(Kontena::Errors::StandardError.new(404, "Host node does not have a node token"))
    end

    it 'uses the grid token' do
      expect{subject.run(['node-1'])}.to exit_with_error.and output(" [error] Node node-1 was not created with a node token. Use `kontena grid env` instead\n").to_stderr
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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