2014-05-07 03:48:59 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
|
|
|
describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
|
|
|
describe 'success' do
|
2015-07-22 18:30:39 +02:00
|
|
|
include_context "with faked facts"
|
|
|
|
context "when the FQDN is 'fakehost.localdomain'" do
|
|
|
|
before :each do
|
|
|
|
fake_fact("fqdn", "fakehost.localdomain")
|
2014-06-24 08:27:59 +02:00
|
|
|
end
|
2014-05-07 03:48:59 +02:00
|
|
|
|
2015-07-22 18:30:39 +02:00
|
|
|
it 'rotates arrays' do
|
|
|
|
pp = <<-EOS
|
|
|
|
$a = ['a','b','c','d']
|
|
|
|
$o = fqdn_rotate($a)
|
|
|
|
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
|
|
|
EOS
|
|
|
|
|
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
|
|
|
|
end
|
2014-05-07 03:48:59 +02:00
|
|
|
end
|
2015-07-22 18:30:39 +02:00
|
|
|
it 'rotates arrays with custom seeds' do
|
|
|
|
pp = <<-EOS
|
|
|
|
$a = ['a','b','c','d']
|
|
|
|
$s = 'seed'
|
|
|
|
$o = fqdn_rotate($a, $s)
|
|
|
|
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
|
|
|
EOS
|
2015-06-02 01:46:08 +02:00
|
|
|
|
2015-07-22 18:30:39 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
|
|
|
|
end
|
2015-06-02 01:46:08 +02:00
|
|
|
end
|
2015-07-22 18:30:39 +02:00
|
|
|
it 'rotates strings' do
|
|
|
|
pp = <<-EOS
|
|
|
|
$a = 'abcd'
|
|
|
|
$o = fqdn_rotate($a)
|
|
|
|
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
|
|
|
EOS
|
2015-06-02 01:46:08 +02:00
|
|
|
|
2015-07-22 18:30:39 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
|
|
|
|
end
|
2015-06-02 01:46:08 +02:00
|
|
|
end
|
2015-07-22 18:30:39 +02:00
|
|
|
it 'rotates strings with custom seeds' do
|
|
|
|
pp = <<-EOS
|
|
|
|
$a = 'abcd'
|
|
|
|
$s = 'seed'
|
|
|
|
$o = fqdn_rotate($a, $s)
|
|
|
|
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
|
|
|
EOS
|
2015-06-02 01:46:08 +02:00
|
|
|
|
2015-07-22 18:30:39 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
|
|
|
|
end
|
2015-06-02 01:46:08 +02:00
|
|
|
end
|
|
|
|
end
|
2014-05-07 03:48:59 +02:00
|
|
|
end
|
|
|
|
describe 'failure' do
|
|
|
|
it 'handles improper argument counts'
|
2015-06-02 01:46:08 +02:00
|
|
|
it 'handles invalid arguments'
|
2014-05-07 03:48:59 +02:00
|
|
|
end
|
|
|
|
end
|