Sha256: 22ac9f5df0a7f9646d2741f80274b8d794a48805813fa6fea1db84ea1ed04f9d

Contents?: true

Size: 1.75 KB

Versions: 32

Compression:

Stored size: 1.75 KB

Contents

require 'kontena/cli/nodes/reset_token_command'

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

  it 'prompts on token update' do
    expect(subject).to receive(:confirm).with("Resetting the node token will disconnect the agent (unless using --no-reset-connection), and require you to reconfigure the kontena-agent using the new `kontena node env` values before it will be able to reconnect. Are you sure?")

    expect(client).to receive(:put).with('nodes/test-grid/test-node/token', {token: nil, reset_connection: true})

    subject.run(['test-node'])
  end

  it 'PUTs token with reset_connection' do
    expect(client).to receive(:put).with('nodes/test-grid/test-node/token', {token: 'asdf', reset_connection: true})

    subject.run(['--force', '--token=asdf', 'test-node'])
  end

  it 'PUTs to generate token with reset_connection' do
    expect(client).to receive(:put).with('nodes/test-grid/test-node/token', {token: nil, reset_connection: true})

    subject.run(['--force', 'test-node'])
  end

  it 'PUTs to generate token without reset_connection' do
    expect(client).to receive(:put).with('nodes/test-grid/test-node/token', {token: nil, reset_connection: false})

    subject.run(['--force', '--no-reset-connection', 'test-node'])
  end

  it 'DELETEs to clear token without reset_connection' do
    expect(client).to receive(:delete).with('nodes/test-grid/test-node/token', {reset_connection: false})

    subject.run(['--force', '--no-reset-connection', '--clear-token', 'test-node'])
  end

  it 'DELETEs to clear token with reset_connection' do
    expect(client).to receive(:delete).with('nodes/test-grid/test-node/token', {reset_connection: true})

    subject.run(['--force', '--clear-token', 'test-node'])
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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