admin_module 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/README.md +281 -0
  8. data/Rakefile +98 -0
  9. data/admin_module.gemspec +34 -0
  10. data/bin/admin_module +13 -0
  11. data/lib/admin_module.rb +260 -0
  12. data/lib/admin_module/cli.rb +54 -0
  13. data/lib/admin_module/cli/cli_guideline.rb +80 -0
  14. data/lib/admin_module/cli/cli_lock.rb +149 -0
  15. data/lib/admin_module/cli/cli_parameter.rb +66 -0
  16. data/lib/admin_module/cli/cli_task.rb +149 -0
  17. data/lib/admin_module/cli_old.rb +92 -0
  18. data/lib/admin_module/client.rb +146 -0
  19. data/lib/admin_module/command.rb +25 -0
  20. data/lib/admin_module/command/client_access.rb +43 -0
  21. data/lib/admin_module/command/config.rb +310 -0
  22. data/lib/admin_module/command/dc.rb +110 -0
  23. data/lib/admin_module/command/gdl.rb +71 -0
  24. data/lib/admin_module/command/lock.rb +110 -0
  25. data/lib/admin_module/command/ppm.rb +142 -0
  26. data/lib/admin_module/command/rule.rb +77 -0
  27. data/lib/admin_module/command/ruleset.rb +56 -0
  28. data/lib/admin_module/command/snapshot.rb +110 -0
  29. data/lib/admin_module/command/stage.rb +131 -0
  30. data/lib/admin_module/command/task.rb +110 -0
  31. data/lib/admin_module/config_helper.rb +33 -0
  32. data/lib/admin_module/dc.rb +133 -0
  33. data/lib/admin_module/guideline.rb +86 -0
  34. data/lib/admin_module/locks.rb +142 -0
  35. data/lib/admin_module/page_factory.rb +55 -0
  36. data/lib/admin_module/pages.rb +120 -0
  37. data/lib/admin_module/pages/dc_definitions_page.rb +73 -0
  38. data/lib/admin_module/pages/dc_detail_page.rb +187 -0
  39. data/lib/admin_module/pages/guideline_page.rb +35 -0
  40. data/lib/admin_module/pages/guideline_version_page.rb +140 -0
  41. data/lib/admin_module/pages/guidelines_page.rb +59 -0
  42. data/lib/admin_module/pages/guidelines_version_all_page.rb +116 -0
  43. data/lib/admin_module/pages/lock_definition_page.rb +178 -0
  44. data/lib/admin_module/pages/lock_definitions_page.rb +69 -0
  45. data/lib/admin_module/pages/login_page.rb +75 -0
  46. data/lib/admin_module/pages/parameter_page.rb +62 -0
  47. data/lib/admin_module/pages/parameters_page.rb +46 -0
  48. data/lib/admin_module/pages/ppms_page.rb +110 -0
  49. data/lib/admin_module/pages/rule_page.rb +68 -0
  50. data/lib/admin_module/pages/rules_page.rb +74 -0
  51. data/lib/admin_module/pages/ruleset_page.rb +64 -0
  52. data/lib/admin_module/pages/rulesets_page.rb +60 -0
  53. data/lib/admin_module/pages/select_list_syncable.rb +64 -0
  54. data/lib/admin_module/pages/snapshot_definitions_page.rb +73 -0
  55. data/lib/admin_module/pages/snapshot_detail_page.rb +246 -0
  56. data/lib/admin_module/pages/workflow_detail_page.rb +451 -0
  57. data/lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb +172 -0
  58. data/lib/admin_module/pages/workflow_detail_task_mappings_page.rb +163 -0
  59. data/lib/admin_module/pages/workflow_detail_task_screens_page.rb +75 -0
  60. data/lib/admin_module/pages/workflow_details_page.rb +67 -0
  61. data/lib/admin_module/pages/workflow_task_page.rb +107 -0
  62. data/lib/admin_module/pages/workflow_tasks_page.rb +111 -0
  63. data/lib/admin_module/ppms.rb +78 -0
  64. data/lib/admin_module/rake.rb +22 -0
  65. data/lib/admin_module/rake/dc_tasks.rb +185 -0
  66. data/lib/admin_module/rake/deploy_task.rb +59 -0
  67. data/lib/admin_module/rake/gdl_tasks.rb +189 -0
  68. data/lib/admin_module/rake/lock_tasks.rb +189 -0
  69. data/lib/admin_module/rake/parameter_task.rb +86 -0
  70. data/lib/admin_module/rake/ppm_tasks.rb +248 -0
  71. data/lib/admin_module/rake/rule_tasks.rb +157 -0
  72. data/lib/admin_module/rake/snapshot_tasks.rb +223 -0
  73. data/lib/admin_module/rake/stage_tasks.rb +197 -0
  74. data/lib/admin_module/rake/stages_task.rb +197 -0
  75. data/lib/admin_module/rake/task_tasks.rb +189 -0
  76. data/lib/admin_module/rules.rb +50 -0
  77. data/lib/admin_module/rulesets.rb +42 -0
  78. data/lib/admin_module/snapshots.rb +133 -0
  79. data/lib/admin_module/stages.rb +171 -0
  80. data/lib/admin_module/tasks.rb +147 -0
  81. data/lib/admin_module/version.rb +3 -0
  82. data/old_spec/lib/admin_module/cli_configuration_spec.rb +126 -0
  83. data/old_spec/lib/admin_module/cli_create_stage_spec.rb +89 -0
  84. data/old_spec/lib/admin_module/cli_delete_rule_spec.rb +57 -0
  85. data/old_spec/lib/admin_module/cli_deploy_spec.rb +57 -0
  86. data/old_spec/lib/admin_module/cli_export_locks_spec.rb +62 -0
  87. data/old_spec/lib/admin_module/cli_export_stages_spec.rb +62 -0
  88. data/old_spec/lib/admin_module/cli_guidelines_version_all_spec.rb +58 -0
  89. data/old_spec/lib/admin_module/cli_import_locks_spec.rb +153 -0
  90. data/old_spec/lib/admin_module/cli_import_stages_spec.rb +173 -0
  91. data/old_spec/lib/admin_module/cli_modify_locks_spec.rb +128 -0
  92. data/old_spec/lib/admin_module/cli_modify_stages_spec.rb +88 -0
  93. data/old_spec/lib/admin_module/cli_rename_rule_spec.rb +53 -0
  94. data/old_spec/lib/admin_module/cli_rename_ruleset_spec.rb +53 -0
  95. data/old_spec/lib/admin_module/cli_var_spec.rb +41 -0
  96. data/old_spec/lib/admin_module/rake/deploy_task_spec.rb +85 -0
  97. data/old_spec/lib/admin_module/rake/parameter_task_spec.rb +58 -0
  98. data/old_spec/lib/admin_module/rake/rules_task_spec.rb +75 -0
  99. data/spec/data/build/test1.xml +0 -0
  100. data/spec/data/build/test2.xml +1 -0
  101. data/spec/data/import_dcs.yml +31 -0
  102. data/spec/data/import_locks.yml +4 -0
  103. data/spec/data/import_snapshots.yml +35 -0
  104. data/spec/data/import_stages.yml +4 -0
  105. data/spec/data/import_tasks.yml +25 -0
  106. data/spec/data/patch-test.xml +1 -0
  107. data/spec/data/remove_test_del_rule.xml +1 -0
  108. data/spec/data/stages.yml +518 -0
  109. data/spec/data/test_del_rule.xml +1 -0
  110. data/spec/lib/admin_module/admin_module_spec.rb +175 -0
  111. data/spec/lib/admin_module/cli_spec.rb +36 -0
  112. data/spec/lib/admin_module/client_spec.rb +158 -0
  113. data/spec/lib/admin_module/command/config_spec.rb +477 -0
  114. data/spec/lib/admin_module/command/dc_spec.rb +202 -0
  115. data/spec/lib/admin_module/command/gdl_spec.rb +139 -0
  116. data/spec/lib/admin_module/command/lock_spec.rb +207 -0
  117. data/spec/lib/admin_module/command/rule_spec.rb +163 -0
  118. data/spec/lib/admin_module/command/ruleset_spec.rb +124 -0
  119. data/spec/lib/admin_module/command/snapshot_spec.rb +202 -0
  120. data/spec/lib/admin_module/command/stage_spec.rb +259 -0
  121. data/spec/lib/admin_module/command/task_spec.rb +207 -0
  122. data/spec/lib/admin_module/dc_spec.rb +192 -0
  123. data/spec/lib/admin_module/guideline_spec.rb +177 -0
  124. data/spec/lib/admin_module/locks_spec.rb +188 -0
  125. data/spec/lib/admin_module/rules_spec.rb +110 -0
  126. data/spec/lib/admin_module/rulesets_spec.rb +85 -0
  127. data/spec/lib/admin_module/snapshot_spec.rb +192 -0
  128. data/spec/lib/admin_module/stages_spec.rb +179 -0
  129. data/spec/lib/admin_module/tasks_spec.rb +196 -0
  130. data/spec/spec_helper.rb +54 -0
  131. data/spec/support/asserts.rb +13 -0
  132. data/spec/support/data_clearing.rb +28 -0
  133. data/spec/support/dirs.rb +54 -0
  134. data/spec/support/helpers.rb +83 -0
  135. data/spec/support/lock.rb +23 -0
  136. data/spec/support/mocks.rb +213 -0
  137. data/spec/support/snapshot.rb +28 -0
  138. data/spec/support/stage.rb +22 -0
  139. data/spec/support/stage_factory.rb +138 -0
  140. data/spec/support/task.rb +23 -0
  141. metadata +381 -0
@@ -0,0 +1 @@
1
+ <GuidelineRoot><Guideline GuidelineID="1" Name="test_del_rule" Version="1" StartDate="Nov 15 2013 12:00AM"><Rule Id="31" Name="Z-TestDelRule"><IfMessages/><ElseMessages/><Condition><Expression><Brace><Compute><Operator>&lt;&gt;</Operator><LeftOperand><PPM Name="Account Name" DataType="Text" Type="APM"/></LeftOperand><RightOperand><PPM Name="Account Name" DataType="Text" Type="APM"/></RightOperand></Compute></Brace></Expression></Condition><IfActions><Assign><AssignTo><DPM Name="Decision"/></AssignTo><AssignValue><Expression><Constant>Fail</Constant></Expression></AssignValue></Assign></IfActions></Rule></Guideline><LOOKUPS></LOOKUPS><Conditions></Conditions><DERIVEDPARAMETERS><DPM Name="Decision" Type="DSM" Order="0" ProductType="6" DataType="Text"/></DERIVEDPARAMETERS></GuidelineRoot>
@@ -0,0 +1,175 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdminModule do
4
+
5
+ before do
6
+ # Reset config to a known state.
7
+ AdminModule.configuration.reset
8
+ end
9
+
10
+ let(:config) do
11
+ AdminModule.configure
12
+ AdminModule.configuration
13
+ end
14
+
15
+ describe ".configure" do
16
+ context "no arguments provided" do
17
+
18
+ it "creates configuration" do
19
+ AdminModule.configure
20
+ expect( AdminModule.configuration ).to_not be nil
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ describe ".find_config_path" do
27
+
28
+ it "returns nil if config not found" do
29
+ with_target_dir('config/location') do
30
+ expect( AdminModule.find_config_path ).to be nil
31
+ end
32
+ end
33
+
34
+ it "returns path if config found" do
35
+ with_target_dir('config/location') do |target_dir|
36
+ target = target_dir + '.admin_module'
37
+
38
+ # Create a config file to find
39
+ AdminModule.save_configuration target
40
+
41
+ actual = nil
42
+
43
+ # Find the file in a parent directory
44
+ with_target_dir(target_dir + 'some/nested/location') do
45
+ actual = AdminModule.find_config_path
46
+ end
47
+
48
+ expect( actual.to_s ).to eq target.expand_path.to_s
49
+ end
50
+ end
51
+ end
52
+
53
+ describe ".save_configuration" do
54
+
55
+ context "filename argument provided" do
56
+
57
+ it "creates a file" do
58
+ with_target_dir('config/location') do |target|
59
+ target = target + '.admin_module'
60
+
61
+ AdminModule.save_configuration target
62
+
63
+ expect( target.exist? ).to be true
64
+ end
65
+ end
66
+ end
67
+
68
+ context "no filename argument provided" do
69
+
70
+ context "config file doesn't exist in any parent directory" do
71
+
72
+ it "creates a file in current dir" do
73
+ with_target_dir('config/location') do |target|
74
+ AdminModule.save_configuration
75
+
76
+ target = target + '.admin_module'
77
+
78
+ expect( target.exist? ).to be true
79
+ end
80
+ end
81
+ end
82
+
83
+ context "config file exists in a parent directory" do
84
+
85
+ it "updates file in parent directory" do
86
+ with_target_dir('config/location') do |actual_location|
87
+ actual = actual_location + '.admin_module'
88
+
89
+ # Save the default configuration in a known location
90
+ AdminModule.configuration.reset
91
+ AdminModule.save_configuration actual
92
+
93
+ # Change the configuration
94
+ AdminModule.configure do |c|
95
+ c.browser_timeout = 1800
96
+ end
97
+
98
+ with_target_dir(actual_location + 'some/nested/location') do |start_dir|
99
+ AdminModule.save_configuration
100
+ end
101
+
102
+ expect( File.readlines(actual) ).to include "browser_timeout: 1800\n"
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ describe ".load_configuration" do
110
+
111
+ context "filename argument provided" do
112
+ context "config file doesn't exist" do
113
+ it "returns false" do
114
+ expect( AdminModule.load_configuration('not/a/real/path') ).to eq false
115
+ end
116
+ end
117
+
118
+ context "config file exists" do
119
+ it "loads the configuration" do
120
+ with_target_dir('config/load') do |actual_location|
121
+ actual = actual_location + '.admin_module'
122
+
123
+ # Change the configuration
124
+ AdminModule.configure do |c|
125
+ c.browser_timeout = 900
126
+ end
127
+
128
+ # Save the configuration in a known location
129
+ AdminModule.save_configuration actual
130
+
131
+ # Reset the config (clean the slate)
132
+ AdminModule.configuration.reset
133
+
134
+ AdminModule.load_configuration actual
135
+ expect( AdminModule.configuration.browser_timeout ).to eq 900
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ context "no filename argument provided" do
142
+ context "config file doesn't exist in any parent directory" do
143
+ it "returns false" do
144
+ expect( AdminModule.load_configuration ).to eq false
145
+ end
146
+ end
147
+
148
+ context "config file exists in a parent directory" do
149
+ it "loads the configuration" do
150
+ with_target_dir('config/load') do |actual_location|
151
+ actual = actual_location + '.admin_module'
152
+
153
+ # Change the configuration
154
+ AdminModule.configure do |c|
155
+ c.browser_timeout = 950
156
+ end
157
+
158
+ # Save the configuration in a known location
159
+ AdminModule.save_configuration actual
160
+
161
+ # Reset the config (clean the slate)
162
+ AdminModule.configuration.reset
163
+
164
+ with_target_dir(actual_location + 'some/nested/path') do |start_dir|
165
+ AdminModule.load_configuration
166
+ end
167
+
168
+ expect( AdminModule.configuration.browser_timeout ).to eq 950
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end # describe AdminModule
175
+
@@ -0,0 +1,36 @@
1
+ require 'pathname'
2
+ require Pathname(__FILE__).ascend{|d| h=d+'spec_helper.rb'; break h if h.file?}
3
+
4
+ require 'admin_module/cli'
5
+
6
+ describe 'admin_module executable' do
7
+
8
+ let(:cli) { AdminModule::CLI }
9
+
10
+ it "returns help info" do
11
+ output = capture_output do
12
+ cli.start %w(help)
13
+ end
14
+
15
+ expect( output ).to include "help [COMMAND]"
16
+ expect( output ).to include "gdl [COMMAND]"
17
+ expect( output ).to include "config [COMMAND]"
18
+ expect( output ).to include "ruleset [COMMAND]"
19
+ expect( output ).to include "rule [COMMAND]"
20
+ end
21
+
22
+ =begin
23
+ it "returns non-zero exit status when passed unrecognized options" do
24
+ pending
25
+ #admin_module '--invalid_argument', :exitstatus => true
26
+ admin_module '--invalid_argument'
27
+ expect(exitstatus).to_not be_zero
28
+ end
29
+
30
+ it "returns non-zero exit status when passed unrecognized task" do
31
+ pending
32
+ admin_module 'unrecognized-task'#, :exitstatus => true
33
+ expect(exitstatus).to_not be_zero
34
+ end
35
+ =end
36
+ end
@@ -0,0 +1,158 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdminModule::Client do
4
+
5
+ before(:each) do
6
+ AdminModule.configure do |config|
7
+ config.reset
8
+ config.credentials[:dev] = ['devuser', 'devpass']
9
+ end
10
+ end
11
+
12
+ let(:client) do
13
+ obj = AdminModule::Client.new
14
+ obj.page_factory = mock_page_factory
15
+ obj
16
+ end
17
+
18
+ let(:login_page) { client.page_factory.login_page }
19
+
20
+ context "#env=" do
21
+ it "sets environment to use" do
22
+ expect{ client.env = 'sit' }.to_not raise_exception
23
+ expect( client.env ).to eq :sit
24
+ end
25
+
26
+ it "raises exception if environment is not configured" do
27
+ expect{ client.env = :test }.to raise_exception
28
+ end
29
+ end
30
+
31
+ context "#env" do
32
+ it "returns default environment if not set" do
33
+ expect( client.env ).to eq AdminModule.configuration.default_environment
34
+ end
35
+ end
36
+
37
+ context "#guideline" do
38
+ it "logs into the current env and returns a pre-configured Guideline object" do
39
+
40
+ expect(login_page)
41
+ .to receive(:login_as)
42
+ .with('testuser', 'testpass')
43
+
44
+ client.user = 'testuser'
45
+ client.password = 'testpass'
46
+
47
+ expect( client.guideline ).to_not be nil
48
+ end
49
+ end
50
+
51
+ context "#rulesets" do
52
+ it "logs into the current env and returns a pre-configured Rulesets object" do
53
+
54
+ expect(login_page)
55
+ .to receive(:login_as)
56
+ .with('testuser', 'testpass')
57
+
58
+ client.user = 'testuser'
59
+ client.password = 'testpass'
60
+
61
+ expect( client.rulesets ).to_not be nil
62
+ end
63
+ end
64
+
65
+ context "#rules" do
66
+ it "logs into the current env and returns a pre-configured Rules object" do
67
+
68
+ expect(login_page)
69
+ .to receive(:login_as)
70
+ .with('testuser', 'testpass')
71
+
72
+ client.user = 'testuser'
73
+ client.password = 'testpass'
74
+
75
+ expect( client.rules ).to_not be nil
76
+ end
77
+ end
78
+
79
+ context "#locks" do
80
+ it "logs into the current env and returns a pre-configured Locks object" do
81
+
82
+ expect(login_page)
83
+ .to receive(:login_as)
84
+ .with('testuser', 'testpass')
85
+
86
+ client.user = 'testuser'
87
+ client.password = 'testpass'
88
+
89
+ expect( client.locks ).to_not be nil
90
+ end
91
+ end
92
+
93
+ context "#stages" do
94
+ it "logs into the current env and returns a pre-configured Stages object" do
95
+
96
+ expect(login_page)
97
+ .to receive(:login_as)
98
+ .with('testuser', 'testpass')
99
+
100
+ client.user = 'testuser'
101
+ client.password = 'testpass'
102
+
103
+ expect( client.stages ).to_not be nil
104
+ end
105
+ end
106
+
107
+ context "#login" do
108
+ context "credentials not passed" do
109
+
110
+ before(:each) do
111
+ AdminModule.configure do |config|
112
+ config.reset
113
+ config.credentials[:dev] = ['devuser', 'devpass']
114
+ end
115
+ end
116
+
117
+ let(:client) do
118
+ obj = AdminModule::Client.new
119
+ obj.page_factory = mock_page_factory
120
+ obj
121
+ end
122
+
123
+ it "uses credentials from configuration data" do
124
+ expect(login_page)
125
+ .to receive(:login_as)
126
+ .with('devuser', 'devpass')
127
+
128
+ client.env = :dev
129
+ client.login
130
+ end
131
+
132
+ it "credentials set on client override configuration data credentials" do
133
+ expect(login_page)
134
+ .to receive(:login_as)
135
+ .with('clientuser', 'clientpass')
136
+
137
+ client.env = :dev
138
+ client.user = 'clientuser'
139
+ client.password = 'clientpass'
140
+ client.login
141
+ end
142
+
143
+ it "raises AuthenticationRequired when no credentials are available" do
144
+ AdminModule.configure do |config|
145
+ config.credentials.delete :dev
146
+ end
147
+
148
+ client.env = :dev
149
+ client.user = nil
150
+ client.password = nil
151
+
152
+ expect{ client.login }.to raise_exception AuthenticationRequired
153
+ end
154
+ end
155
+
156
+ end
157
+ end
158
+
@@ -0,0 +1,477 @@
1
+ require 'pathname'
2
+ require Pathname(__FILE__).ascend{|d| h=d+'spec_helper.rb'; break h if h.file?}
3
+
4
+ require 'admin_module'
5
+
6
+ describe 'config command' do
7
+
8
+ before do
9
+ # Reset config to a known state.
10
+ AdminModule.configuration.reset
11
+ # Delete any config file that may have been created.
12
+ file = Pathname.pwd + '.admin_module'
13
+ file.delete if file.exist?
14
+ end
15
+
16
+ let(:cli) { AdminModule::CLI }
17
+
18
+ it "returns help info" do
19
+ output = capture_output do
20
+ cli.start %w(help config)
21
+ end
22
+
23
+ expect( output ).to include "config help [COMMAND]"
24
+ expect( output ).to include "config add [CATEGORY]"
25
+ expect( output ).to include "config show [CATEGORY]"
26
+ expect( output ).to include "config del [CATEGORY]"
27
+ expect( output ).to include "config init"
28
+ expect( output ).to include "config timeout <seconds>"
29
+ expect( output ).to include "config defcomment '<comment>'"
30
+ expect( output ).to include "config defenv <envname>"
31
+ end
32
+
33
+ context 'config init' do
34
+
35
+ context "no filename/path provided" do
36
+ it "writes a configuration file to the current working directory" do
37
+ with_target_dir('config/init') do |working_dir|
38
+ output = capture_output do
39
+ run_with_args %w(config init)
40
+ end
41
+
42
+ output_file = Pathname(working_dir) + '.admin_module'
43
+
44
+ expect( output ).to include "configuration written to #{output_file.to_s}"
45
+ expect( output_file.exist? ).to eq true
46
+ end
47
+ end
48
+ end
49
+
50
+ context "filename/path provided" do
51
+ it "writes a configuration file to the specified directory" do
52
+ with_target_dir('config/init') do |working_dir|
53
+ final_dir = clean_target_dir(working_dir + 'nested/dir')
54
+
55
+ output = capture_output do
56
+ run_with_args %W(config init #{final_dir.to_s})
57
+ end
58
+
59
+ output_file = Pathname(final_dir) + '.admin_module'
60
+
61
+ expect( output_file.exist? ).to eq true
62
+ expect( output ).to include "configuration written to #{output_file.to_s}"
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ context 'config timeout' do
69
+
70
+ it "returns the current timeout when no argument provided" do
71
+ with_target_dir('config/timeout') do
72
+ run_with_args %w(config init -q)
73
+
74
+ output = capture_output do
75
+ run_with_args %w(config timeout)
76
+ end
77
+
78
+ expect( output ).to include 'browser timeout: 360'
79
+ end
80
+ end
81
+
82
+ it "sets the current timeout when an argument is provided" do
83
+ with_target_dir('config/timout') do
84
+ run_with_args %w(config init -q)
85
+
86
+ run_with_args %w(config timeout 180)
87
+
88
+ expect( AdminModule.configuration.browser_timeout ).to eq 180
89
+ end
90
+ end
91
+
92
+ it "displays an argument error if timeout value is not an integer" do
93
+ with_target_dir('config/timeout') do
94
+ output = capture_output do
95
+ run_with_args %w(config timeout blag)
96
+ end
97
+
98
+ expect( output ).to include 'argument error: seconds must be an integer'
99
+ end
100
+ end
101
+ end
102
+
103
+ context 'config defenv' do
104
+
105
+ it "returns the current default environment when no argument provided" do
106
+ with_target_dir('config/defenv') do
107
+ run_with_args %w(config init -q)
108
+
109
+ run_with_args %w(config add env test1 http://example.com)
110
+ run_with_args %w(config defenv test1)
111
+
112
+ output = capture_output do
113
+ run_with_args %w(config defenv)
114
+ end
115
+
116
+ expect( output ).to include 'default environment: test1'
117
+ end
118
+ end
119
+
120
+ it "sets the current default environment when an argument is provided" do
121
+ with_target_dir('config/defenv') do
122
+ run_with_args %w(config init -q)
123
+
124
+ run_with_args %w(config add env test2 http://example.com)
125
+ run_with_args %w(config defenv test2)
126
+
127
+ expect( AdminModule.configuration.default_environment ).to eq :test2
128
+ end
129
+ end
130
+
131
+ it "displays an argument error if environment doesn't exist" do
132
+ with_target_dir('config/defenv') do
133
+ run_with_args %w(config init -q)
134
+
135
+ output = capture_output do
136
+ run_with_args %w(config defenv nope)
137
+ end
138
+
139
+ expect( output ).to include "argument error: environment 'nope' has not been configured"
140
+ end
141
+ end
142
+ end
143
+
144
+ context 'config defcomment' do
145
+
146
+ it "returns the current default comment when no argument provided" do
147
+ with_target_dir('config/defcomment') do
148
+ run_with_args %w(config init -q)
149
+
150
+ output = capture_output do
151
+ run_with_args %w(config defcomment)
152
+ end
153
+
154
+ expect( output ).to include 'default comment: no comment'
155
+ end
156
+ end
157
+
158
+ it "sets the default comment when an argument is provided" do
159
+ with_target_dir('config/defcomment') do
160
+ run_with_args %w(config init -q)
161
+
162
+ cmt = "new default comment"
163
+ run_with_args %W(config defcomment #{cmt})
164
+
165
+ expect( AdminModule.configuration.default_comment ).to eq 'new default comment'
166
+ end
167
+ end
168
+ end
169
+
170
+ context 'config add' do
171
+
172
+ it "returns help info" do
173
+ output = capture_output do
174
+ run_with_args %w(config help add)
175
+ end
176
+
177
+ expect( output ).to include "add help [COMMAND]"
178
+ expect( output ).to include "add env <envname> <url>"
179
+ expect( output ).to include "add xmlmap <xmlfile> <gdlname>"
180
+ expect( output ).to include "add credentials <envname> <username> <pass>"
181
+ end
182
+
183
+ context "env" do
184
+
185
+ it "adds an environment" do
186
+ with_target_dir('config/add/env') do
187
+ run_with_args %w(config init -q)
188
+
189
+ run_with_args %w(config add env test http://example.com)
190
+
191
+ actual = AdminModule.configuration.base_urls[:test]
192
+ expect( actual ).to eq 'http://example.com'
193
+ end
194
+ end
195
+
196
+ it "displays an error if environment already exists" do
197
+ with_target_dir('config/add/env') do
198
+ run_with_args %w(config init -q)
199
+
200
+ run_with_args %w(config add env test http://example.com)
201
+
202
+ output = capture_output do
203
+ run_with_args %w(config add env test http://example.com)
204
+ end
205
+
206
+ expect( output ).to include "environment 'test' already exists"
207
+ end
208
+ end
209
+ end
210
+
211
+ context "xmlmap" do
212
+
213
+ it "adds an xml file to guideline mapping" do
214
+ with_target_dir('config/add/xmlmap') do
215
+ run_with_args %w(config init -q)
216
+
217
+ run_with_args %w(config add xmlmap file.xml Guideline)
218
+
219
+ actual = AdminModule.configuration.xmlmaps['file']
220
+ expect( actual ).to eq 'Guideline'
221
+ end
222
+ end
223
+
224
+ it "displays an error if the file is already mapped" do
225
+ with_target_dir('config/add/xmlmap') do
226
+ run_with_args %w(config init -q)
227
+
228
+ run_with_args %w(config add xmlmap file.xml Guideline)
229
+
230
+ output = capture_output do
231
+ run_with_args %w(config add xmlmap file.xml Guideline)
232
+ end
233
+
234
+ expect( output ).to include "a mapping already exists for 'file'"
235
+ expect( output ).to include "delete and re-add the mapping to change it"
236
+ end
237
+ end
238
+ end
239
+
240
+ context "credentials" do
241
+
242
+ it "adds a set of credentials" do
243
+ with_target_dir('config/add/credentials') do
244
+ run_with_args %w(config init -q)
245
+
246
+ # Add an environment first...
247
+ run_with_args %w(config add env test http://example.com)
248
+
249
+ run_with_args %w(config add credentials test testuser testpass)
250
+
251
+ actual_user, actual_pass = AdminModule.configuration.credentials[:test]
252
+ expect( actual_user ).to eq 'testuser'
253
+ expect( actual_pass ).to eq 'testpass'
254
+ end
255
+ end
256
+
257
+ it "displays an error if credentials already exist for the given env" do
258
+ with_target_dir('config/add/credentials') do
259
+ run_with_args %w(config init -q)
260
+
261
+ # Add an environment first...
262
+ run_with_args %w(config add env test http://example.com)
263
+
264
+ run_with_args %w(config add credentials test testuser testpass)
265
+
266
+ output = capture_output do
267
+ run_with_args %w(config add credentials test testuser testpass)
268
+ end
269
+
270
+ expect( output ).to include "credentials already exist for environment 'test'"
271
+ end
272
+ end
273
+
274
+ it "displays an error if environment hasn't been created first" do
275
+ with_target_dir('config/add/credentials') do
276
+ run_with_args %w(config init -q)
277
+
278
+ output = capture_output do
279
+ run_with_args %w(config add credentials test testuser testpass)
280
+ end
281
+
282
+ expect( output ).to include "environment 'test' doesn't exist"
283
+ expect( output ).to include "create environment before adding credentials"
284
+ expect( AdminModule.configuration.credentials.key?(:test) ).to be false
285
+ end
286
+ end
287
+ end
288
+ end
289
+
290
+ context 'config show' do
291
+
292
+ it "returns help info" do
293
+ output = capture_output do
294
+ run_with_args %w(config help show)
295
+ end
296
+
297
+ expect( output ).to include "show help [COMMAND]"
298
+ expect( output ).to include "show envs"
299
+ expect( output ).to include "show xmlmaps"
300
+ expect( output ).to include "show credentials <envname>"
301
+ end
302
+
303
+ context "envs" do
304
+
305
+ it "displays configured environments" do
306
+ with_target_dir('config/show/credentials') do
307
+ run_with_args %w(config init -q)
308
+
309
+ run_with_args %w(config add env test1 http://example.com)
310
+ run_with_args %w(config add env test2 http://example.org)
311
+
312
+ output = capture_output do
313
+ run_with_args %w(config show envs)
314
+ end
315
+
316
+ expect( output ).to include 'Environments:'
317
+ expect( output ).to include 'test1 http://example.com'
318
+ expect( output ).to include 'test2 http://example.org'
319
+ end
320
+ end
321
+ end
322
+
323
+ context "xmlmaps" do
324
+
325
+ it "displays configured xmlmaps" do
326
+ with_target_dir('config/show/xmlmaps') do
327
+ run_with_args %w(config init -q)
328
+
329
+ gdl1 = 'Guideline 1'
330
+ gdl2 = 'Guideline 2'
331
+ run_with_args %W(config add xmlmap file1.xml #{gdl1})
332
+ run_with_args %W(config add xmlmap file2.xml #{gdl2})
333
+
334
+ output = capture_output do
335
+ run_with_args %w(config show xmlmaps)
336
+ end
337
+
338
+ expect( output ).to include 'xmlmaps:'
339
+ expect( output ).to include 'file1 Guideline 1'
340
+ expect( output ).to include 'file2 Guideline 2'
341
+ end
342
+ end
343
+ end
344
+
345
+ context "credentials" do
346
+
347
+ it "displays configured credentials" do
348
+ with_target_dir('config/show/credentials') do
349
+ run_with_args %w(config init -q)
350
+
351
+ run_with_args %w(config add env test1 http://example.com)
352
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
353
+
354
+ run_with_args %w(config add env test2 http://example.org)
355
+ run_with_args %w(config add credentials test2 testuser2 testpass2)
356
+
357
+ output = capture_output do
358
+ run_with_args %w(config show credentials)
359
+ end
360
+
361
+ expect( output ).to include 'credentials:'
362
+ expect( output ).to include 'test1 testuser1 testpass1'
363
+ expect( output ).to include 'test2 testuser2 testpass2'
364
+ end
365
+ end
366
+
367
+ it "displays configured credentials for specified environment" do
368
+ with_target_dir('config/show/credentials') do
369
+ run_with_args %w(config init -q)
370
+
371
+ run_with_args %w(config add env test1 http://example.com)
372
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
373
+
374
+ run_with_args %w(config add env test2 http://example.org)
375
+ run_with_args %w(config add credentials test2 testuser2 testpass2)
376
+
377
+ output = capture_output do
378
+ run_with_args %w(config show credentials test1)
379
+ end
380
+
381
+ expect( output ).to include 'credentials:'
382
+ expect( output ).to include 'test1 testuser1 testpass1'
383
+ expect( output ).to_not include 'test2 testuser2 testpass2'
384
+ end
385
+ end
386
+ end
387
+ end
388
+
389
+ context 'config del' do
390
+
391
+ it "returns help info" do
392
+ output = capture_output do
393
+ run_with_args %w(config help del)
394
+ end
395
+
396
+ expect( output ).to include "del help [COMMAND]"
397
+ expect( output ).to include "del env <envname>"
398
+ expect( output ).to include "del xmlmap <xmlfile>"
399
+ expect( output ).to include "del credentials <envname>"
400
+ end
401
+
402
+ context "env" do
403
+
404
+ it "deletes an existing environment" do
405
+ with_target_dir('config/del/env') do
406
+ run_with_args %w(config init -q)
407
+
408
+ run_with_args %w(config add env test1 http://example.com)
409
+
410
+ run_with_args %w(config del env test1)
411
+
412
+ expect( AdminModule.configuration.base_urls.key?(:test1) ).to be false
413
+ end
414
+ end
415
+
416
+ it "deletes matching credentials when deleting an environment" do
417
+ with_target_dir('config/del/env') do
418
+ run_with_args %w(config init -q)
419
+
420
+ run_with_args %w(config add env test1 http://example.com)
421
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
422
+
423
+ run_with_args %w(config del env test1)
424
+
425
+ expect( AdminModule.configuration.base_urls.key?(:test1) ).to be false
426
+ expect( AdminModule.configuration.credentials.key?(:test1) ).to be false
427
+ end
428
+ end
429
+ end
430
+
431
+ context "xmlmap" do
432
+
433
+ it "deletes an existing xmlmap" do
434
+ with_target_dir('config/del/xmlmap') do
435
+ run_with_args %w(config init -q)
436
+
437
+ run_with_args %w(config add xmlmap file1.xml Guideline1)
438
+
439
+ run_with_args %w(config del xmlmap file1.xml)
440
+
441
+ expect( AdminModule.configuration.xmlmaps.key?('file1') ).to be false
442
+ end
443
+ end
444
+ end
445
+
446
+ context "credentials" do
447
+
448
+ it "deletes existing credentials" do
449
+ with_target_dir('config/del/credentials') do
450
+ run_with_args %w(config init -q)
451
+
452
+ run_with_args %w(config add env test1 http://example.com)
453
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
454
+
455
+ run_with_args %w(config del credentials test1)
456
+
457
+ expect( AdminModule.configuration.credentials.key?(:test1) ).to be false
458
+ end
459
+ end
460
+
461
+ it "does not delete matching environment when deleting credentials" do
462
+ with_target_dir('config/del/credentials') do
463
+ run_with_args %w(config init -q)
464
+
465
+ run_with_args %w(config add env test1 http://example.com)
466
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
467
+
468
+ run_with_args %w(config del credentials test1)
469
+
470
+ expect( AdminModule.configuration.base_urls.key?(:test1) ).to be true
471
+ expect( AdminModule.configuration.credentials.key?(:test1) ).to be false
472
+ end
473
+ end
474
+ end
475
+ end
476
+ end
477
+