Skip to content

Commit

Permalink
(maint) login_with_puppet_access_on should respect --lifetime flag (w…
Browse files Browse the repository at this point in the history
…ith spec tests) (#52)

* (maint) fix puppet access helper to respect lifetime argument

* (maint) Add spec tests for login_with_puppet_access_on
  • Loading branch information
lucywyman authored and tvpartytonight committed Feb 6, 2017
1 parent 625c17e commit c17a8da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/beaker-pe/pe-client-tools/executable_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def login_with_puppet_access_on(host, credentialed_dispatcher, opts={})

user = credentialed_dispatcher.credentials.login
password = credentialed_dispatcher.credentials.password
puppet_access_on(host, 'login', {:stdin => "#{user}\n#{password}\n"})
args = ['login']
args.push "--lifetime #{lifetime}" if lifetime
puppet_access_on(host, *args, {:stdin => "#{user}\n#{password}\n"})
else

# this is a hack
Expand Down
29 changes: 27 additions & 2 deletions spec/beaker-pe/pe-client-tools/executable_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'
require 'beaker'
require 'scooter'

class MixedWithExecutableHelper
include Beaker::DSL::PEClientTools::ExecutableHelper
Expand All @@ -9,7 +10,7 @@ class MixedWithExecutableHelper

let(:method_name) { "puppet_#{tool}_on"}

shared_examples 'pe-client-tool'do
shared_examples 'pe-client-tool' do

it 'has a method to execute the tool' do
expect(subject.respond_to?(method_name)).not_to be(false)
Expand Down Expand Up @@ -55,4 +56,28 @@ class MixedWithExecutableHelper
it 'has a method to login with puppet access' do
expect(subject.respond_to?('login_with_puppet_access_on')).not_to be(false)
end
end

context 'puppet access login with lifetime parameter' do
let(:logger) {Beaker::Logger.new}
let(:test_host) {Beaker::Host.create('my_super_host',
{:roles => ['master', 'agent'],
:platform => 'linux',
:type => 'pe'},
make_opts)}
let(:username) {'T'}
let(:password) {'Swift'}
let(:credentials) {{:login => username, :password => password}}
let(:test_dispatcher) {Scooter::HttpDispatchers::ConsoleDispatcher.new('my_super_host', credentials)}

before do
allow(logger).to receive(:debug) { true }
expect(test_dispatcher).to be_kind_of(Scooter::HttpDispatchers::ConsoleDispatcher)
expect(test_host).to be_kind_of(Beaker::Host)
expect(test_host).to receive(:exec)
end

it 'accepts correct value' do
expect{subject.login_with_puppet_access_on(test_host, test_dispatcher, {:lifetime => '5d'})}.not_to raise_error
end
end
end

0 comments on commit c17a8da

Please sign in to comment.