Sha256: 41019407274280f542219dd8295ab4060c23231e2f34e2f3b0118f8af345c555

Contents?: true

Size: 1.27 KB

Versions: 56

Compression:

Stored size: 1.27 KB

Contents

require "kontena/cli/grids/trusted_subnet_command"
require "kontena/cli/grids/trusted_subnets/remove_command"

describe Kontena::Cli::Grids::TrustedSubnets::RemoveCommand do

  include ClientHelpers
  include RequirementsHelper

  expect_to_require_current_master

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

    it 'removes subnet from grid' do
      allow(client).to receive(:get).with("grids/test-grid").and_return(
        'trusted_subnets' => ['192.168.12.0/24', '192.168.50.0/24']
      )
      expect(client).to receive(:put).with(
        'grids/test-grid', hash_including({trusted_subnets: [
          '192.168.12.0/24'
        ]})
      )
      subject.run(['--force', '192.168.50.0/24'])
    end

    it 'supports the --grid option' do
      allow(subject).to receive(:current_grid).and_call_original
      allow(client).to receive(:get).with("grids/ingrid").and_return(
        'trusted_subnets' => ['192.168.12.0/24', '192.168.50.0/24']
      )
      expect(client).to receive(:put).with(
        'grids/ingrid', hash_including({trusted_subnets: [
          '192.168.12.0/24'
        ]})
      )
      subject.run(['--force', '--grid', 'ingrid', '192.168.50.0/24'])
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

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