beaker 3.36.0 → 3.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/CONTRIBUTING.md +46 -2
- data/docs/how_to/hypervisors/README.md +9 -5
- data/docs/tutorials/subcommands.md +1 -1
- data/lib/beaker/cli.rb +11 -24
- data/lib/beaker/logger.rb +1 -1
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/fog_credentials.rb +61 -0
- data/lib/beaker/subcommand.rb +5 -3
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +21 -0
- data/spec/beaker/logger_spec.rb +4 -0
- data/spec/beaker/shared/fog_credentials_spec.rb +100 -0
- data/spec/beaker/subcommand_spec.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65affe7f42763474ab6859ece3eecd8804e8e313
|
4
|
+
data.tar.gz: 72fcac34ef28fc6c15dffa7d71e42a83a65d0676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f160ec4f6589e6cf8e5e5eb737ebb896be7123317141ea34d406332c45734916aadd15a7eaa81a4ce7ffa5ffc206c653b0a9fa20421b0dd466b42bfba7b7faa
|
7
|
+
data.tar.gz: 83a4209a5c18acec0c56ef9d951311972115dc08bffe1da60aac97725b4385517ae94d280d34cbd75d9005179edc590cc62dd8ef6c510047b3c4bbcdeece4395
|
data/CHANGELOG.md
CHANGED
@@ -11,7 +11,17 @@ Tracking in this Changelog began for this project in version 3.25.0.
|
|
11
11
|
If you're looking for changes from before this, refer to the project's
|
12
12
|
git logs & PR history.
|
13
13
|
|
14
|
-
# [Unreleased](https://github.com/puppetlabs/beaker/compare/3.
|
14
|
+
# [Unreleased](https://github.com/puppetlabs/beaker/compare/3.37.0...master)
|
15
|
+
|
16
|
+
# [3.37.0](https://github.com/puppetlabs/beaker/compare/3.36.0...3.37.0) - 2018-07-11
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Exit early on --help/--version/--parse-only arguments instead of partial dry-run
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- `Beaker::Shared::FogCredentials.get_fog_credentials()` to parse .fog credential files
|
15
25
|
|
16
26
|
# [3.36.0](https://github.com/puppetlabs/beaker/compare/3.35.0...3.36.0) - 2018-06-18
|
17
27
|
|
data/CONTRIBUTING.md
CHANGED
@@ -16,8 +16,10 @@ Beaker does not use GitHub Issues, but an internal ticketing system running Jira
|
|
16
16
|
|
17
17
|
## Making Changes
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
Contributions are accepted in the form of pull requests against the master branch on GitHub.
|
20
|
+
|
21
|
+
* Create a topic branch on your fork of [puppetlabs/beaker](https://github.com/puppetlabs/beaker) based on `master`.
|
22
|
+
* Make commits of logical units. If your commits are a mess, you will be asked to [rebase or at least squash](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History) your PR.
|
21
23
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
22
24
|
* Make sure your commit messages are in the proper format:
|
23
25
|
```
|
@@ -28,6 +30,48 @@ Beaker does not use GitHub Issues, but an internal ticketing system running Jira
|
|
28
30
|
The first line is a real life imperative statement with a ticket number from our issue tracker. The body describes the behavior without the patch, why this is a problem, and how the patch fixes the problem when applied.
|
29
31
|
```
|
30
32
|
* During the time that you are working on your patch the master Beaker branch may have changed - be sure to [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) on top of [Beaker's](https://github.com/puppetlabs/beaker) master branch before you submit your PR. A successful rebase ensures that your PR will merge cleanly.
|
33
|
+
* When you're ready for review, create a new pull request.
|
34
|
+
|
35
|
+
#### PR Requirements
|
36
|
+
|
37
|
+
Pull Requests are subject to the following requirements:
|
38
|
+
|
39
|
+
* Commits must be logical units. Follow these [basic guidelines](https://github.com/trein/dev-best-practices/wiki/Git-Commit-Best-Practices#basic-rules), and don't be afraid to make too many commits: it's always easier to squash than to fixup.
|
40
|
+
* Must not contain changes unrelated to the ticket being worked on. Issues you encounter as directly related to the main work for a ticket are fiar game. Many beaker components only get infrequent updates so it is not uncommon to encounter dependency version changes that cause problems. These can be addressed with a `(MAINT)` commit within the feature PR you're working on. Larger or only peripherally related changes should go through their own ticket, which you can create; tickets with attached PRs are generally accepted.
|
41
|
+
* Must merge cleanly. Only fast-forward merges are accepted, so make sure the PR shows as a clean merge.
|
42
|
+
* On that note, merge commits are not accepted. In order to keep your feature branch up-to-date and ensure a clean merge, you should [rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) on top of beaker's master. You can also use this opportunity to keep your fork up to date. That workflow looks like this:
|
43
|
+
~~~console
|
44
|
+
you@local:beaker $ git checkout master
|
45
|
+
Switched to branch 'master'
|
46
|
+
Your branch is up to date with 'origin/master'.
|
47
|
+
you@local:beaker $ git fetch upstream
|
48
|
+
you@local:beaker $ git merge upstream/master
|
49
|
+
Updating a01b5732..a565e1ac
|
50
|
+
Fast-forward
|
51
|
+
lib/beaker/logger.rb | 2 +-
|
52
|
+
spec/beaker/logger_spec.rb | 4 ++++
|
53
|
+
2 files changed, 5 insertions(+), 1 deletion(-)
|
54
|
+
you@local:beaker $ git push
|
55
|
+
Total 0 (delta 0), reused 0 (delta 0)
|
56
|
+
To https://github.com/Dakta/beaker.git
|
57
|
+
a01b5732..a565e1ac master -> master
|
58
|
+
you@local:beaker $ git checkout BKR-816
|
59
|
+
Switched to branch 'BKR-816'
|
60
|
+
you@local:beaker $ git rebase master
|
61
|
+
# if you have conflicts, they'll appear here. Manually fix the listed files then use `git rebase --continue`. Repeat as necessary for each conflicting commit.
|
62
|
+
First, rewinding head to replay your work on top of it...
|
63
|
+
Fast-forwarded BKR-816 to master.
|
64
|
+
you@local:beaker $ git push --set-upstream origin BKR-816
|
65
|
+
Counting objects: 9, done.
|
66
|
+
Delta compression using up to 8 threads.
|
67
|
+
Compressing objects: 100% (9/9), done.
|
68
|
+
Writing objects: 100% (9/9), 2.05 KiB | 2.05 MiB/s, done.
|
69
|
+
Total 9 (delta 6), reused 0 (delta 0)
|
70
|
+
remote: Resolving deltas: 100% (6/6), completed with 6 local objects.
|
71
|
+
To https://github.com/Dakta/beaker.git
|
72
|
+
+ [new branch] BKR-816 -> BKR-816
|
73
|
+
Branch 'BKR-816' set up to track remote branch 'BKR-816' from 'origin'.
|
74
|
+
~~~
|
31
75
|
|
32
76
|
#### Courtesy
|
33
77
|
|
@@ -13,13 +13,17 @@ By default, the file is located under the user's home directory. This helps to k
|
|
13
13
|
The `.fog` file is written in YAML. The keys are particular to the service that they correspond to, and each hypervisor's documentation should include the keys that are needed for it. An example `.fog` file is below:
|
14
14
|
|
15
15
|
```yaml
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
default:
|
17
|
+
vsphere_server: 'vsphere.example.com'
|
18
|
+
vsphere_username: 'joe'
|
19
|
+
vsphere_password: 'MyP@$$w0rd'
|
20
|
+
vmpooler_token: 'randomtokentext'
|
21
21
|
```
|
22
22
|
|
23
|
+
Note: keys can be specified as either Strings or as Ruby Symbols (e.g. `:vsphere_server`). For interoprability with other systems, however, it is prudent to use Strings.
|
24
|
+
|
25
|
+
The credentials file supports multiple sections. Hypervisors currently do not specify a section, and the normal behavior is to fall back to using the `default` section. You can override the section by specifying an environment variable, [as documented on the fog website](https://fog.io/about/getting_started.html). Set `ENV['FOG_CREDENTIAL']` to specify an alternative provider section and `Beaker::Shared::FogFileParser.parse_fog_file()` will attempt to load that section, no matter what other section the hypervisor specifies.
|
26
|
+
|
23
27
|
# External Hypervisors
|
24
28
|
|
25
29
|
Puppet and its community have made several gems that support different hypervisors with beaker, the reason for this is that we're looking to decrease Beaker's dependency footprint, and hypervisors are one of the places where we can often increase the load across all Beaker uses to benefit a small group that uses a particular hypervisor.
|
@@ -22,7 +22,7 @@ Provisions hosts defined in your `subcommand_options file`. You can pass the `--
|
|
22
22
|
|
23
23
|
### beaker exec
|
24
24
|
|
25
|
-
Run
|
25
|
+
Run either files, directories, or beaker suites. If supplied a file or directory, that resource will be run in the context of the `tests` suite; If supplied a beaker suite, then just that suite will run. If no resource is supplied, then this command executes the suites as they are defined in the configuration. Accepts a comma-separated, homogeneous list. E.g. only files, only directories, or only suites, such as: `exec pre-suite,tests`
|
26
26
|
|
27
27
|
### beaker destroy
|
28
28
|
|
data/lib/beaker/cli.rb
CHANGED
@@ -19,9 +19,9 @@ module Beaker
|
|
19
19
|
@options = {}
|
20
20
|
end
|
21
21
|
|
22
|
-
def parse_options
|
22
|
+
def parse_options(args = ARGV)
|
23
23
|
@options_parser = Beaker::Options::Parser.new
|
24
|
-
@options = @options_parser.parse_args
|
24
|
+
@options = @options_parser.parse_args(args)
|
25
25
|
@attribution = @options_parser.attribution
|
26
26
|
@logger = Beaker::Logger.new(@options)
|
27
27
|
InParallel::InParallelExecutor.logger = @logger
|
@@ -30,16 +30,18 @@ module Beaker
|
|
30
30
|
@options_parser.update_option(:beaker_version, Beaker::Version::STRING, 'runtime')
|
31
31
|
beaker_version_string = VERSION_STRING % @options[:beaker_version]
|
32
32
|
|
33
|
+
# Some flags should exit early
|
33
34
|
if @options[:help]
|
34
35
|
@logger.notify(@options_parser.usage)
|
35
|
-
|
36
|
-
return self
|
36
|
+
exit(0)
|
37
37
|
end
|
38
|
-
|
39
38
|
if @options[:beaker_version_print]
|
40
39
|
@logger.notify(beaker_version_string)
|
41
|
-
|
42
|
-
|
40
|
+
exit(0)
|
41
|
+
end
|
42
|
+
if @options[:parse_only]
|
43
|
+
print_version_and_options
|
44
|
+
exit(0)
|
43
45
|
end
|
44
46
|
|
45
47
|
#add additional paths to the LOAD_PATH
|
@@ -52,13 +54,6 @@ module Beaker
|
|
52
54
|
require File.expand_path(helper)
|
53
55
|
end
|
54
56
|
|
55
|
-
if @options[:parse_only]
|
56
|
-
print_version_and_options
|
57
|
-
@execute = false
|
58
|
-
return self
|
59
|
-
end
|
60
|
-
|
61
|
-
@execute = true
|
62
57
|
self
|
63
58
|
end
|
64
59
|
|
@@ -69,11 +64,8 @@ module Beaker
|
|
69
64
|
@logger.info(@options.dump)
|
70
65
|
end
|
71
66
|
|
72
|
-
#Provision, validate and configure all hosts as defined in the hosts file
|
67
|
+
# Provision, validate and configure all hosts as defined in the hosts file
|
73
68
|
def provision
|
74
|
-
# return self if only invoking the OptionsParser help
|
75
|
-
return self if @options[:help]
|
76
|
-
|
77
69
|
begin
|
78
70
|
@hosts = []
|
79
71
|
initialize_network_manager
|
@@ -96,18 +88,13 @@ module Beaker
|
|
96
88
|
end
|
97
89
|
end
|
98
90
|
|
99
|
-
#Run Beaker tests.
|
91
|
+
# Run Beaker tests.
|
100
92
|
#
|
101
|
-
# - provision hosts (includes validation and configuration)
|
102
93
|
# - run pre-suite
|
103
94
|
# - run tests
|
104
95
|
# - run post-suite
|
105
96
|
# - cleanup hosts
|
106
97
|
def execute!
|
107
|
-
if !@execute
|
108
|
-
return
|
109
|
-
end
|
110
|
-
|
111
98
|
print_version_and_options
|
112
99
|
|
113
100
|
begin
|
data/lib/beaker/logger.rb
CHANGED
@@ -203,7 +203,7 @@ module Beaker
|
|
203
203
|
end
|
204
204
|
else
|
205
205
|
# Remove invalid and undefined UTF-8 character encodings
|
206
|
-
string.to_s.force_encoding('UTF-8')
|
206
|
+
string = string.to_s.dup.force_encoding('UTF-8')
|
207
207
|
return string.to_s.chars.select{|i| i.valid_encoding?}.join
|
208
208
|
end
|
209
209
|
end
|
data/lib/beaker/shared.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver'].each do |lib|
|
1
|
+
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver', 'fog_credentials'].each do |lib|
|
2
2
|
require "beaker/shared/#{lib}"
|
3
3
|
end
|
4
4
|
module Beaker
|
@@ -9,6 +9,7 @@ module Beaker
|
|
9
9
|
include Beaker::Shared::Timed
|
10
10
|
include Beaker::Shared::Semvar
|
11
11
|
include Beaker::Shared::OptionsResolver
|
12
|
+
include Beaker::Shared::FogCredentials
|
12
13
|
end
|
13
14
|
end
|
14
15
|
include Beaker::Shared
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'stringify-hash'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Shared
|
5
|
+
# A set of functions to read .fog files
|
6
|
+
module FogCredentials
|
7
|
+
# Constructs ArgumentError with common phrasing for #get_fog_credentials errors
|
8
|
+
#
|
9
|
+
# @param path [String] path to offending file
|
10
|
+
# @param from_env [String] if the path was overridden in ENV
|
11
|
+
# @param reason [String] explanation for the failure
|
12
|
+
# @return [ArgumentError] ArgumentError with preformatted message
|
13
|
+
def fog_credential_error(path = nil, from_env = nil, reason = nil)
|
14
|
+
message = "Failed loading credentials from .fog file"
|
15
|
+
message << " '#{path}'" if path
|
16
|
+
message << " #{from_env}" if from_env
|
17
|
+
message << "."
|
18
|
+
message << "Reason: #{reason}" if reason
|
19
|
+
ArgumentError.new(message)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Load credentials from a .fog file
|
23
|
+
#
|
24
|
+
# @note Loaded .fog files may use symbols for keys.
|
25
|
+
# Although not clearly documented, it is valid:
|
26
|
+
# https://www.rubydoc.info/gems/fog-core/1.42.0/Fog#credential-class_method
|
27
|
+
# https://github.com/fog/fog-core/blob/7865ef77ea990fd0d085e49c28e15957b7ce0d2b/spec/utils_spec.rb#L11
|
28
|
+
#
|
29
|
+
# @param fog_file_path [String] dot fog path. Overridden by ENV["FOG_RC"]
|
30
|
+
# @param credential_group [String, Symbol] Credential group to use. Overridden by ENV["FOG_CREDENTIAL"]
|
31
|
+
# @return [StringifyHash] credentials stored in fog_file_path
|
32
|
+
# @raise [ArgumentError] when the credentials cannot be loaded, describing the reson
|
33
|
+
def get_fog_credentials(fog_file_path = '~/.fog', credential_group = :default)
|
34
|
+
# respect file location from env
|
35
|
+
if ENV["FOG_RC"]
|
36
|
+
fog_file_path = ENV["FOG_RC"]
|
37
|
+
from_env = ' set in ENV["FOG_RC"]'
|
38
|
+
end
|
39
|
+
begin
|
40
|
+
fog = YAML.load_file(fog_file_path)
|
41
|
+
rescue Psych::SyntaxError, Errno::ENOENT => e
|
42
|
+
raise fog_credential_error fog_file_path, from_env, "(#{e.class}) #{e.message}"
|
43
|
+
end
|
44
|
+
if fog == false # YAML.load => false for empty file
|
45
|
+
raise fog_credential_error fog_file_path, from_env, "is empty."
|
46
|
+
end
|
47
|
+
# transparently support symbols or strings for keys
|
48
|
+
fog = StringifyHash.new.merge!(fog)
|
49
|
+
# respect credential from env
|
50
|
+
# @note ENV must be a string, e.g. "default" not ":default"
|
51
|
+
if ENV["FOG_CREDENTIAL"]
|
52
|
+
credential_group = ENV["FOG_CREDENTIAL"].to_sym
|
53
|
+
end
|
54
|
+
if not fog[credential_group]
|
55
|
+
raise fog_credential_error fog_file_path, from_env, "could not load the specified credential group '#{credential_group}'."
|
56
|
+
end
|
57
|
+
fog[credential_group]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/beaker/subcommand.rb
CHANGED
@@ -149,12 +149,14 @@ module Beaker
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
desc 'exec FILE/BEAKER_SUITE', 'execute
|
152
|
+
desc 'exec FILE(S)/BEAKER_SUITE', 'execute directories, files, or beaker suites'
|
153
153
|
long_desc <<-LONG_DESC
|
154
|
-
Run
|
154
|
+
Run either files, directories, or beaker suites. If supplied a file or directory,
|
155
155
|
that resource will be run in the context of the `tests` suite; If supplied a beaker
|
156
156
|
suite, then just that suite will run. If no resource is supplied, then this command
|
157
|
-
executes the suites as they are defined in the configuration.
|
157
|
+
executes the suites as they are defined in the configuration. Accepts a comma
|
158
|
+
-separated, homogeneous list. E.g. only files, only directories, or only suites,
|
159
|
+
such as: exec pre-suite,tests
|
158
160
|
LONG_DESC
|
159
161
|
option :help, :type => :boolean, :hide => true
|
160
162
|
def exec(resource=nil)
|
data/lib/beaker/version.rb
CHANGED
data/spec/beaker/cli_spec.rb
CHANGED
@@ -32,6 +32,27 @@ module Beaker
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe '#parse_options special behavior' do
|
36
|
+
# NOTE: this `describe` block must be separate, with the following `before` block.
|
37
|
+
# Use the above `describe` block for #parse_options when access to the logger object is not needed
|
38
|
+
before do
|
39
|
+
# Within parse_options() the reassignment of cli.logger makes it impossible to capture subsequent logger calls.
|
40
|
+
# So, hijack the reassignment call so that we can keep a reference to it.
|
41
|
+
allow(Beaker::Logger).to receive(:new).with(no_args).once.and_call_original
|
42
|
+
allow(Beaker::Logger).to receive(:new).once.and_return(cli.instance_variable_get(:@logger))
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'prints the version and exits cleanly' do
|
46
|
+
expect(cli.logger).to receive(:notify).once
|
47
|
+
expect{ cli.parse_options(['--version']) }.to raise_exception(SystemExit) { |e| expect(e.success?).to eq(true) }
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'prints the help and exits cleanly' do
|
51
|
+
expect(cli.logger).to receive(:notify).once
|
52
|
+
expect{ cli.parse_options(['--help']) }.to raise_exception(SystemExit) { |e| expect(e.success?).to eq(true) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
35
56
|
describe '#print_version_and_options' do
|
36
57
|
before do
|
37
58
|
options = Beaker::Options::OptionsHash.new
|
data/spec/beaker/logger_spec.rb
CHANGED
@@ -24,6 +24,10 @@ module Beaker
|
|
24
24
|
pending "not supported in ruby 1.8 (using #{RUBY_VERSION})"
|
25
25
|
end
|
26
26
|
end
|
27
|
+
it 'supports frozen strings' do
|
28
|
+
valid_utf8.freeze
|
29
|
+
expect( logger.convert(valid_utf8) ).to be === valid_utf8
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
context '#generate_dated_log_folder' do
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Shared
|
5
|
+
describe FogCredentials do
|
6
|
+
context "#get_fog_credentials" do
|
7
|
+
it 'raises ArgumentError when fog file is missing' do
|
8
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'raises ArgumentError when fog file is empty' do
|
12
|
+
expect( File ).to receive( :open ) { "" }
|
13
|
+
|
14
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog') }.to raise_error( ArgumentError )
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'raises ArgumentError when fog file does not contain "default" section and no section is specified' do
|
18
|
+
data = { :some => { :other => :data } }
|
19
|
+
|
20
|
+
expect( YAML ).to receive( :load_file ) { data }
|
21
|
+
|
22
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises ArgumentError when fog file does not contain another section passed by argument' do
|
26
|
+
data = { :some => { :other => :data } }
|
27
|
+
|
28
|
+
expect( YAML ).to receive( :load_file ) { data }
|
29
|
+
|
30
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :other_credential ) }.to raise_error( ArgumentError )
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises ArgumentError when there are formatting errors in the fog file' do
|
34
|
+
data = { "'default'" => { :vmpooler_token => "b2wl8prqe6ddoii70md" } }
|
35
|
+
|
36
|
+
expect( YAML ).to receive( :load_file ) { data }
|
37
|
+
|
38
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError )
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'raises ArgumentError when there are syntax errors in the fog file' do
|
42
|
+
data = ";default;\n :vmpooler_token: z2wl8prqe0ddoii707d"
|
43
|
+
|
44
|
+
allow( File ).to receive( :open ).and_yield( StringIO.new( data ) )
|
45
|
+
|
46
|
+
expect{ get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' ) }.to raise_error( ArgumentError, /Psych::SyntaxError/ )
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns the named credential section' do
|
50
|
+
data = {
|
51
|
+
:default => { :vmpooler_token => "wrong_token"},
|
52
|
+
:other_credential => { :vmpooler_token => "correct_token" }
|
53
|
+
}
|
54
|
+
|
55
|
+
expect( YAML ).to receive( :load_file ) { data }
|
56
|
+
|
57
|
+
expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :other_credential )[:vmpooler_token] ).to eq( "correct_token" )
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns the named credential section from ENV["FOG_CREDENTIAL"]' do
|
61
|
+
ENV['FOG_CREDENTIAL'] = 'other_credential'
|
62
|
+
data = {
|
63
|
+
:default => { :vmpooler_token => "wrong_token"},
|
64
|
+
:other_credential => { :vmpooler_token => "correct_token" }
|
65
|
+
}
|
66
|
+
|
67
|
+
expect( YAML ).to receive( :load_file ) { data }
|
68
|
+
|
69
|
+
expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog' )[:vmpooler_token] ).to eq( "correct_token" )
|
70
|
+
ENV.delete( 'FOG_CREDENTIAL' )
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns the named credential section from ENV["FOG_CREDENTIAL"] even when an argument is provided' do
|
74
|
+
ENV['FOG_CREDENTIAL'] = 'other_credential'
|
75
|
+
data = {
|
76
|
+
:default => { :vmpooler_token => "wrong_token"},
|
77
|
+
:other_credential => { :vmpooler_token => "correct_token" }
|
78
|
+
}
|
79
|
+
|
80
|
+
expect( YAML ).to receive( :load_file ) { data }
|
81
|
+
|
82
|
+
expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :default )[:vmpooler_token] ).to eq( "correct_token" )
|
83
|
+
ENV.delete( 'FOG_CREDENTIAL' )
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'returns the named credential section from ENV["FOG_RC"] path' do
|
87
|
+
ENV['FOG_RC'] = '/some/other/path/to/.fog'
|
88
|
+
data = {
|
89
|
+
:default => { :vmpooler_token => "correct_token"},
|
90
|
+
:other_credential => { :vmpooler_token => "wrong_token" }
|
91
|
+
}
|
92
|
+
|
93
|
+
expect( YAML ).to receive( :load_file ).with( '/some/other/path/to/.fog' ) { data }
|
94
|
+
|
95
|
+
expect( get_fog_credentials( fog_file_path = '/path/that/does/not/exist/.fog', credential = :default )[:vmpooler_token] ).to eq( "correct_token" )
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -176,6 +176,7 @@ module Beaker
|
|
176
176
|
before :each do
|
177
177
|
allow(subcommand.cli).to receive(:parse_options)
|
178
178
|
allow(subcommand.cli).to receive(:initialize_network_manager)
|
179
|
+
allow(subcommand.cli).to receive(:execute!)
|
179
180
|
end
|
180
181
|
|
181
182
|
it 'calls execute! when no resource is given' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.37.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -707,6 +707,7 @@ files:
|
|
707
707
|
- lib/beaker/result.rb
|
708
708
|
- lib/beaker/shared.rb
|
709
709
|
- lib/beaker/shared/error_handler.rb
|
710
|
+
- lib/beaker/shared/fog_credentials.rb
|
710
711
|
- lib/beaker/shared/host_manager.rb
|
711
712
|
- lib/beaker/shared/options_resolver.rb
|
712
713
|
- lib/beaker/shared/repetition.rb
|
@@ -778,6 +779,7 @@ files:
|
|
778
779
|
- spec/beaker/perf_spec.rb
|
779
780
|
- spec/beaker/platform_spec.rb
|
780
781
|
- spec/beaker/shared/error_handler_spec.rb
|
782
|
+
- spec/beaker/shared/fog_credentials_spec.rb
|
781
783
|
- spec/beaker/shared/host_manager_spec.rb
|
782
784
|
- spec/beaker/shared/options_resolver_spec.rb
|
783
785
|
- spec/beaker/shared/repetition_spec.rb
|