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,109 +1,109 @@
1
- require 'serverspec/type/base'
2
- require 'net/http'
3
- require 'json'
4
-
5
- module Serverspec::Type
6
- class OctopusDeploySmtpConfig < Base
7
- @serverUrl = nil
8
- @apiKey = nil
9
- @smtpConfig = nil
10
-
11
- def initialize(*url_and_api_key)
12
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
13
-
14
- @name = "Octopus Deploy SMTP Config #{serverUrl}"
15
- @runner = Specinfra::Runner
16
- @serverUrl = serverUrl
17
- @apiKey = apiKey
18
-
19
- if serverUrl.nil?
20
- serverUrl = get_env_var('OCTOPUS_CLI_SERVER').chomp('/') # removes trailing slash if present
21
- end
22
-
23
- if apiKey.nil?
24
- apiKey = get_env_var('OCTOPUS_CLI_API_KEY')
25
- end
26
-
27
- # is it still nil?
28
- if serverUrl.nil?
29
- raise "'serverUrl' was not provided. Unable to connect to Octopus server to validate configuration."
30
- end
31
- if apiKey.nil?
32
- raise "'apiKey' was not provided. Unable to connect to Octopus server to validate configuration."
33
- end
34
-
35
- @smtpConfig = get_smtp_config_via_api(serverUrl, apiKey)
36
- end
37
-
38
- def configured?
39
- url = "#{@serverUrl}/api/smtpconfiguration/isconfigured?api-key=#{@apiKey}"
40
- begin
41
- resp = Net::HTTP.get_response(URI.parse(url))
42
- body = JSON.parse(resp.body)
43
- smtp = body unless body.nil?
44
- rescue => e
45
- raise "get_smtp_config_via_api: Unable to connect to #{url}: #{e}"
46
- end
47
-
48
- smtp["IsConfigured"]
49
- end
50
-
51
- def using_ssl?
52
- false if @smtpConfig.nil?
53
- @smtpConfig["EnableSsl"]
54
- end
55
-
56
- def on_port?(port_number)
57
- false if @smtpConfig.nil?
58
- @smtpConfig["SmtpPort"] == port_number
59
- end
60
-
61
- def on_host?(hostname)
62
- false if @smtpConfig.nil?
63
- @smtpConfig["SmtpHost"] == hostname
64
- end
65
-
66
- def using_credentials?(username)
67
- # we can't test the password, but we can check the username
68
- false if @smtpConfig.nil?
69
- @smtpConfig["SmtpLogin"] == username && @smtpConfig["SmtpPassword"]["HasValue"]
70
- end
71
-
72
- def has_from_address?(from_address)
73
- false if @smtpConfig.nil?
74
- @smtpConfig["SendEmailFrom"] == from_address
75
- end
76
- end
77
-
78
- # module-level constructors/entrypoints
79
-
80
- def octopus_deploy_smtp_config(*url_and_api_key)
81
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
82
- OctopusDeploySmtpConfig.new(serverUrl, apiKey)
83
- end
84
-
85
- def octopus_smtp_config(*url_and_api_key)
86
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
87
- octopus_deploy_smtp_config(serverUrl, apiKey)
88
- end
89
-
90
- private
91
-
92
- def get_smtp_config_via_api(serverUrl, apiKey)
93
- smtp = nil
94
-
95
- url = "#{serverUrl}/api/smtpconfiguration?api-key=#{apiKey}"
96
-
97
- begin
98
- resp = Net::HTTP.get_response(URI.parse(url))
99
- body = JSON.parse(resp.body)
100
- smtp = body unless body.nil?
101
- rescue => e
102
- raise "get_smtp_config_via_api: Unable to connect to #{url}: #{e}"
103
- end
104
-
105
- smtp
106
- end
107
- end
108
-
109
- include Serverspec::Type
1
+ require 'serverspec/type/base'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module Serverspec::Type
6
+ class OctopusDeploySmtpConfig < Base
7
+ @serverUrl = nil
8
+ @apiKey = nil
9
+ @smtpConfig = nil
10
+
11
+ def initialize(*url_and_api_key)
12
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
13
+
14
+ @name = "Octopus Deploy SMTP Config #{serverUrl}"
15
+ @runner = Specinfra::Runner
16
+ @serverUrl = serverUrl
17
+ @apiKey = apiKey
18
+
19
+ if serverUrl.nil?
20
+ serverUrl = get_env_var('OCTOPUS_CLI_SERVER').chomp('/') # removes trailing slash if present
21
+ end
22
+
23
+ if apiKey.nil?
24
+ apiKey = get_env_var('OCTOPUS_CLI_API_KEY')
25
+ end
26
+
27
+ # is it still nil?
28
+ if serverUrl.nil?
29
+ raise "'serverUrl' was not provided. Unable to connect to Octopus server to validate configuration."
30
+ end
31
+ if apiKey.nil?
32
+ raise "'apiKey' was not provided. Unable to connect to Octopus server to validate configuration."
33
+ end
34
+
35
+ @smtpConfig = get_smtp_config_via_api(serverUrl, apiKey)
36
+ end
37
+
38
+ def configured?
39
+ url = "#{@serverUrl}/api/smtpconfiguration/isconfigured?api-key=#{@apiKey}"
40
+ begin
41
+ resp = Net::HTTP.get_response(URI.parse(url))
42
+ body = JSON.parse(resp.body)
43
+ smtp = body unless body.nil?
44
+ rescue => e
45
+ raise "get_smtp_config_via_api: Unable to connect to #{url}: #{e}"
46
+ end
47
+
48
+ smtp["IsConfigured"]
49
+ end
50
+
51
+ def using_ssl?
52
+ false if @smtpConfig.nil?
53
+ @smtpConfig["EnableSsl"]
54
+ end
55
+
56
+ def on_port?(port_number)
57
+ false if @smtpConfig.nil?
58
+ @smtpConfig["SmtpPort"] == port_number
59
+ end
60
+
61
+ def on_host?(hostname)
62
+ false if @smtpConfig.nil?
63
+ @smtpConfig["SmtpHost"] == hostname
64
+ end
65
+
66
+ def using_credentials?(username)
67
+ # we can't test the password, but we can check the username
68
+ false if @smtpConfig.nil?
69
+ @smtpConfig["SmtpLogin"] == username && @smtpConfig["SmtpPassword"]["HasValue"]
70
+ end
71
+
72
+ def has_from_address?(from_address)
73
+ false if @smtpConfig.nil?
74
+ @smtpConfig["SendEmailFrom"] == from_address
75
+ end
76
+ end
77
+
78
+ # module-level constructors/entrypoints
79
+
80
+ def octopus_deploy_smtp_config(*url_and_api_key)
81
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
82
+ OctopusDeploySmtpConfig.new(serverUrl, apiKey)
83
+ end
84
+
85
+ def octopus_smtp_config(*url_and_api_key)
86
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
87
+ octopus_deploy_smtp_config(serverUrl, apiKey)
88
+ end
89
+
90
+ private
91
+
92
+ def get_smtp_config_via_api(serverUrl, apiKey)
93
+ smtp = nil
94
+
95
+ url = "#{serverUrl}/api/smtpconfiguration?api-key=#{apiKey}"
96
+
97
+ begin
98
+ resp = Net::HTTP.get_response(URI.parse(url))
99
+ body = JSON.parse(resp.body)
100
+ smtp = body unless body.nil?
101
+ rescue => e
102
+ raise "get_smtp_config_via_api: Unable to connect to #{url}: #{e}"
103
+ end
104
+
105
+ smtp
106
+ end
107
+ end
108
+
109
+ include Serverspec::Type
@@ -1,92 +1,92 @@
1
- require 'serverspec/type/base'
2
- require 'net/http'
3
- require 'json'
4
-
5
- module Serverspec::Type
6
- class OctopusDeploySpace < Base
7
- @serverUrl = nil
8
- @apiKey = nil
9
- @spaceName = nil
10
- @space = nil
11
-
12
- def initialize(*url_and_api_key, space_name)
13
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
14
-
15
- @name = "Octopus Deploy Space #{space_name}"
16
- @runner = Specinfra::Runner
17
- @serverUrl = serverUrl
18
- @apiKey = apiKey
19
-
20
- if space_name.nil?
21
- raise "'space_name' was not included. Cannot contact server to validate space."
22
- end
23
-
24
- @spaceName = space_name
25
- end
26
-
27
- def exists?
28
- load_resource_if_nil
29
- @space.nil? == false
30
- end
31
-
32
- def default?
33
- load_resource_if_nil
34
- false if @space.nil?
35
- @space['IsDefault'] == true
36
- end
37
-
38
- def has_running_task_queue?
39
- load_resource_if_nil
40
- false if @space.nil?
41
- @space['TaskQueueStopped'] == false
42
- end
43
-
44
- def has_description?(description)
45
- load_resource_if_nil
46
- false if @space.nil?
47
- @space['Description'] == description
48
- end
49
-
50
- def load_resource_if_nil
51
- if @space.nil?
52
- @space = get_space_via_api
53
- end
54
- end
55
- end
56
-
57
- # module-level constructors/entrypoints
58
-
59
- def octopus_deploy_space(*url_and_api_key, space_name)
60
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
61
- OctopusDeploySpace.new(serverUrl, apiKey, space_name)
62
- end
63
-
64
- def octopus_space(*url_and_api_key, space_name)
65
- serverUrl, apiKey = get_octopus_creds(url_and_api_key)
66
- OctopusDeploySpace.new(serverUrl, apiKey, space_name)
67
- end
68
-
69
- private
70
-
71
- def get_space_via_api
72
- space = nil
73
-
74
- @serverSupportsSpaces = check_supports_spaces(@serverUrl)
75
-
76
- unless @serverSupportsSpaces
77
- raise "Server does not support Spaces"
78
- end
79
-
80
- url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
81
-
82
- begin
83
- resp = Net::HTTP.get_response(URI.parse(url))
84
- body = JSON.parse(resp.body)
85
- space = body.select {|i| i['Name'] == @spaceName }.first unless body.nil?
86
- rescue => e
87
- raise "get_account_via_api: Unable to connect to #{url}: #{e}"
88
- end
89
-
90
- space
91
- end
92
- end
1
+ require 'serverspec/type/base'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module Serverspec::Type
6
+ class OctopusDeploySpace < Base
7
+ @serverUrl = nil
8
+ @apiKey = nil
9
+ @spaceName = nil
10
+ @space = nil
11
+
12
+ def initialize(*url_and_api_key, space_name)
13
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
14
+
15
+ @name = "Octopus Deploy Space #{space_name}"
16
+ @runner = Specinfra::Runner
17
+ @serverUrl = serverUrl
18
+ @apiKey = apiKey
19
+
20
+ if space_name.nil?
21
+ raise "'space_name' was not included. Cannot contact server to validate space."
22
+ end
23
+
24
+ @spaceName = space_name
25
+ end
26
+
27
+ def exists?
28
+ load_resource_if_nil
29
+ @space.nil? == false
30
+ end
31
+
32
+ def default?
33
+ load_resource_if_nil
34
+ false if @space.nil?
35
+ @space['IsDefault'] == true
36
+ end
37
+
38
+ def has_running_task_queue?
39
+ load_resource_if_nil
40
+ false if @space.nil?
41
+ @space['TaskQueueStopped'] == false
42
+ end
43
+
44
+ def has_description?(description)
45
+ load_resource_if_nil
46
+ false if @space.nil?
47
+ @space['Description'] == description
48
+ end
49
+
50
+ def load_resource_if_nil
51
+ if @space.nil?
52
+ @space = get_space_via_api
53
+ end
54
+ end
55
+ end
56
+
57
+ # module-level constructors/entrypoints
58
+
59
+ def octopus_deploy_space(*url_and_api_key, space_name)
60
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
61
+ OctopusDeploySpace.new(serverUrl, apiKey, space_name)
62
+ end
63
+
64
+ def octopus_space(*url_and_api_key, space_name)
65
+ serverUrl, apiKey = get_octopus_creds(url_and_api_key)
66
+ OctopusDeploySpace.new(serverUrl, apiKey, space_name)
67
+ end
68
+
69
+ private
70
+
71
+ def get_space_via_api
72
+ space = nil
73
+
74
+ @serverSupportsSpaces = check_supports_spaces(@serverUrl)
75
+
76
+ unless @serverSupportsSpaces
77
+ raise "Server does not support Spaces"
78
+ end
79
+
80
+ url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
81
+
82
+ begin
83
+ resp = Net::HTTP.get_response(URI.parse(url))
84
+ body = JSON.parse(resp.body)
85
+ space = body.select {|i| i['Name'] == @spaceName }.first unless body.nil?
86
+ rescue => e
87
+ raise "get_account_via_api: Unable to connect to #{url}: #{e}"
88
+ end
89
+
90
+ space
91
+ end
92
+ end
@@ -1,82 +1,82 @@
1
- require 'serverspec/type/base'
2
- require 'net/http'
3
- require 'json'
4
-
5
- module Serverspec::Type
6
- class OctopusDeployTeam < Base
7
- @team_name = nil
8
- @serverUrl = nil
9
- @apiKey = nil
10
- @serverSupportsSpaces = false
11
- @team = nil
12
- @spaceId = nil
13
-
14
- def initialize(*url_and_api_key, team_name)
15
- serverUrl,apiKey = get_octopus_creds(url_and_api_key)
16
-
17
- @team_name = team_name
18
-
19
- @name = "Octopus Deploy User Account #{serverUrl}"
20
- @runner = Specinfra::Runner
21
- @serverUrl = serverUrl
22
- @apiKey = apiKey
23
-
24
- if team_name.nil?
25
- raise "'team_name' was not provided"
26
- end
27
- end
28
-
29
- def exists?
30
- load_resource_if_nil
31
- @team != nil?
32
- end
33
-
34
- def in_space(space_name)
35
- # allows us to tag .in_space() onto the end of the resource. as in
36
- # describe octopus_account("account name").in_space("MyNewSpace") do
37
- @spaceId = get_space_id?(space_name)
38
- if @team_name.nil?
39
- raise "'team_name' was not provided. Unable to connect to Octopus server to validate configuration."
40
- end
41
- self
42
- end
43
-
44
- def load_resource_if_nil
45
- if @team.nil?
46
- @team = get_team_via_api(@serverUrl, @apiKey, @team_name)
47
- end
48
- end
49
- end
50
-
51
- def octopus_deploy_team(*url_and_api_key, team_name)
52
- serverUrl,apiKey = get_octopus_creds(url_and_api_key)
53
- OctopusDeployTeam.new(serverUrl, apiKey, team_name)
54
- end
55
-
56
- def octopus_team(*url_and_api_key, team_name)
57
- serverUrl,apiKey = get_octopus_creds(url_and_api_key)
58
- OctopusDeployTeam.new(serverUrl, apiKey, team_name)
59
- end
60
-
61
- private
62
-
63
- def get_team_via_api(serverUrl, apiKey, team_name)
64
- team = nil
65
-
66
- url = "#{serverUrl}/api#{@spaceFragment}/teams/all?api-key=#{apiKey}"
67
-
68
- begin
69
- resp = Net::HTTP.get_response(URI.parse(url))
70
- body = JSON.parse(resp.body)
71
- teams = body unless body.nil?
72
- team = teams.select {|i| i['Name'] == team_name }.first unless teams.nil?
73
- rescue => e
74
- raise "get_team_via_api: Unable to connect to #{url}: #{e}"
75
- end
76
-
77
- team
78
- end
79
-
80
- end
81
-
1
+ require 'serverspec/type/base'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module Serverspec::Type
6
+ class OctopusDeployTeam < Base
7
+ @team_name = nil
8
+ @serverUrl = nil
9
+ @apiKey = nil
10
+ @serverSupportsSpaces = false
11
+ @team = nil
12
+ @spaceId = nil
13
+
14
+ def initialize(*url_and_api_key, team_name)
15
+ serverUrl,apiKey = get_octopus_creds(url_and_api_key)
16
+
17
+ @team_name = team_name
18
+
19
+ @name = "Octopus Deploy User Account #{serverUrl}"
20
+ @runner = Specinfra::Runner
21
+ @serverUrl = serverUrl
22
+ @apiKey = apiKey
23
+
24
+ if team_name.nil?
25
+ raise "'team_name' was not provided"
26
+ end
27
+ end
28
+
29
+ def exists?
30
+ load_resource_if_nil
31
+ @team != nil?
32
+ end
33
+
34
+ def in_space(space_name)
35
+ # allows us to tag .in_space() onto the end of the resource. as in
36
+ # describe octopus_account("account name").in_space("MyNewSpace") do
37
+ @spaceId = get_space_id?(space_name)
38
+ if @team_name.nil?
39
+ raise "'team_name' was not provided. Unable to connect to Octopus server to validate configuration."
40
+ end
41
+ self
42
+ end
43
+
44
+ def load_resource_if_nil
45
+ if @team.nil?
46
+ @team = get_team_via_api(@serverUrl, @apiKey, @team_name)
47
+ end
48
+ end
49
+ end
50
+
51
+ def octopus_deploy_team(*url_and_api_key, team_name)
52
+ serverUrl,apiKey = get_octopus_creds(url_and_api_key)
53
+ OctopusDeployTeam.new(serverUrl, apiKey, team_name)
54
+ end
55
+
56
+ def octopus_team(*url_and_api_key, team_name)
57
+ serverUrl,apiKey = get_octopus_creds(url_and_api_key)
58
+ OctopusDeployTeam.new(serverUrl, apiKey, team_name)
59
+ end
60
+
61
+ private
62
+
63
+ def get_team_via_api(serverUrl, apiKey, team_name)
64
+ team = nil
65
+
66
+ url = "#{serverUrl}/api#{@spaceFragment}/teams/all?api-key=#{apiKey}"
67
+
68
+ begin
69
+ resp = Net::HTTP.get_response(URI.parse(url))
70
+ body = JSON.parse(resp.body)
71
+ teams = body unless body.nil?
72
+ team = teams.select {|i| i['Name'] == team_name }.first unless teams.nil?
73
+ rescue => e
74
+ raise "get_team_via_api: Unable to connect to #{url}: #{e}"
75
+ end
76
+
77
+ team
78
+ end
79
+
80
+ end
81
+
82
82
  include Serverspec::Type