Sha256: 4b7aa875c46a60fefecced5800d184294822d6e6f5adf5e4a446f9cf5ef712e3

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 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 'PUTs to clear token without reset_connection' do
    expect(client).to receive(:put).with('nodes/test-grid/test-node/token', {token: '', reset_connection: false})

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-cli-1.4.0.pre5 spec/kontena/cli/nodes/reset_token_command_spec.rb
kontena-cli-1.4.0.pre4 spec/kontena/cli/nodes/reset_token_command_spec.rb
kontena-cli-1.4.0.pre3 spec/kontena/cli/nodes/reset_token_command_spec.rb
kontena-cli-1.4.0.pre2 spec/kontena/cli/nodes/reset_token_command_spec.rb
kontena-cli-1.4.0.pre1 spec/kontena/cli/nodes/reset_token_command_spec.rb