octopus-serverspec-extensions 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -14
  3. data/.rspec +2 -2
  4. data/.travis.yml +5 -5
  5. data/Gemfile +4 -4
  6. data/LICENSE.txt +12 -12
  7. data/README.md +39 -39
  8. data/Rakefile +6 -6
  9. data/bin/console +14 -14
  10. data/bin/setup +8 -8
  11. data/docs/authentication.md +45 -45
  12. data/docs/octopus_deploy_account.md +37 -37
  13. data/docs/octopus_deploy_doc_template.md +16 -16
  14. data/docs/octopus_deploy_environment.md +32 -32
  15. data/docs/octopus_deploy_project_group.md +30 -30
  16. data/docs/octopus_deploy_smtp_config.md +39 -39
  17. data/docs/octopus_deploy_space.md +32 -32
  18. data/docs/octopus_deploy_team.md +25 -25
  19. data/docs/octopus_deploy_tentacle.md +40 -40
  20. data/docs/octopus_deploy_upgrade_config.md +33 -33
  21. data/docs/octopus_deploy_user.md +33 -33
  22. data/docs/octopus_deploy_worker.md +38 -38
  23. data/docs/octopus_deploy_worker_pool.md +25 -25
  24. data/lib/octopus_serverspec_extensions.rb +85 -85
  25. data/lib/octopus_serverspec_extensions/matcher/allow_dynamic_infrastructure.rb +12 -12
  26. data/lib/octopus_serverspec_extensions/matcher/have_linux_line_endings.rb +13 -13
  27. data/lib/octopus_serverspec_extensions/matcher/have_version.rb +36 -36
  28. data/lib/octopus_serverspec_extensions/matcher/have_windows_line_endings.rb +13 -13
  29. data/lib/octopus_serverspec_extensions/matcher/run_under_account.rb +17 -17
  30. data/lib/octopus_serverspec_extensions/matcher/use_guided_failure.rb +12 -12
  31. data/lib/octopus_serverspec_extensions/type/chocolatey_package.rb +33 -33
  32. data/lib/octopus_serverspec_extensions/type/java_property_file.rb +28 -28
  33. data/lib/octopus_serverspec_extensions/type/npm_package.rb +36 -36
  34. data/lib/octopus_serverspec_extensions/type/octopus_deploy_account.rb +176 -176
  35. data/lib/octopus_serverspec_extensions/type/octopus_deploy_environment.rb +117 -117
  36. data/lib/octopus_serverspec_extensions/type/octopus_deploy_project_group.rb +127 -127
  37. data/lib/octopus_serverspec_extensions/type/octopus_deploy_smtp_config.rb +109 -109
  38. data/lib/octopus_serverspec_extensions/type/octopus_deploy_space.rb +92 -92
  39. data/lib/octopus_serverspec_extensions/type/octopus_deploy_team.rb +81 -81
  40. data/lib/octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb +208 -208
  41. data/lib/octopus_serverspec_extensions/type/octopus_deploy_upgrade_config.rb +112 -112
  42. data/lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb +110 -110
  43. data/lib/octopus_serverspec_extensions/type/octopus_deploy_worker.rb +173 -173
  44. data/lib/octopus_serverspec_extensions/type/octopus_deploy_worker_pool.rb +88 -88
  45. data/lib/octopus_serverspec_extensions/type/windows_dsc.rb +37 -37
  46. data/lib/octopus_serverspec_extensions/type/windows_firewall.rb +32 -32
  47. data/lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb +33 -33
  48. data/lib/octopus_serverspec_extensions/version.rb +3 -3
  49. data/octopus-serverspec-extensions.gemspec +34 -34
  50. metadata +15 -16
@@ -1,39 +1,39 @@
1
- # octopus_deploy_worker
2
-
3
- Describes the state of an [Octopus Deploy Worker](https://octopus.com/docs/infrastructure/workers) Agent resource
4
-
5
- A worker is essentially a specialised version of the [Tentacle Agent](octopus_deploy_tentacle.md) resource, so this Type has much in common.
6
-
7
- ## Example
8
-
9
- ```ruby
10
- describe octopus_worker('WorkerInstance').in_space('TeamBlue') do
11
- it { should exist }
12
- it { should be_online }
13
- it { should be_listening_worker }
14
- it { should have_display_name('Blue Team worker') }
15
- end
16
- ```
17
-
18
-
19
- #### Type
20
-
21
- ```ruby
22
- octopus_deploy_worker([url, api_key], instance_name)
23
- octopus_worker([url, api_key], instance_name)
24
- octopus_deploy_worker([url, api_key], instance_name).in_space(space_name)
25
-
26
- ```
27
-
28
- #### Matchers
29
-
30
- | Matcher | Description |
31
- |:--------|:------------|
32
- | should exist | Tests if tentacle.exe is present locally |
33
- | should be_registered_with_the_server | Checks if this worker instance is present in the target server |
34
- | should be_online | Tests if the worker has a status of 'online'. If the machine is in a healthcheck, waits until healthcheck completes |
35
- | should be_in_space(space_name) | Tests if a worker appears in a given space. _deprecated_. |
36
- | should have_policy(policy_name) | Tests if a worker has a give policy applied |
37
- | should have_display_name | Tests if a worker has a given display name |
38
- | should be_polling_worker | Tests if a worker is in the 'polling' or 'Active' mode |
1
+ # octopus_deploy_worker
2
+
3
+ Describes the state of an [Octopus Deploy Worker](https://octopus.com/docs/infrastructure/workers) Agent resource
4
+
5
+ A worker is essentially a specialised version of the [Tentacle Agent](octopus_deploy_tentacle.md) resource, so this Type has much in common.
6
+
7
+ ## Example
8
+
9
+ ```ruby
10
+ describe octopus_worker('WorkerInstance').in_space('TeamBlue') do
11
+ it { should exist }
12
+ it { should be_online }
13
+ it { should be_listening_worker }
14
+ it { should have_display_name('Blue Team worker') }
15
+ end
16
+ ```
17
+
18
+
19
+ #### Type
20
+
21
+ ```ruby
22
+ octopus_deploy_worker([url, api_key], instance_name)
23
+ octopus_worker([url, api_key], instance_name)
24
+ octopus_deploy_worker([url, api_key], instance_name).in_space(space_name)
25
+
26
+ ```
27
+
28
+ #### Matchers
29
+
30
+ | Matcher | Description |
31
+ |:--------|:------------|
32
+ | should exist | Tests if tentacle.exe is present locally |
33
+ | should be_registered_with_the_server | Checks if this worker instance is present in the target server |
34
+ | should be_online | Tests if the worker has a status of 'online'. If the machine is in a healthcheck, waits until healthcheck completes |
35
+ | should be_in_space(space_name) | Tests if a worker appears in a given space. _deprecated_. |
36
+ | should have_policy(policy_name) | Tests if a worker has a give policy applied |
37
+ | should have_display_name | Tests if a worker has a given display name |
38
+ | should be_polling_worker | Tests if a worker is in the 'polling' or 'Active' mode |
39
39
  | should be_listening_worker | Tests if a worker is in the 'listening' or 'Passive' mode |
@@ -1,26 +1,26 @@
1
- # octopus_deploy_worker_pool
2
-
3
- Describes an Octopus Deploy [Worker Pool](https://octopus.com/docs/infrastructure/workers/worker-pools) resource.
4
-
5
- ## Example
6
-
7
- ```ruby
8
- describe octopus_deploy_worker_pool('My Worker Pool').in_space("My Space") do
9
- it { should exist }
10
- end
11
- ```
12
-
13
- This type can be instantiated in several ways, depending on [how you authenticate](authentication.md).
14
-
15
- #### Type
16
-
17
- ```ruby
18
- octopus_deploy_worker_pool('My Worker Pool').in_space("My Space")
19
- octopus_worker_pool('Pool in Default Space')
20
- ```
21
-
22
- #### Matchers
23
-
24
- | Matcher | Description |
25
- |:--------|:------------|
1
+ # octopus_deploy_worker_pool
2
+
3
+ Describes an Octopus Deploy [Worker Pool](https://octopus.com/docs/infrastructure/workers/worker-pools) resource.
4
+
5
+ ## Example
6
+
7
+ ```ruby
8
+ describe octopus_deploy_worker_pool('My Worker Pool').in_space("My Space") do
9
+ it { should exist }
10
+ end
11
+ ```
12
+
13
+ This type can be instantiated in several ways, depending on [how you authenticate](authentication.md).
14
+
15
+ #### Type
16
+
17
+ ```ruby
18
+ octopus_deploy_worker_pool('My Worker Pool').in_space("My Space")
19
+ octopus_worker_pool('Pool in Default Space')
20
+ ```
21
+
22
+ #### Matchers
23
+
24
+ | Matcher | Description |
25
+ |:--------|:------------|
26
26
  | should exist | Tests for existence of a pool with this name |
@@ -1,86 +1,86 @@
1
- require 'octopus_serverspec_extensions/type/chocolatey_package.rb'
2
- require 'octopus_serverspec_extensions/type/npm_package.rb'
3
- require 'octopus_serverspec_extensions/type/java_property_file.rb'
4
- require 'octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb'
5
- require 'octopus_serverspec_extensions/type/octopus_deploy_worker.rb'
6
- require 'octopus_serverspec_extensions/type/octopus_deploy_environment.rb'
7
- require 'octopus_serverspec_extensions/type/octopus_deploy_project_group.rb'
8
- require 'octopus_serverspec_extensions/type/octopus_deploy_worker_pool.rb'
9
- require 'octopus_serverspec_extensions/type/octopus_deploy_account.rb'
10
- require 'octopus_serverspec_extensions/type/octopus_deploy_smtp_config.rb'
11
- require 'octopus_serverspec_extensions/type/octopus_deploy_team.rb'
12
- require 'octopus_serverspec_extensions/type/octopus_deploy_upgrade_config.rb'
13
- require 'octopus_serverspec_extensions/type/octopus_deploy_user.rb'
14
- require 'octopus_serverspec_extensions/type/octopus_deploy_space.rb'
15
- require 'octopus_serverspec_extensions/type/windows_dsc.rb'
16
- require 'octopus_serverspec_extensions/type/windows_firewall.rb'
17
- require 'octopus_serverspec_extensions/type/windows_scheduled_task.rb'
18
- require 'octopus_serverspec_extensions/matcher/have_version.rb'
19
- require 'octopus_serverspec_extensions/matcher/run_under_account.rb'
20
- require 'octopus_serverspec_extensions/matcher/have_windows_line_endings.rb'
21
- require 'octopus_serverspec_extensions/matcher/have_linux_line_endings.rb'
22
- require 'octopus_serverspec_extensions/version.rb'
23
-
24
- private
25
-
26
- def get_env_var(name)
27
- raise 'unexpected env var' if name != 'OCTOPUS_CLI_API_KEY' && name != 'OCTOPUS_CLI_SERVER'
28
- raise "env var #{name} not found" if ENV[name].nil?
29
- ENV[name]
30
- end
31
-
32
- def get_octopus_url(server_url)
33
- # returns the url or nil
34
- if server_url.nil?
35
- server_url = get_env_var('OCTOPUS_CLI_SERVER')
36
- end
37
-
38
- server_url
39
- end
40
-
41
- def get_octopus_api_key(api_key)
42
- # returns the api key or nil
43
- if api_key.nil?
44
- api_key = get_env_var('OCTOPUS_CLI_API_KEY')
45
- end
46
-
47
- api_key
48
- end
49
-
50
- def get_octopus_creds(args)
51
- server = args[0]
52
- api_key = args[1]
53
-
54
- if args.length != 0 && args.length != 2
55
- raise "Supplied credentials invalid. Expected: [url, api_key] Received: #{args}"
56
- end
57
-
58
- if server.nil?
59
- server = get_env_var('OCTOPUS_CLI_SERVER')
60
- end
61
-
62
- if api_key.nil?
63
- api_key = get_env_var('OCTOPUS_CLI_API_KEY')
64
- end
65
-
66
- # are they still nil? raise an error
67
- if api_key.nil? or server.nil?
68
- raise "Supplied credentials invalid. One or more of [server, api_key] was null. " +
69
- "If you intended to use Environment Variables, please check the value of OCTOPUS_CLI_SERVER and OCTOPUS_CLI_API_KEY"
70
- end
71
-
72
- server = server.chomp("/") # remove the trailing slash if it exists
73
-
74
- [server, api_key]
75
- end
76
-
77
- def check_supports_spaces(server_url)
78
- begin
79
- resp = Net::HTTP.get_response(URI.parse("#{server_url}/api/"))
80
- body = JSON.parse(resp.body)
81
- version = body['Version']
82
- return Gem::Version.new(version) > Gem::Version.new('2019.0.0')
83
- rescue => e
84
- raise "check_supports_spaces: Unable to connect to #{server_url}: #{e}"
85
- end
1
+ require 'octopus_serverspec_extensions/type/chocolatey_package.rb'
2
+ require 'octopus_serverspec_extensions/type/npm_package.rb'
3
+ require 'octopus_serverspec_extensions/type/java_property_file.rb'
4
+ require 'octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb'
5
+ require 'octopus_serverspec_extensions/type/octopus_deploy_worker.rb'
6
+ require 'octopus_serverspec_extensions/type/octopus_deploy_environment.rb'
7
+ require 'octopus_serverspec_extensions/type/octopus_deploy_project_group.rb'
8
+ require 'octopus_serverspec_extensions/type/octopus_deploy_worker_pool.rb'
9
+ require 'octopus_serverspec_extensions/type/octopus_deploy_account.rb'
10
+ require 'octopus_serverspec_extensions/type/octopus_deploy_smtp_config.rb'
11
+ require 'octopus_serverspec_extensions/type/octopus_deploy_team.rb'
12
+ require 'octopus_serverspec_extensions/type/octopus_deploy_upgrade_config.rb'
13
+ require 'octopus_serverspec_extensions/type/octopus_deploy_user.rb'
14
+ require 'octopus_serverspec_extensions/type/octopus_deploy_space.rb'
15
+ require 'octopus_serverspec_extensions/type/windows_dsc.rb'
16
+ require 'octopus_serverspec_extensions/type/windows_firewall.rb'
17
+ require 'octopus_serverspec_extensions/type/windows_scheduled_task.rb'
18
+ require 'octopus_serverspec_extensions/matcher/have_version.rb'
19
+ require 'octopus_serverspec_extensions/matcher/run_under_account.rb'
20
+ require 'octopus_serverspec_extensions/matcher/have_windows_line_endings.rb'
21
+ require 'octopus_serverspec_extensions/matcher/have_linux_line_endings.rb'
22
+ require 'octopus_serverspec_extensions/version.rb'
23
+
24
+ private
25
+
26
+ def get_env_var(name)
27
+ raise 'unexpected env var' if name != 'OCTOPUS_CLI_API_KEY' && name != 'OCTOPUS_CLI_SERVER'
28
+ raise "env var #{name} not found" if ENV[name].nil?
29
+ ENV[name]
30
+ end
31
+
32
+ def get_octopus_url(server_url)
33
+ # returns the url or nil
34
+ if server_url.nil?
35
+ server_url = get_env_var('OCTOPUS_CLI_SERVER')
36
+ end
37
+
38
+ server_url
39
+ end
40
+
41
+ def get_octopus_api_key(api_key)
42
+ # returns the api key or nil
43
+ if api_key.nil?
44
+ api_key = get_env_var('OCTOPUS_CLI_API_KEY')
45
+ end
46
+
47
+ api_key
48
+ end
49
+
50
+ def get_octopus_creds(args)
51
+ server = args[0]
52
+ api_key = args[1]
53
+
54
+ if args.length != 0 && args.length != 2
55
+ raise "Supplied credentials invalid. Expected: [url, api_key] Received: #{args}"
56
+ end
57
+
58
+ if server.nil?
59
+ server = get_env_var('OCTOPUS_CLI_SERVER')
60
+ end
61
+
62
+ if api_key.nil?
63
+ api_key = get_env_var('OCTOPUS_CLI_API_KEY')
64
+ end
65
+
66
+ # are they still nil? raise an error
67
+ if api_key.nil? or server.nil?
68
+ raise "Supplied credentials invalid. One or more of [server, api_key] was null. " +
69
+ "If you intended to use Environment Variables, please check the value of OCTOPUS_CLI_SERVER and OCTOPUS_CLI_API_KEY"
70
+ end
71
+
72
+ server = server.chomp("/") # remove the trailing slash if it exists
73
+
74
+ [server, api_key]
75
+ end
76
+
77
+ def check_supports_spaces(server_url)
78
+ begin
79
+ resp = Net::HTTP.get_response(URI.parse("#{server_url}/api/"))
80
+ body = JSON.parse(resp.body)
81
+ version = body['Version']
82
+ return Gem::Version.new(version) > Gem::Version.new('2019.0.0')
83
+ rescue => e
84
+ raise "check_supports_spaces: Unable to connect to #{server_url}: #{e}"
85
+ end
86
86
  end
@@ -1,13 +1,13 @@
1
- RSpec::Matchers.define :allow_dynamic_infrastructure do
2
- match do |env|
3
- env.allow_dynamic_infrastructure? == true
4
- end
5
-
6
- failure_message do |env|
7
- "Expected Environment '#{env.environment_name}' to allow dynamic infrastructure, but it didn't"
8
- end
9
-
10
- failure_message_when_negated do |env|
11
- "Expected Environment '#{env.environment_name}' not to allow dynamic infrastructure, but it did"
12
- end
1
+ RSpec::Matchers.define :allow_dynamic_infrastructure do
2
+ match do |env|
3
+ env.allow_dynamic_infrastructure? == true
4
+ end
5
+
6
+ failure_message do |env|
7
+ "Expected Environment '#{env.environment_name}' to allow dynamic infrastructure, but it didn't"
8
+ end
9
+
10
+ failure_message_when_negated do |env|
11
+ "Expected Environment '#{env.environment_name}' not to allow dynamic infrastructure, but it did"
12
+ end
13
13
  end
@@ -1,13 +1,13 @@
1
- RSpec::Matchers.define :have_linux_line_endings do
2
- match do |file|
3
- !file.content.include?("\r\n")
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have linux line endings, but it didn't"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have linux line endings, but it did"
12
- end
13
- end
1
+ RSpec::Matchers.define :have_linux_line_endings do
2
+ match do |file|
3
+ !file.content.include?("\r\n")
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have linux line endings, but it didn't"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have linux line endings, but it did"
12
+ end
13
+ end
@@ -1,36 +1,36 @@
1
- RSpec::Matchers.define :have_version do |version|
2
- match do |file|
3
- get_version(file) == version
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have version '#{version}' but it had version '#{get_version}' instead"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have version '#{version}' but it did"
12
- end
13
-
14
- private
15
- def get_version(file)
16
- version_dll = Fiddle.dlopen('version.dll')
17
-
18
- s=''
19
- vsize = Fiddle::Function.new(version_dll['GetFileVersionInfoSize'],
20
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
21
- Fiddle::TYPE_LONG).call(file.name, s)
22
-
23
- raise 'Unable to determine the version number' unless vsize > 0
24
-
25
- result = ' '*vsize
26
- Fiddle::Function.new(version_dll['GetFileVersionInfo'],
27
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG,
28
- Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP],
29
- Fiddle::TYPE_VOIDP).call(file.name, 0, vsize, result)
30
-
31
- rstring = result.unpack('v*').map{|s| s.chr if s<256}*''
32
- r = /FileVersion..(.*?)\000/.match(rstring)
33
-
34
- r[1]
35
- end
36
- end
1
+ RSpec::Matchers.define :have_version do |version|
2
+ match do |file|
3
+ get_version(file) == version
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have version '#{version}' but it had version '#{get_version}' instead"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have version '#{version}' but it did"
12
+ end
13
+
14
+ private
15
+ def get_version(file)
16
+ version_dll = Fiddle.dlopen('version.dll')
17
+
18
+ s=''
19
+ vsize = Fiddle::Function.new(version_dll['GetFileVersionInfoSize'],
20
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
21
+ Fiddle::TYPE_LONG).call(file.name, s)
22
+
23
+ raise 'Unable to determine the version number' unless vsize > 0
24
+
25
+ result = ' '*vsize
26
+ Fiddle::Function.new(version_dll['GetFileVersionInfo'],
27
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG,
28
+ Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP],
29
+ Fiddle::TYPE_VOIDP).call(file.name, 0, vsize, result)
30
+
31
+ rstring = result.unpack('v*').map{|s| s.chr if s<256}*''
32
+ r = /FileVersion..(.*?)\000/.match(rstring)
33
+
34
+ r[1]
35
+ end
36
+ end
@@ -1,13 +1,13 @@
1
- RSpec::Matchers.define :have_windows_line_endings do
2
- match do |file|
3
- file.content.include?("\r\n")
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have windows line endings, but it didn't"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have windows line endings, but it did"
12
- end
13
- end
1
+ RSpec::Matchers.define :have_windows_line_endings do
2
+ match do |file|
3
+ file.content.include?("\r\n")
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have windows line endings, but it didn't"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have windows line endings, but it did"
12
+ end
13
+ end