polytrix 0.0.1 → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.rspec +1 -6
  4. data/.rubocop-todo.yml +19 -0
  5. data/.rubocop.yml +10 -0
  6. data/.travis.yml +11 -0
  7. data/Gemfile +0 -16
  8. data/README.md +119 -28
  9. data/Rakefile +18 -123
  10. data/bin/polytrix +5 -0
  11. data/doc-src/_markdown.md +5 -0
  12. data/doc-src/default_bootstrap.md +13 -0
  13. data/docs/influences.md +28 -0
  14. data/docs/samples/code2doc/java/HelloWorld.md +13 -0
  15. data/docs/samples/code2doc/java/Quine.md +33 -0
  16. data/docs/samples/code2doc/python/hello_world.md +3 -0
  17. data/docs/samples/code2doc/python/quine.md +4 -0
  18. data/docs/samples/code2doc/ruby/hello_world.md +7 -0
  19. data/features/execution.feature +67 -0
  20. data/features/fixtures/configs/empty.yml +12 -0
  21. data/features/fixtures/configs/hello_world.yml +10 -0
  22. data/features/fixtures/spec/polytrix_merge.rb +5 -0
  23. data/features/fixtures/spec/polytrix_spec.rb +10 -0
  24. data/features/reporting.feature +140 -0
  25. data/features/step_definitions/sdk_steps.rb +12 -0
  26. data/features/support/env.rb +8 -0
  27. data/lib/polytrix/challenge.rb +20 -7
  28. data/lib/polytrix/challenge_runner.rb +9 -44
  29. data/lib/polytrix/cli/add.rb +67 -0
  30. data/lib/polytrix/cli/report.rb +88 -0
  31. data/lib/polytrix/cli/reports/hash_reporter.rb +30 -0
  32. data/lib/polytrix/cli/reports/json_reporter.rb +14 -0
  33. data/lib/polytrix/cli/reports/markdown_reporter.rb +23 -0
  34. data/lib/polytrix/cli/reports/yaml_reporter.rb +14 -0
  35. data/lib/polytrix/cli.rb +158 -0
  36. data/lib/polytrix/configuration.rb +65 -4
  37. data/lib/polytrix/core/file_system_helper.rb +75 -0
  38. data/lib/polytrix/core/implementor.rb +31 -3
  39. data/lib/polytrix/documentation/code_segmenter.rb +168 -0
  40. data/lib/polytrix/documentation/comment_styles.rb +87 -0
  41. data/lib/polytrix/documentation/helpers/code_helper.rb +85 -0
  42. data/lib/polytrix/documentation/view_helper.rb +21 -0
  43. data/lib/polytrix/documentation_generator.rb +59 -10
  44. data/lib/polytrix/executor.rb +89 -0
  45. data/lib/polytrix/logger.rb +17 -0
  46. data/lib/polytrix/manifest.rb +64 -7
  47. data/lib/polytrix/result.rb +16 -2
  48. data/lib/polytrix/rspec/documentation_formatter.rb +41 -16
  49. data/lib/polytrix/rspec/yaml_report.rb +51 -0
  50. data/lib/polytrix/rspec.rb +32 -53
  51. data/lib/polytrix/runners/middleware/feature_executor.rb +4 -3
  52. data/lib/polytrix/runners/middleware/setup_env_vars.rb +6 -4
  53. data/lib/polytrix/validation.rb +20 -0
  54. data/lib/polytrix/validations.rb +23 -0
  55. data/lib/polytrix/validator.rb +20 -0
  56. data/lib/polytrix/validator_registry.rb +34 -0
  57. data/lib/polytrix/version.rb +1 -1
  58. data/lib/polytrix.rb +125 -22
  59. data/polytrix.gemspec +7 -2
  60. data/polytrix.rb +6 -0
  61. data/polytrix_tests.yml +20 -0
  62. data/resources/code_sample.tt +2 -0
  63. data/samples/.gitignore +2 -0
  64. data/samples/_markdown.md +5 -0
  65. data/samples/default_bootstrap.rb +14 -0
  66. data/samples/polytrix.rb +28 -0
  67. data/samples/polytrix_cli.sh +7 -0
  68. data/samples/polytrix_tests.yml +10 -0
  69. data/{sdks/fog → samples}/scripts/bootstrap +0 -2
  70. data/samples/scripts/wrapper +7 -0
  71. data/samples/sdks/custom/polytrix.yml +2 -0
  72. data/samples/sdks/java/.gitignore +2 -0
  73. data/samples/sdks/java/build.gradle +14 -0
  74. data/samples/sdks/java/challenges/HelloWorld.java +10 -0
  75. data/samples/sdks/java/challenges/Quine.java +31 -0
  76. data/samples/sdks/java/code_sample.tt +11 -0
  77. data/samples/sdks/java/scripts/bootstrap +2 -0
  78. data/samples/sdks/java/scripts/wrapper +8 -0
  79. data/samples/sdks/python/challenges/hello_world.py +2 -0
  80. data/samples/sdks/python/challenges/quine.py +2 -0
  81. data/{sdks/pkgcloud → samples/sdks/python}/scripts/wrapper +1 -1
  82. data/samples/sdks/ruby/challenges/hello_world.rb +4 -0
  83. data/scripts/bootstrap +1 -9
  84. data/scripts/wrapper +7 -0
  85. data/spec/fabricators/challenge_fabricator.rb +17 -0
  86. data/spec/fabricators/manifest_fabricator.rb +50 -0
  87. data/spec/fabricators/validator_fabricator.rb +12 -0
  88. data/spec/fixtures/{polytrix.yml → polytrix_tests.yml} +0 -0
  89. data/spec/fixtures/src-doc/_scenario.md.erb +1 -0
  90. data/spec/polytrix/challenge_runner_spec.rb +3 -3
  91. data/spec/polytrix/challenge_spec.rb +3 -4
  92. data/spec/polytrix/cli_spec.rb +39 -0
  93. data/spec/polytrix/configuration_spec.rb +45 -1
  94. data/spec/polytrix/documentation/helpers/code_helper_spec.rb +120 -0
  95. data/spec/polytrix/documentation_generator_spec.rb +41 -20
  96. data/spec/polytrix/file_finder_spec.rb +4 -3
  97. data/spec/polytrix/implementor_spec.rb +33 -0
  98. data/spec/polytrix/manifest_spec.rb +32 -14
  99. data/spec/polytrix/middleware/feature_executor_spec.rb +1 -1
  100. data/spec/polytrix/result_spec.rb +49 -0
  101. data/spec/polytrix/validations_spec.rb +16 -0
  102. data/spec/polytrix/validator_registry_spec.rb +39 -0
  103. data/spec/polytrix/validator_spec.rb +63 -0
  104. data/spec/polytrix_spec.rb +33 -7
  105. data/spec/spec_helper.rb +14 -1
  106. data/spec/thor_spy.rb +64 -0
  107. metadata +177 -160
  108. data/.rspec_parallel +0 -10
  109. data/Vagrantfile +0 -41
  110. data/features/0_identity_spec.rb +0 -40
  111. data/features/1_cloud_files_spec.rb +0 -48
  112. data/features/2_servers_spec.rb +0 -19
  113. data/features/features_helper.rb +0 -46
  114. data/features/helpers/cloudfiles_helper.rb +0 -31
  115. data/features/helpers/pacto_helper.rb +0 -33
  116. data/features/helpers/teardown_helper.rb +0 -49
  117. data/features/pacto/extensions/loaders/api_blueprint_loader.rb +0 -63
  118. data/features/pacto/extensions/loaders/simple_loader.rb +0 -55
  119. data/features/pacto/extensions/loaders/yaml_or_json_loader.rb +0 -17
  120. data/features/pacto/extensions/matchers.rb +0 -38
  121. data/features/phase2/feature_coverage_report.rb +0 -109
  122. data/features/phase2/run_all_features.rb +0 -14
  123. data/features/static_site/fixtures/index.html +0 -6
  124. data/lib/polytrix/challenge_builder.rb +0 -16
  125. data/lib/polytrix/core/file_finder.rb +0 -43
  126. data/lib/polytrix/core/result_tracker.rb +0 -25
  127. data/lib/polytrix/runners/middleware/pacto.rb +0 -59
  128. data/packer/.gitignore +0 -3
  129. data/packer/Berksfile +0 -15
  130. data/packer/Gemfile +0 -5
  131. data/packer/Vagrantfile +0 -128
  132. data/packer/cookbooks/drg/metadata.rb +0 -27
  133. data/packer/cookbooks/drg/recipes/admins.rb +0 -22
  134. data/packer/cookbooks/drg/recipes/default.rb +0 -9
  135. data/packer/cookbooks/drg/recipes/dotnet.rb +0 -4
  136. data/packer/cookbooks/drg/recipes/golang.rb +0 -4
  137. data/packer/cookbooks/drg/recipes/java.rb +0 -5
  138. data/packer/cookbooks/drg/recipes/php.rb +0 -10
  139. data/packer/cookbooks/drg/recipes/ruby.rb +0 -29
  140. data/packer/cookbooks/drg/recipes/system.rb +0 -13
  141. data/packer/create_box.sh +0 -10
  142. data/packer/http/preseed.cfg +0 -87
  143. data/packer/packer.json +0 -91
  144. data/packer/scripts/root_setup.sh +0 -37
  145. data/packer/scripts/setup.sh +0 -32
  146. data/pacto/config/pacto_server.rb +0 -40
  147. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/extensions.json +0 -64
  148. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/flavors/id.json +0 -100
  149. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/images/id.json +0 -176
  150. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers/id.json +0 -189
  151. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers.json +0 -63
  152. data/pacto/contracts/dns.api.rackspacecloud.com/v1.0/_tenant_id/domains.json +0 -62
  153. data/pacto/contracts/identity.api.rackspacecloud.com/v2.0/tokens.json +0 -192
  154. data/pacto/contracts/monitoring.api.rackspacecloud.com/v1.0/_tenant_id/account.json +0 -39
  155. data/pacto/contracts/ord.autoscale.api.rackspacecloud.com/v1.0/_tenant_id/groups.json +0 -38
  156. data/pacto/contracts/ord.blockstorage.api.rackspacecloud.com/v1/_tenant_id/volumes.json +0 -30
  157. data/pacto/contracts/ord.databases.api.rackspacecloud.com/v1.0/_tenant_id/instances.json +0 -30
  158. data/pacto/contracts/ord.loadbalancers.api.rackspacecloud.com/v1.0/_tenant_id/loadbalancers.json +0 -114
  159. data/pacto/contracts/ord.queues.api.rackspacecloud.com/v1/_tenant_id/queues.json +0 -13
  160. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/os-networksv2.json +0 -46
  161. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/servers/detail.json +0 -230
  162. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account/container/object.json +0 -15
  163. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account.json +0 -43
  164. data/pacto/contracts/storage101.ord1.clouddrive.com/v1/_mosso_id.json +0 -44
  165. data/pacto/pacto_server.rb +0 -100
  166. data/pacto/rackspace_uri_map.yaml +0 -229
  167. data/scripts/cibuild +0 -4
  168. data/sdks/fog/.gitignore +0 -1
  169. data/sdks/fog/Gemfile +0 -5
  170. data/sdks/fog/challenges/all_connections.rb +0 -45
  171. data/sdks/fog/challenges/authenticate_token.rb +0 -15
  172. data/sdks/fog/challenges/cdn_enable_container.rb +0 -20
  173. data/sdks/fog/challenges/create_a_container.rb +0 -17
  174. data/sdks/fog/challenges/create_server.rb +0 -36
  175. data/sdks/fog/challenges/get_object_metadata.rb +0 -13
  176. data/sdks/fog/challenges/list_containers.rb +0 -10
  177. data/sdks/fog/challenges/provision_scalable_webapp.rb +0 -30
  178. data/sdks/fog/challenges/upload_folder.rb +0 -25
  179. data/sdks/fog/scripts/bootstrap.ps1 +0 -1
  180. data/sdks/fog/scripts/wrapper +0 -2
  181. data/sdks/fog/scripts/wrapper.ps1 +0 -1
  182. data/sdks/gophercloud/.gitignore +0 -2
  183. data/sdks/gophercloud/challenges/authenticate_token.go +0 -23
  184. data/sdks/gophercloud/scripts/bootstrap +0 -6
  185. data/sdks/gophercloud/scripts/wrapper +0 -10
  186. data/sdks/jclouds/.gitignore +0 -1
  187. data/sdks/jclouds/challenges/AuthenticateToken.java +0 -115
  188. data/sdks/jclouds/pom.xml +0 -34
  189. data/sdks/jclouds/scripts/bootstrap +0 -3
  190. data/sdks/jclouds/scripts/wrapper +0 -7
  191. data/sdks/openstack.net/.gitignore +0 -4
  192. data/sdks/openstack.net/.nuget/Microsoft.Build.dll +0 -0
  193. data/sdks/openstack.net/.nuget/NuGet.Config +0 -6
  194. data/sdks/openstack.net/.nuget/NuGet.exe +0 -0
  195. data/sdks/openstack.net/.nuget/NuGet.targets +0 -136
  196. data/sdks/openstack.net/Challenge.cs +0 -10
  197. data/sdks/openstack.net/RunChallenge.cs +0 -19
  198. data/sdks/openstack.net/challenges/AuthenticateToken.cs +0 -24
  199. data/sdks/openstack.net/challenges/Weird.cs +0 -133
  200. data/sdks/openstack.net/openstack.net.csproj +0 -58
  201. data/sdks/openstack.net/openstack.net.sln +0 -27
  202. data/sdks/openstack.net/openstack.net.userprefs +0 -8
  203. data/sdks/openstack.net/packages.config +0 -6
  204. data/sdks/openstack.net/scripts/bootstrap +0 -2
  205. data/sdks/openstack.net/scripts/bootstrap.ps1 +0 -2
  206. data/sdks/openstack.net/scripts/wrapper +0 -7
  207. data/sdks/openstack.net/scripts/wrapper.ps1 +0 -1
  208. data/sdks/php-opencloud/.gitignore +0 -4
  209. data/sdks/php-opencloud/challenges/all_connections.php +0 -64
  210. data/sdks/php-opencloud/challenges/authenticate_token.php +0 -14
  211. data/sdks/php-opencloud/challenges/create_server.php +0 -39
  212. data/sdks/php-opencloud/challenges/get_object_metadata.php +0 -19
  213. data/sdks/php-opencloud/composer.json +0 -5
  214. data/sdks/php-opencloud/scripts/bootstrap +0 -4
  215. data/sdks/php-opencloud/scripts/bootstrap.ps1 +0 -2
  216. data/sdks/php-opencloud/scripts/wrapper +0 -2
  217. data/sdks/php-opencloud/scripts/wrapper.ps1 +0 -1
  218. data/sdks/pkgcloud/.gitignore +0 -1
  219. data/sdks/pkgcloud/challenges/authenticate_token.js +0 -17
  220. data/sdks/pkgcloud/challenges/get_object_metadata.js +0 -18
  221. data/sdks/pkgcloud/scripts/bootstrap +0 -2
  222. data/sdks/pkgcloud/scripts/bootstrap.ps1 +0 -1
  223. data/sdks/pkgcloud/scripts/wrapper.ps1 +0 -1
  224. data/sdks/pyrax/.gitignore +0 -2
  225. data/sdks/pyrax/challenges/all_connections.py +0 -61
  226. data/sdks/pyrax/challenges/authenticate_token.py +0 -17
  227. data/sdks/pyrax/challenges/cdn_enable_container.py +0 -22
  228. data/sdks/pyrax/challenges/create_a_container.py +0 -21
  229. data/sdks/pyrax/challenges/create_server.py +0 -35
  230. data/sdks/pyrax/challenges/get_object_metadata.py +0 -17
  231. data/sdks/pyrax/challenges/upload_folder.py +0 -32
  232. data/sdks/pyrax/requirements.txt +0 -21
  233. data/sdks/pyrax/scripts/bootstrap +0 -9
  234. data/sdks/pyrax/scripts/bootstrap.ps1 +0 -7
  235. data/sdks/pyrax/scripts/wrapper +0 -3
  236. data/sdks/pyrax/scripts/wrapper.ps1 +0 -2
  237. data/spec/polytrix/challenge_builder_spec.rb +0 -16
  238. data/spec/rspec_spec.rb +0 -17
@@ -1,230 +0,0 @@
1
- {
2
- "request": {
3
- "headers": {
4
- },
5
- "method": "get",
6
- "path": "/v2/:tenant_id/servers/detail"
7
- },
8
- "response": {
9
- "headers": {
10
- "Content-Type": "application/json"
11
- },
12
- "status": 200,
13
- "body": {
14
- "$schema": "http://json-schema.org/draft-03/schema#",
15
- "description": "Generated from https://ord.servers.api.rackspacecloud.com/v2/:tenant_id/servers/detail with shasum 1c7341b036cda60e635ee836dd71c182f8f78712",
16
- "type": "object",
17
- "required": true,
18
- "properties": {
19
- "servers": {
20
- "type": "array",
21
- "required": true,
22
- "minItems": 1,
23
- "uniqueItems": true,
24
- "items": {
25
- "type": "object",
26
- "required": true,
27
- "properties": {
28
- "status": {
29
- "type": "string",
30
- "required": true
31
- },
32
- "updated": {
33
- "type": "string",
34
- "required": true
35
- },
36
- "hostId": {
37
- "type": "string",
38
- "required": true
39
- },
40
- "addresses": {
41
- "type": "object",
42
- "required": true,
43
- "properties": {
44
- "public": {
45
- "type": "array",
46
- "required": true,
47
- "minItems": 1,
48
- "uniqueItems": true,
49
- "items": {
50
- "type": "object",
51
- "required": true,
52
- "properties": {
53
- "version": {
54
- "type": "integer",
55
- "required": true
56
- },
57
- "addr": {
58
- "type": "string",
59
- "required": true
60
- }
61
- }
62
- }
63
- },
64
- "private": {
65
- "type": "array",
66
- "required": true,
67
- "minItems": 1,
68
- "uniqueItems": true,
69
- "items": {
70
- "type": "object",
71
- "required": true,
72
- "properties": {
73
- "version": {
74
- "type": "integer",
75
- "required": true
76
- },
77
- "addr": {
78
- "type": "string",
79
- "required": true
80
- }
81
- }
82
- }
83
- }
84
- }
85
- },
86
- "links": {
87
- "type": "array",
88
- "required": true,
89
- "minItems": 1,
90
- "uniqueItems": true,
91
- "items": {
92
- "type": "object",
93
- "required": true,
94
- "properties": {
95
- "href": {
96
- "type": "string",
97
- "required": true
98
- },
99
- "rel": {
100
- "type": "string",
101
- "required": true
102
- }
103
- }
104
- }
105
- },
106
- "key_name": {
107
- },
108
- "image": {
109
- "type": "object",
110
- "required": true,
111
- "properties": {
112
- "id": {
113
- "type": "string",
114
- "required": true
115
- },
116
- "links": {
117
- "type": "array",
118
- "required": true,
119
- "minItems": 1,
120
- "uniqueItems": true,
121
- "items": {
122
- "type": "object",
123
- "required": true,
124
- "properties": {
125
- "href": {
126
- "type": "string",
127
- "required": true
128
- },
129
- "rel": {
130
- "type": "string",
131
- "required": true
132
- }
133
- }
134
- }
135
- }
136
- }
137
- },
138
- "OS-EXT-STS:task_state": {
139
- },
140
- "OS-EXT-STS:vm_state": {
141
- "type": "string",
142
- "required": false
143
- },
144
- "flavor": {
145
- "type": "object",
146
- "required": true,
147
- "properties": {
148
- "id": {
149
- "type": "string",
150
- "required": true
151
- },
152
- "links": {
153
- "type": "array",
154
- "required": true,
155
- "minItems": 1,
156
- "uniqueItems": true,
157
- "items": {
158
- "type": "object",
159
- "required": true,
160
- "properties": {
161
- "href": {
162
- "type": "string",
163
- "required": true
164
- },
165
- "rel": {
166
- "type": "string",
167
- "required": true
168
- }
169
- }
170
- }
171
- }
172
- }
173
- },
174
- "id": {
175
- "type": "string",
176
- "required": true
177
- },
178
- "user_id": {
179
- "type": "string",
180
- "required": true
181
- },
182
- "name": {
183
- "type": "string",
184
- "required": true
185
- },
186
- "created": {
187
- "type": "string",
188
- "required": true
189
- },
190
- "tenant_id": {
191
- "type": "string",
192
- "required": true
193
- },
194
- "OS-DCF:diskConfig": {
195
- "type": "string",
196
- "required": false
197
- },
198
- "accessIPv4": {
199
- "type": "string",
200
- "required": true
201
- },
202
- "accessIPv6": {
203
- "type": "string",
204
- "required": true
205
- },
206
- "progress": {
207
- "type": "integer",
208
- "required": true
209
- },
210
- "OS-EXT-STS:power_state": {
211
- "type": "integer",
212
- "required": false
213
- },
214
- "config_drive": {
215
- "type": "string",
216
- "required": true
217
- },
218
- "metadata": {
219
- "type": "object",
220
- "required": true,
221
- "properties": {
222
- }
223
- }
224
- }
225
- }
226
- }
227
- }
228
- }
229
- }
230
- }
@@ -1,15 +0,0 @@
1
- {
2
- "request": {
3
- "headers": {
4
- },
5
- "method": "head",
6
- "path": "/v1/:mosso_account/:container/:object"
7
- },
8
- "response": {
9
- "headers": {
10
- "Content-Type": "application/octet-stream",
11
- "Accept-Ranges": "bytes"
12
- },
13
- "status": 200
14
- }
15
- }
@@ -1,43 +0,0 @@
1
- {
2
- "request": {
3
- "headers": {
4
- },
5
- "method": "get",
6
- "params": {
7
- },
8
- "path": "/v1/:mosso"
9
- },
10
- "response": {
11
- "headers": {
12
- "Content-Type": "application/json; charset=utf-8",
13
- "Accept-Ranges": "bytes"
14
- },
15
- "status": 200,
16
- "body": {
17
- "$schema": "http://json-schema.org/draft-03/schema#",
18
- "description": "Generated from vcr with shasum 814f52c8c895e72dd1051188ee3a65704698033a",
19
- "type": "array",
20
- "required": true,
21
- "minItems": 1,
22
- "uniqueItems": true,
23
- "items": {
24
- "type": "object",
25
- "required": true,
26
- "properties": {
27
- "count": {
28
- "type": "integer",
29
- "required": true
30
- },
31
- "bytes": {
32
- "type": "integer",
33
- "required": true
34
- },
35
- "name": {
36
- "type": "string",
37
- "required": true
38
- }
39
- }
40
- }
41
- }
42
- }
43
- }
@@ -1,44 +0,0 @@
1
- {
2
- "request": {
3
- "headers": {
4
- },
5
- "method": "get",
6
- "params": {
7
- "format": "json"
8
- },
9
- "path": "/v1/:mosso_id/"
10
- },
11
- "response": {
12
- "headers": {
13
- "Content-Type": "application/json; charset=utf-8",
14
- "Accept-Ranges": "bytes"
15
- },
16
- "status": 200,
17
- "body": {
18
- "$schema": "http://json-schema.org/draft-03/schema#",
19
- "description": "Generated from https://storage101.ord1.clouddrive.com/v1/:mosso_id/?format=json with shasum f8f6461144643dda6fc335e09f96a5930008b9d9",
20
- "type": "array",
21
- "required": true,
22
- "minItems": 1,
23
- "uniqueItems": true,
24
- "items": {
25
- "type": "object",
26
- "required": true,
27
- "properties": {
28
- "count": {
29
- "type": "integer",
30
- "required": true
31
- },
32
- "bytes": {
33
- "type": "integer",
34
- "required": true
35
- },
36
- "name": {
37
- "type": "string",
38
- "required": true
39
- }
40
- }
41
- }
42
- }
43
- }
44
- }
@@ -1,100 +0,0 @@
1
- require 'goliath'
2
- require 'em-synchrony'
3
- require 'em-synchrony/em-http'
4
-
5
- class PactoServer < Goliath::API
6
- use ::Rack::ContentLength
7
-
8
- def port
9
- env.config[:port]
10
- end
11
-
12
- def on_body(env, data)
13
- env.logger.info 'received data: ' + safe_log(data)
14
- (env['async-body'] ||= '') << data
15
- end
16
-
17
- def response (env)
18
- path = env[Goliath::Request::REQUEST_PATH]
19
- host = env['HTTP_HOST'].gsub(".dev:#{port}", '.com')
20
- headers = env['client-headers']
21
- begin
22
- uri = normalize_uri(env, "https://#{host}#{path}")
23
- env.logger.info 'forwarding to: ' + uri
24
- safe_headers = headers.reject {|k,v| ['host', 'content-length', 'transfer-encoding'].include? k.downcase }
25
- env.logger.debug "filtered headers: #{safe_headers}"
26
- # request_body = env[Goliath::Request::RACK_INPUT].read
27
- request_body = env['async-body']
28
- request_method = env['REQUEST_METHOD'].downcase
29
- em_request_method = "a#{request_method}".to_sym
30
- em_request_options = {:head => safe_headers, :query => env['QUERY_STRING']}
31
- env.logger.debug "sending #{request_method} request"
32
- unless request_body.nil?
33
- em_request_options.merge!({:body => request_body})
34
- env.logger.debug "with request body"
35
- end
36
-
37
- resp = EM::Synchrony.sync EventMachine::HttpRequest.new(uri).send(em_request_method, em_request_options)
38
- raise resp.error if resp.error
39
-
40
- code = resp.response_header.http_status
41
- safe_response_headers = normalize_headers(resp.response_header).reject {|k,v| ['connection', 'content-encoding', 'content-length', 'transfer-encoding'].include? k.downcase}
42
- body = proxy_rewrite(resp.response)
43
-
44
- env.logger.debug "response headers: #{safe_response_headers}"
45
- env.logger.debug "response body: #{safe_log(body)}"
46
- [code, safe_response_headers, body]
47
- rescue => e
48
- env.logger.warn "responding with error: #{e.message}"
49
- [500, {}, e.message]
50
- end
51
- end
52
-
53
- def normalize_uri env, uri
54
- if uri[-1] == '/'
55
- env.logger.warn 'Normalizing uri with trailing /, this may be detected as a consistency issue in the future'
56
- uri = uri[0..-2]
57
- end
58
- uri
59
- end
60
-
61
- def normalize_headers headers
62
- headers.inject({}) do |res, elem|
63
- key = elem.first.dup
64
- value = elem.last
65
- key.gsub!('_', '-')
66
- key = key.split('-').map {|w| w.capitalize}.join '-'
67
- res[key] = value
68
- res
69
- end
70
- end
71
-
72
- def proxy_rewrite body
73
- # Make sure rels continue going through our proxy
74
- body.gsub('.com', ".dev:#{port}").gsub(/https\:([\w\-\.\\\/]+).dev/, 'http:\1.dev')
75
- end
76
-
77
- def options_parser(opts, options)
78
- options[:strict] ||= false
79
- options[:directory] ||= "contracts"
80
- opts.on('-l', '--live', 'Send requests to live services (instead of stubs)') { |val| options[:live] = true }
81
- opts.on('-g', '--generate', 'Generate Contracts from requests') { |val| options[:generate] = true }
82
- opts.on('-V', '--validate', 'Validate requests/responses against Contracts') { |val| options[:validate] = true }
83
- opts.on('-m', '--match-strict', 'Enforce strict request matching rules') { |val| options[:strict] = true }
84
- opts.on('-x', '--contracts_dir DIR', 'Directory that contains the contracts to be registered') { |val| options[:directory] = val }
85
- opts.on('-H', '--host HOST', 'Host of the real service, for generating or validating live requests') { |val| options[:backend_host] = val }
86
- end
87
-
88
- def on_headers(env, headers)
89
- env.logger.info 'proxying new request: ' + headers.inspect
90
- env['client-headers'] = headers
91
- end
92
-
93
- def safe_log(string_to_log)
94
- if string_to_log.ascii_only?
95
- string_to_log
96
- else
97
- "(Supressed logging of non-ASCII content)"
98
- end
99
- end
100
- end
@@ -1,229 +0,0 @@
1
- ---
2
- # Provides a simple map of request patterns to service names,
3
- # so Pacto can do basic validation that services are called
4
- # and testing of services before a complete contract is available.
5
- services:
6
- Identity:
7
- servers:
8
- - identity.api.rackspacecloud.com
9
- services:
10
- # contract is available
11
- Authenticate:
12
- method: post
13
- uriTemplate: /v2.0/tokens
14
- requestSchema:
15
- $schema: "http://json-schema.org/draft-03/schema#"
16
- description: "Generated from pacto with shasum b5ec82bb381eac4a445c35bbfbfcc324135a742c"
17
- type: "object"
18
- required: true
19
- properties:
20
- auth:
21
- type: "object"
22
- required: true
23
- properties:
24
- RAX-KSKEY:apiKeyCredentials:
25
- type: "object"
26
- required: true
27
- properties:
28
- username:
29
- type: "string"
30
- required: true
31
- apiKey:
32
- type: "string"
33
- required: true
34
- Cloud Servers:
35
- servers:
36
- - syd.servers.api.rackspacecloud.com
37
- - iad.servers.api.rackspacecloud.com
38
- - ord.servers.api.rackspacecloud.com
39
- - dfw.servers.api.rackspacecloud.com
40
- - hkg.servers.api.rackspacecloud.com
41
- services:
42
- List Servers:
43
- method: get
44
- uriTemplate: /v2/{tenant_id}/servers/detail{?limit}
45
- Create Server:
46
- method: post
47
- uriTemplate: /v2/{tenant_id}/servers{?limit}
48
- responseStatusCode: 202
49
- Get Server Details:
50
- method: get
51
- uriTemplate: /v2/{tenant_id}/servers/{id}
52
- Attach Volume:
53
- method: post
54
- uriTemplate: /v2/{tenant_id}/servers/{server_id}/os-volume_attachments{?limit}
55
- # Documented code is 202, but I'm receiving 200
56
- responseStatusCode: 200
57
- List Extensions:
58
- method: get
59
- uriTemplate: /v2/{tenant_id}/extensions{?limit}
60
- Get Image Details:
61
- method: get
62
- uriTemplate: /v2/{tenant_id}/images/{image_id}
63
- Get Flavor Details:
64
- method: get
65
- uriTemplate: /v2/{tenant_id}/flavors/{flavor_id}
66
- Cloud Files:
67
- servers:
68
- - snet-storage101.dfw1.clouddrive.com
69
- - storage101.dfw1.clouddrive.com
70
- - snet-storage101.iad3.clouddrive.com
71
- - storage101.iad3.clouddrive.com
72
- - storage101.ord1.clouddrive.com
73
- - snet-storage101.ord1.clouddrive.com
74
- - snet-storage101.syd2.clouddrive.com
75
- - storage101.syd2.clouddrive.com
76
- - snet-storage101.hkg1.clouddrive.com
77
- - storage101.hkg1.clouddrive.com
78
- services:
79
- List Containers:
80
- method: get
81
- # uriTemplate only supports RFC 6570 level 0
82
- # uriTemplate: v1/{account}{?limit,marker,end_marker,format}
83
- # Fog and php-opencloud require a trailing '/' before '?', which works
84
- # but is inconsistent with documentation
85
- uriTemplate: /v1/{account}{?format,limit}
86
- Get Object Metadata:
87
- method: head
88
- uriTemplate: /v1/{account}/{container}/{object}{?format}
89
- CDN:
90
- servers:
91
- - cdn1.clouddrive.com
92
- - cdn4.clouddrive.com
93
- - cdn2.clouddrive.com
94
- - cdn5.clouddrive.com
95
- - cdn6.clouddrive.com
96
- services:
97
- Load Balancers:
98
- servers:
99
- - syd.loadbalancers.api.rackspacecloud.com
100
- - iad.loadbalancers.api.rackspacecloud.com
101
- - ord.loadbalancers.api.rackspacecloud.com
102
- - dfw.loadbalancers.api.rackspacecloud.com
103
- - hkg.loadbalancers.api.rackspacecloud.com
104
- services:
105
- Create:
106
- method: post
107
- uriTemplate: /loadbalancers
108
- Add Node:
109
- method: post
110
- uriTemplate: /loadbalancers/{loadBalancerId}/nodes
111
- List Load Balancers:
112
- method: get
113
- uriTemplate: /v1.0/{token_id}/loadbalancers{.format}{?limit}
114
- Block Storage:
115
- # Note that OpenStack docs currently have v2, Rackspace is v1
116
- servers:
117
- - syd.blockstorage.api.rackspacecloud.com
118
- - iad.blockstorage.api.rackspacecloud.com
119
- - ord.blockstorage.api.rackspacecloud.com
120
- - dfw.blockstorage.api.rackspacecloud.com
121
- - hkg.blockstorage.api.rackspacecloud.com
122
- services:
123
- Create Volume:
124
- method: post
125
- uriTemplate: /v1/{tenant_id}/volumes
126
- List Volumes:
127
- method: get
128
- uriTemplate: /v1/{token_id}/volumes{?limit}
129
- Cloud Database:
130
- servers:
131
- - syd.databases.api.rackspacecloud.com
132
- - iad.databases.api.rackspacecloud.com
133
- - ord.databases.api.rackspacecloud.com
134
- - dfw.databases.api.rackspacecloud.com
135
- - hkg.databases.api.rackspacecloud.com
136
- services:
137
- Create Instance:
138
- method: post
139
- uriTemplate: /instances
140
- Create Database:
141
- method: post
142
- uriTemplate: /instances/{instanceId}/databases
143
- List Instances:
144
- method: get
145
- uriTemplate: /v1.0/{token_id}/instances{?limit}
146
- DNS:
147
- servers:
148
- - dns.api.rackspacecloud.com
149
- services:
150
- Create Domain:
151
- method: post
152
- uriTemplate: /domains
153
- Add Records:
154
- method: post
155
- uriTemplate: /domains/{domainId}/records
156
- List Domains:
157
- method: get
158
- uriTemplate: /v1.0/{token_id}/domains{?limit}
159
- Monitoring:
160
- servers:
161
- - monitoring.api.rackspacecloud.com
162
- services:
163
- Backups:
164
- servers:
165
- - backup.api.rackspacecloud.com
166
- - syd.backup.api.rackspacecloud.com
167
- - iad.backup.api.rackspacecloud.com
168
- - ord.backup.api.rackspacecloud.com
169
- - dfw.backup.api.rackspacecloud.com
170
- - hkg.backup.api.rackspacecloud.com
171
- services:
172
- Create Backup Configuration:
173
- method: post
174
- uriTemplate: /backup-configuration
175
- Start or Stop a Backup Manually:
176
- method: post
177
- uriTemplate: /backup/action-requested
178
- Autoscale:
179
- servers:
180
- - syd.autoscale.api.rackspacecloud.com
181
- - iad.autoscale.api.rackspacecloud.com
182
- - ord.autoscale.api.rackspacecloud.com
183
- - dfw.autoscale.api.rackspacecloud.com
184
- - hkg.autoscale.api.rackspacecloud.com
185
- services:
186
- List Groups:
187
- method: get
188
- uriTemplate: /v1.0/{token_id}/groups{?limit}
189
- Cloud Queues:
190
- servers:
191
- - snet-hkg.queues.api.rackspacecloud.com
192
- - hkg.queues.api.rackspacecloud.com
193
- - snet-iad.queues.api.rackspacecloud.com
194
- - iad.queues.api.rackspacecloud.com
195
- - snet-dfw.queues.api.rackspacecloud.com
196
- - dfw.queues.api.rackspacecloud.com
197
- - snet-syd.queues.api.rackspacecloud.com
198
- - syd.queues.api.rackspacecloud.com
199
- - snet-ord.queues.api.rackspacecloud.com
200
- - ord.queues.api.rackspacecloud.com
201
- services:
202
- List Queues:
203
- method: get
204
- uriTemplate: /v1/{token_id}/queues{?limit}
205
- responseStatusCode: 204
206
- Cloud Networks:
207
- servers:
208
- - syd.servers.api.rackspacecloud.com
209
- - iad.servers.api.rackspacecloud.com
210
- - ord.servers.api.rackspacecloud.com
211
- - dfw.servers.api.rackspacecloud.com
212
- - hkg.servers.api.rackspacecloud.com
213
- services:
214
- List Networks:
215
- method: get
216
- uriTemplate: /v2/{token_id}/os-networksv2{?limit}
217
- Cloud Monitoring:
218
- servers:
219
- - monitoring.api.rackspacecloud.com
220
- services:
221
- Get Account:
222
- method: get
223
- uriTemplate: /v1.0/{token_id}/account
224
- # Need
225
- # Cloud Networks / List Networks
226
- # Load Balancers / List Load Balancers
227
-
228
- # Did not List Containers
229
-
data/scripts/cibuild DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
- bundle exec rake clean bootstrap parallel_spec documentation:dashboard
4
- bundle exec rspec spec/phase2/feature_coverage_report.rb --format MatrixFormatter::Formatters::HTML5Formatter --out docs/api_coverage.html
data/sdks/fog/.gitignore DELETED
@@ -1 +0,0 @@
1
- Gemfile.lock
data/sdks/fog/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # A sample Gemfile
2
- source "https://rubygems.org"
3
-
4
- gem "fog"
5
- gem "pry"