ncfoundry 4.9.2

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 (268) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +11 -0
  8. data/Checkfile +2 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE +987 -0
  11. data/NOTICE +10 -0
  12. data/README.md +9 -0
  13. data/Rakefile +14 -0
  14. data/VERSION +1 -0
  15. data/cfoundry.gemspec +41 -0
  16. data/config/locales/en.yml +168 -0
  17. data/lib/cc_api_stub/app_usage_events.rb +11 -0
  18. data/lib/cc_api_stub/applications.rb +57 -0
  19. data/lib/cc_api_stub/domains.rb +32 -0
  20. data/lib/cc_api_stub/events.rb +11 -0
  21. data/lib/cc_api_stub/frameworks.rb +22 -0
  22. data/lib/cc_api_stub/helper.rb +148 -0
  23. data/lib/cc_api_stub/login.rb +21 -0
  24. data/lib/cc_api_stub/organization_users.rb +27 -0
  25. data/lib/cc_api_stub/organizations.rb +82 -0
  26. data/lib/cc_api_stub/routes.rb +26 -0
  27. data/lib/cc_api_stub/runtimes.rb +22 -0
  28. data/lib/cc_api_stub/service_bindings.rb +22 -0
  29. data/lib/cc_api_stub/service_instances.rb +22 -0
  30. data/lib/cc_api_stub/services.rb +21 -0
  31. data/lib/cc_api_stub/space_users.rb +27 -0
  32. data/lib/cc_api_stub/spaces.rb +58 -0
  33. data/lib/cc_api_stub/users.rb +85 -0
  34. data/lib/cc_api_stub.rb +20 -0
  35. data/lib/cfoundry/auth_token.rb +62 -0
  36. data/lib/cfoundry/baseclient.rb +220 -0
  37. data/lib/cfoundry/chatty_hash.rb +46 -0
  38. data/lib/cfoundry/client.rb +42 -0
  39. data/lib/cfoundry/concerns/login_helpers.rb +14 -0
  40. data/lib/cfoundry/concerns/proxy_options.rb +14 -0
  41. data/lib/cfoundry/errors.rb +163 -0
  42. data/lib/cfoundry/rest_client.rb +316 -0
  43. data/lib/cfoundry/test_support.rb +3 -0
  44. data/lib/cfoundry/trace_helpers.rb +64 -0
  45. data/lib/cfoundry/uaaclient.rb +151 -0
  46. data/lib/cfoundry/upload_helpers.rb +222 -0
  47. data/lib/cfoundry/v2/app.rb +313 -0
  48. data/lib/cfoundry/v2/app_event.rb +13 -0
  49. data/lib/cfoundry/v2/app_instance.rb +74 -0
  50. data/lib/cfoundry/v2/app_usage_event.rb +14 -0
  51. data/lib/cfoundry/v2/base.rb +112 -0
  52. data/lib/cfoundry/v2/client.rb +104 -0
  53. data/lib/cfoundry/v2/domain.rb +20 -0
  54. data/lib/cfoundry/v2/event.rb +17 -0
  55. data/lib/cfoundry/v2/helper.rb +11 -0
  56. data/lib/cfoundry/v2/managed_service_instance.rb +13 -0
  57. data/lib/cfoundry/v2/model.rb +213 -0
  58. data/lib/cfoundry/v2/model_magic/attribute.rb +49 -0
  59. data/lib/cfoundry/v2/model_magic/client_extensions.rb +170 -0
  60. data/lib/cfoundry/v2/model_magic/has_summary.rb +49 -0
  61. data/lib/cfoundry/v2/model_magic/query_multi_value_helper.rb +21 -0
  62. data/lib/cfoundry/v2/model_magic/query_value_helper.rb +33 -0
  63. data/lib/cfoundry/v2/model_magic/queryable_by.rb +39 -0
  64. data/lib/cfoundry/v2/model_magic/to_many.rb +145 -0
  65. data/lib/cfoundry/v2/model_magic/to_one.rb +81 -0
  66. data/lib/cfoundry/v2/model_magic.rb +134 -0
  67. data/lib/cfoundry/v2/organization.rb +44 -0
  68. data/lib/cfoundry/v2/quota_definition.rb +12 -0
  69. data/lib/cfoundry/v2/route.rb +25 -0
  70. data/lib/cfoundry/v2/service.rb +22 -0
  71. data/lib/cfoundry/v2/service_auth_token.rb +9 -0
  72. data/lib/cfoundry/v2/service_binding.rb +10 -0
  73. data/lib/cfoundry/v2/service_broker.rb +12 -0
  74. data/lib/cfoundry/v2/service_instance.rb +14 -0
  75. data/lib/cfoundry/v2/service_plan.rb +16 -0
  76. data/lib/cfoundry/v2/space.rb +31 -0
  77. data/lib/cfoundry/v2/stack.rb +10 -0
  78. data/lib/cfoundry/v2/user.rb +97 -0
  79. data/lib/cfoundry/v2/user_provided_service_instance.rb +16 -0
  80. data/lib/cfoundry/validator.rb +41 -0
  81. data/lib/cfoundry/version.rb +4 -0
  82. data/lib/cfoundry/zip.rb +56 -0
  83. data/lib/cfoundry.rb +6 -0
  84. data/release_notes/release_1_5_3.md +177 -0
  85. data/release_notes/release_2.3.1.md +14 -0
  86. data/release_notes/release_2.3.3.md +38 -0
  87. data/release_notes/release_2.3.4.md +16 -0
  88. data/release_notes/release_2.3.5.md +14 -0
  89. data/release_notes/release_2.3.6.md +14 -0
  90. data/release_notes/release_2.3.6.rc1.md +29 -0
  91. data/release_notes/release_2.3.6.rc2.md +19 -0
  92. data/release_notes/release_2.3.7.rc1.md +14 -0
  93. data/release_notes/release_2.4.0.md +41 -0
  94. data/release_notes/release_2.4.1.rc1.md +58 -0
  95. data/release_notes/release_3.0.0.md +21 -0
  96. data/release_notes/release_3.0.1.md +16 -0
  97. data/release_notes/release_3.0.2.rc1.md +19 -0
  98. data/release_notes/release_4.0.0.md +19 -0
  99. data/release_notes/release_4.0.1.md +14 -0
  100. data/release_notes/release_4.0.2.rc1.md +14 -0
  101. data/release_notes/release_4.0.2.rc2.md +11 -0
  102. data/release_notes/release_4.0.2.rc3.md +11 -0
  103. data/release_notes/release_4.0.2.rc4.md +19 -0
  104. data/release_notes/release_4.0.2.rc5.md +14 -0
  105. data/release_notes/release_4.0.3.md +19 -0
  106. data/release_notes/release_4.0.4.rc1.md +14 -0
  107. data/release_notes/release_4.0.4.rc2.md +14 -0
  108. data/release_notes/release_4.1.0.md +19 -0
  109. data/release_notes/release_4.2.0.rc.md +24 -0
  110. data/release_notes/release_4.3.0.md +22 -0
  111. data/release_notes/release_4.3.1.md +14 -0
  112. data/release_notes/release_4.3.10.md +14 -0
  113. data/release_notes/release_4.3.11.md +14 -0
  114. data/release_notes/release_4.3.12.md +14 -0
  115. data/release_notes/release_4.3.2.rc1.md +21 -0
  116. data/release_notes/release_4.3.3.md +24 -0
  117. data/release_notes/release_4.3.4.md +11 -0
  118. data/release_notes/release_4.3.4.rc1.md +24 -0
  119. data/release_notes/release_4.3.5.md +36 -0
  120. data/release_notes/release_4.3.5.rc1.md +21 -0
  121. data/release_notes/release_4.3.6.md +14 -0
  122. data/release_notes/release_4.3.7.md +50 -0
  123. data/release_notes/release_4.3.8.md +19 -0
  124. data/release_notes/release_4.3.9.md +14 -0
  125. data/release_notes/release_4.4.0.md +16 -0
  126. data/release_notes/release_4.5.1.md +11 -0
  127. data/release_notes/release_4.5.2.md +14 -0
  128. data/release_notes/release_4.5.3.md +29 -0
  129. data/release_notes/release_4.6.0.md +24 -0
  130. data/release_notes/release_4.6.1.md +14 -0
  131. data/release_notes/release_4.6.2.md +16 -0
  132. data/release_notes/release_4.6.3.rc1.md +14 -0
  133. data/release_notes/release_4.6.3.rc2.md +14 -0
  134. data/release_notes/release_4.6.3.rc3.md +17 -0
  135. data/release_notes/release_4.7.0.md +11 -0
  136. data/release_notes/release_4.7.1.md +14 -0
  137. data/release_notes/release_4.7.1.rc.1.md +14 -0
  138. data/release_notes/release_4.7.1.rc1.md +19 -0
  139. data/script/gpp +3 -0
  140. data/spec/cc_api_stub/app_usage_events_spec.rb +12 -0
  141. data/spec/cc_api_stub/applications_spec.rb +69 -0
  142. data/spec/cc_api_stub/domains_spec.rb +40 -0
  143. data/spec/cc_api_stub/events_spec.rb +12 -0
  144. data/spec/cc_api_stub/frameworks_spec.rb +19 -0
  145. data/spec/cc_api_stub/login_spec.rb +20 -0
  146. data/spec/cc_api_stub/organization_users_spec.rb +35 -0
  147. data/spec/cc_api_stub/organizations_spec.rb +118 -0
  148. data/spec/cc_api_stub/routes_spec.rb +19 -0
  149. data/spec/cc_api_stub/runtimes_spec.rb +19 -0
  150. data/spec/cc_api_stub/service_bindings_spec.rb +13 -0
  151. data/spec/cc_api_stub/service_instances_spec.rb +19 -0
  152. data/spec/cc_api_stub/services_spec.rb +11 -0
  153. data/spec/cc_api_stub/space_users_spec.rb +35 -0
  154. data/spec/cc_api_stub/spaces_spec.rb +38 -0
  155. data/spec/cc_api_stub/users_spec.rb +107 -0
  156. data/spec/cfoundry/auth_token_spec.rb +153 -0
  157. data/spec/cfoundry/baseclient_spec.rb +284 -0
  158. data/spec/cfoundry/client_spec.rb +13 -0
  159. data/spec/cfoundry/errors_spec.rb +117 -0
  160. data/spec/cfoundry/rest_client_spec.rb +367 -0
  161. data/spec/cfoundry/trace_helpers_spec.rb +91 -0
  162. data/spec/cfoundry/uaaclient_spec.rb +421 -0
  163. data/spec/cfoundry/upload_helpers_spec.rb +182 -0
  164. data/spec/cfoundry/v2/app_event_spec.rb +97 -0
  165. data/spec/cfoundry/v2/app_instance_spec.rb +31 -0
  166. data/spec/cfoundry/v2/app_spec.rb +354 -0
  167. data/spec/cfoundry/v2/app_usage_event_spec.rb +15 -0
  168. data/spec/cfoundry/v2/base_spec.rb +375 -0
  169. data/spec/cfoundry/v2/client_spec.rb +121 -0
  170. data/spec/cfoundry/v2/domain_spec.rb +63 -0
  171. data/spec/cfoundry/v2/event_spec.rb +15 -0
  172. data/spec/cfoundry/v2/managed_service_instance_spec.rb +149 -0
  173. data/spec/cfoundry/v2/model_magic/attribute_spec.rb +123 -0
  174. data/spec/cfoundry/v2/model_magic/has_summary_spec.rb +17 -0
  175. data/spec/cfoundry/v2/model_magic/to_many_spec.rb +53 -0
  176. data/spec/cfoundry/v2/model_magic/to_one_spec.rb +106 -0
  177. data/spec/cfoundry/v2/model_magic_spec.rb +43 -0
  178. data/spec/cfoundry/v2/model_spec.rb +472 -0
  179. data/spec/cfoundry/v2/organization_spec.rb +282 -0
  180. data/spec/cfoundry/v2/quota_definition_spec.rb +50 -0
  181. data/spec/cfoundry/v2/route_spec.rb +42 -0
  182. data/spec/cfoundry/v2/service_plan_spec.rb +53 -0
  183. data/spec/cfoundry/v2/service_spec.rb +58 -0
  184. data/spec/cfoundry/v2/space_spec.rb +160 -0
  185. data/spec/cfoundry/v2/user_provided_service_instance_spec.rb +57 -0
  186. data/spec/cfoundry/v2/user_spec.rb +206 -0
  187. data/spec/cfoundry/validator_spec.rb +94 -0
  188. data/spec/factories/app_events_factory.rb +7 -0
  189. data/spec/factories/app_usage_events_factory.rb +32 -0
  190. data/spec/factories/apps_factory.rb +11 -0
  191. data/spec/factories/clients_factory.rb +7 -0
  192. data/spec/factories/domains_factory.rb +10 -0
  193. data/spec/factories/events_factory.rb +50 -0
  194. data/spec/factories/organizations_factory.rb +12 -0
  195. data/spec/factories/quota_definitions_factory.rb +8 -0
  196. data/spec/factories/routes_factory.rb +10 -0
  197. data/spec/factories/service_instances_factory.rb +10 -0
  198. data/spec/factories/service_plans_factory.rb +10 -0
  199. data/spec/factories/services_factory.rb +10 -0
  200. data/spec/factories/spaces_factory.rb +10 -0
  201. data/spec/factories/user_provided_service_instances_factory.rb +10 -0
  202. data/spec/factories/users_factory.rb +10 -0
  203. data/spec/fixtures/apps/with_cfignore/.cfignore +4 -0
  204. data/spec/fixtures/apps/with_cfignore/.hidden_file +1 -0
  205. data/spec/fixtures/apps/with_cfignore/ambiguous_ignored +0 -0
  206. data/spec/fixtures/apps/with_cfignore/ignored_dir/file_in_ignored_dir.txt +1 -0
  207. data/spec/fixtures/apps/with_cfignore/ignored_file.txt +1 -0
  208. data/spec/fixtures/apps/with_cfignore/non_ignored_dir/file_in_non_ignored_dir.txt +1 -0
  209. data/spec/fixtures/apps/with_cfignore/non_ignored_dir/ignored_file.txt +1 -0
  210. data/spec/fixtures/apps/with_cfignore/non_ignored_dir/toplevel_ignored.txt +0 -0
  211. data/spec/fixtures/apps/with_cfignore/non_ignored_file.txt +1 -0
  212. data/spec/fixtures/apps/with_cfignore/toplevel_ignored.txt +0 -0
  213. data/spec/fixtures/apps/with_dotfiles/.dotfile +1 -0
  214. data/spec/fixtures/apps/with_dotfiles/xyz +1 -0
  215. data/spec/fixtures/apps/with_external_symlink/foo +1 -0
  216. data/spec/fixtures/apps/with_ignored_external_symlink/.cfignore +1 -0
  217. data/spec/fixtures/apps/with_ignored_external_symlink/foo +1 -0
  218. data/spec/fixtures/apps/with_nested_directories/foo/bar/baz/fizz +0 -0
  219. data/spec/fixtures/apps/with_nested_directories/xyz +0 -0
  220. data/spec/fixtures/empty_file +0 -0
  221. data/spec/fixtures/fake_cc_app_usage_events.json +152 -0
  222. data/spec/fixtures/fake_cc_application.json +20 -0
  223. data/spec/fixtures/fake_cc_application_summary.json +56 -0
  224. data/spec/fixtures/fake_cc_created_application.json +11 -0
  225. data/spec/fixtures/fake_cc_created_domain.json +15 -0
  226. data/spec/fixtures/fake_cc_created_organization.json +11 -0
  227. data/spec/fixtures/fake_cc_created_route.json +13 -0
  228. data/spec/fixtures/fake_cc_created_service_instance.json +11 -0
  229. data/spec/fixtures/fake_cc_created_space.json +11 -0
  230. data/spec/fixtures/fake_cc_created_user.json +11 -0
  231. data/spec/fixtures/fake_cc_domain.json +55 -0
  232. data/spec/fixtures/fake_cc_domain_spaces.json +27 -0
  233. data/spec/fixtures/fake_cc_empty_search.json +7 -0
  234. data/spec/fixtures/fake_cc_events.json +419 -0
  235. data/spec/fixtures/fake_cc_frameworks.json +20 -0
  236. data/spec/fixtures/fake_cc_managed_service_instance.json +83 -0
  237. data/spec/fixtures/fake_cc_organization.json +161 -0
  238. data/spec/fixtures/fake_cc_organization_domains.json +59 -0
  239. data/spec/fixtures/fake_cc_organization_search.json +37 -0
  240. data/spec/fixtures/fake_cc_organization_spaces.json +99 -0
  241. data/spec/fixtures/fake_cc_organization_summary.json +20 -0
  242. data/spec/fixtures/fake_cc_organization_users.json +81 -0
  243. data/spec/fixtures/fake_cc_route.json +16 -0
  244. data/spec/fixtures/fake_cc_runtimes.json +20 -0
  245. data/spec/fixtures/fake_cc_service_binding.json +22 -0
  246. data/spec/fixtures/fake_cc_service_bindings.json +24 -0
  247. data/spec/fixtures/fake_cc_service_instance.json +83 -0
  248. data/spec/fixtures/fake_cc_service_instances.json +72 -0
  249. data/spec/fixtures/fake_cc_services.json +160 -0
  250. data/spec/fixtures/fake_cc_space.json +45 -0
  251. data/spec/fixtures/fake_cc_space_apps.json +49 -0
  252. data/spec/fixtures/fake_cc_space_summary.json +84 -0
  253. data/spec/fixtures/fake_cc_spaces.json +92 -0
  254. data/spec/fixtures/fake_cc_stats.json +29 -0
  255. data/spec/fixtures/fake_cc_user.json +139 -0
  256. data/spec/fixtures/fake_cc_user_organizations.json +92 -0
  257. data/spec/fixtures/fake_cc_user_provided_service_instance.json +51 -0
  258. data/spec/fixtures/fake_cc_user_with_managers.json +85 -0
  259. data/spec/integration/client_spec.rb +38 -0
  260. data/spec/spec_helper.rb +22 -0
  261. data/spec/support/factory_girl.rb +6 -0
  262. data/spec/support/shared_examples/cc_api_stub_request_examples.rb +79 -0
  263. data/spec/support/shared_examples/client_login_examples.rb +46 -0
  264. data/spec/support/shared_examples/model_summary_examples.rb +34 -0
  265. data/spec/support/test_model_builder.rb +10 -0
  266. data/vendor/errors/v1.yml +189 -0
  267. data/vendor/errors/v2.yml +845 -0
  268. metadata +712 -0
data/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ cf-cfoundry
2
+
3
+ Copyright (c) 2012-2013 GoPivotal, Inc. All Rights Reserved.
4
+
5
+ This product is licensed to you under the Apache License, Version 2.0 (the "License").
6
+ You may not use this product except in compliance with the License.
7
+
8
+ This product may include a number of subcomponents with separate copyright notices
9
+ and license terms. Your use of these subcomponents is subject to the terms and
10
+ conditions of the subcomponent's license, as noted in the LICENSE file.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ [![Build Status](https://travis-ci.org/cloudfoundry/cfoundry.png)](https://travis-ci.org/cloudfoundry/cfoundry)
2
+ [![Gem Version](https://badge.fury.io/rb/cfoundry.png)](http://badge.fury.io/rb/cfoundry)
3
+ [![Code Climate](https://codeclimate.com/github/cloudfoundry/cfoundry.png)](https://codeclimate.com/github/cloudfoundry/cfoundry)
4
+
5
+ # new_cfoundry gem
6
+
7
+ This is fork from https://github.com/cloudfoundry-attic/cfoundry
8
+
9
+ cfoundry is a ruby gem that provides a REST client for the Cloud Foundry REST API, which is implemented by both the [cloud controller](https://github.com/cloudfoundry/cloud_controller) and the [next generation cloud controller](https://github.com/cloudfoundry/cloud_controller_ng). cfoundry version 7+ can speak with the v2 version of the Cloud Foundry API.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "rake"
2
+ require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/version_task'
5
+
6
+ Rake::VersionTask.new
7
+ Dir.glob("lib/tasks/**/*").sort.each { |ext| load(ext) }
8
+
9
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
10
+ require "cfoundry/version"
11
+
12
+
13
+ RSpec::Core::RakeTask.new(:spec)
14
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 4.9.2
data/cfoundry.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cfoundry/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ncfoundry"
7
+ s.version = CFoundry::VERSION.dup
8
+ s.authors = ["CI-Platform-Team", "Toshio Maki"]
9
+ s.license = "Apache 2.0"
10
+ s.email = ["alexandrusmn@gmail.com"]
11
+ s.homepage = "http://github.com/smnalex/ncfoundry"
12
+ s.summary = %q{
13
+ High-level library for working with the Cloud Foundry API.
14
+ This is fork from https://github.com/cloudfoundry-attic/cfoundry
15
+ }
16
+
17
+ s.files = `git ls-files`.split($/) + Dir.glob("vendor/errors/**/*")
18
+ s.test_files = Dir.glob("spec/**/*")
19
+ s.require_paths = %w[lib]
20
+
21
+ s.add_dependency "activemodel", "<5.0.0", ">= 3.2.13"
22
+ s.add_dependency "cf-uaa-lib", "~> 3.8.0"
23
+ s.add_dependency "jwt", "~> 1.5"
24
+ s.add_dependency "multi_json", "~> 1.7"
25
+ s.add_dependency "multipart-post", "~> 1.1"
26
+ s.add_dependency "rubyzip", "~> 0.9"
27
+
28
+ s.add_development_dependency 'bundler', '~> 1.9'
29
+ s.add_development_dependency "pry"
30
+ s.add_development_dependency "pry-stack_explorer"
31
+ s.add_development_dependency "factory_girl"
32
+ s.add_development_dependency "gem-release"
33
+ s.add_development_dependency "json_pure", "~> 1.8"
34
+ s.add_development_dependency "rake", ">= 0.9", "< 11.0"
35
+ s.add_development_dependency "rspec", "~> 2.14"
36
+ s.add_development_dependency "shoulda-matchers", "~> 2.5.0"
37
+ s.add_development_dependency "timecop", "~> 0.6.1"
38
+ s.add_development_dependency "webmock", "~> 1.9"
39
+ s.add_development_dependency "putsinator"
40
+ s.add_development_dependency "version"
41
+ end
@@ -0,0 +1,168 @@
1
+ en:
2
+ activemodel:
3
+ errors:
4
+ models:
5
+ abstract_model:
6
+ attributes:
7
+ base:
8
+ cc_client: "Cloud Controller reported an error during a request."
9
+ account:
10
+ attributes:
11
+ base:
12
+ create_or_update: "Billing services are currently unavailable. Please try again later."
13
+ invalid: "Please enter a valid value."
14
+ spending_alert_amount:
15
+ invalid: "Please enter a whole dollar amount without decimal places."
16
+ not_an_integer: "Please enter a whole dollar amount without decimal places."
17
+ not_a_number: "Please enter a dollar amount."
18
+ greater_than: "Please enter a positive dollar amount."
19
+ application:
20
+ attributes:
21
+ base:
22
+ cc_client: "Cloud Controller reported an error during a request."
23
+ application_invalid: "App is invalid."
24
+ application_not_found: "App is not found."
25
+ app_memory_free_quota_exceeded: "You have exceeded your organization's FREE memory limit.<br/> A credit card must be on-file for your organization before exceeding 512MB of application memory."
26
+ app_memory_paid_quota_exceeded: "You have exceeded your organization's PAID memory limit.<br/> Please file a support ticket to request additional resources."
27
+ name:
28
+ application_name_taken: "is already in use"
29
+ instances_count:
30
+ inclusion: "must be between 1 and 999"
31
+ change_password:
32
+ attributes:
33
+ base:
34
+ default: "Something went wrong. Please try again later."
35
+ current_password:
36
+ invalid: "incorrect password"
37
+ password:
38
+ insufficient_strength: "is not secure enough"
39
+ service_unavailable: "could not validate strength. Please, try again later"
40
+ domain:
41
+ attributes:
42
+ base:
43
+ cc_client: "Cloud Controller reported an error during a request."
44
+ domain_invalid: "Domain is invalid."
45
+ domain_not_found: "Domain is not found."
46
+ name:
47
+ invalid: "not a valid domain name"
48
+ domain_name_taken: "is already taken"
49
+ invitation:
50
+ attributes:
51
+ base:
52
+ create: "There was a problem with inviting. Please try again later."
53
+ cc_client: "Cloud Controller reported an error during a request."
54
+ invitations_form:
55
+ attributes:
56
+ emails:
57
+ invalid: "is invalid"
58
+ login:
59
+ attributes:
60
+ base:
61
+ default: "Unable to login. Please try again later."
62
+ invalid: "Unable to login. Invalid email and/or password."
63
+ unauthorized: "You don't have permission to access this site."
64
+ organization:
65
+ attributes:
66
+ base:
67
+ cc_client: "Cloud Controller reported an error during a request."
68
+ organization_invalid: "Organization is invalid."
69
+ organization_not_found: "Organization is not found."
70
+ name:
71
+ invalid: "cannot include spaces"
72
+ organization_name_taken: "is already in use"
73
+ spending_limit:
74
+ less_than_or_equal_to: "exceeds the maximum spending limit"
75
+ organization_user:
76
+ attributes:
77
+ base:
78
+ update: "There was an error updating user."
79
+ destroy: "There was an error deleting user. Please try again later."
80
+ cc_client: "Cloud Controller reported an error during a request."
81
+ organization/event/date_filter:
82
+ attributes:
83
+ base:
84
+ invalid_date_range: "Selected date range is invalid"
85
+ from:
86
+ invalid: "is invalid"
87
+ to:
88
+ invalid: "is invalid"
89
+ password_reset:
90
+ attributes:
91
+ base:
92
+ no_user: There was a problem updating the password. Please contact support.
93
+ password:
94
+ insufficient_strength: is not secure enough
95
+ service_unavailable: could not validate strength. Please, try again later
96
+ c_foundry/v2/route:
97
+ attributes:
98
+ base:
99
+ cc_client: "Cloud Controller reported an error during a request."
100
+ invalid_domain: "The URL provided is not valid."
101
+ route_not_found: cannot be found
102
+ route_invalid: is invalid
103
+ host:
104
+ route_host_taken: is already taken
105
+ invalid: "can only include a-z, 0-9 and -"
106
+ service_instance:
107
+ attributes:
108
+ base:
109
+ cc_client: "Cloud Controller reported an error during a request."
110
+ service_instance_wrong_space: "The service instance and the service binding are in different spaces."
111
+ service_instance_invalid: "Service is invalid."
112
+ service_instance_not_found: "Service is not found."
113
+ max_quota_exceeded: "Unable to add the service due to a quota issue."
114
+ free_service_quota_exceeded: A credit card must be on-file for your organization before completing this action.
115
+ paid_service_quota_exceeded: A credit card must be on-file for your organization before completing this action.
116
+ service_instance_not_allowed: A credit card must be on-file for your organization before completing this action.
117
+ name:
118
+ service_instance_name_invalid: "is invalid"
119
+ service_instance_name_taken: "is already in use"
120
+ space:
121
+ attributes:
122
+ base:
123
+ cc_client: "Cloud Controller reported an error during a request."
124
+ space_invalid: "Space is invalid."
125
+ space_not_found: "Space is not found."
126
+ space_wrong_organization: "The space and the user are not in the same organization."
127
+ name:
128
+ invalid: "cannot include spaces"
129
+ space_name_taken: "is already in use"
130
+ spending_limit:
131
+ less_than_or_equal_to: "exceeds the maximum spending limit"
132
+ user_registration:
133
+ attributes:
134
+ base:
135
+ create: "Registration failed. Please try again later."
136
+ invalid_email_for_invitation_code: "This invitation code cannot be used for your email address. Please register with a different invitation code or a different email address."
137
+ email:
138
+ email_already_exists: "An account with this email already exists"
139
+ user:
140
+ attributes:
141
+ base:
142
+ already_registered: "The username is already registered."
143
+ create: "There was a problem with registering. Please try again later."
144
+ update: "Could not update details"
145
+ cc_client: "Cloud Controller reported an error during a request."
146
+ user_name:
147
+ invalid: "can only include a-z, 0-9, and +-_.@ characters"
148
+ password:
149
+ insufficient_strength: "is not secure enough"
150
+ service_unavailable: "could not validate strength. Please, try again later"
151
+ user/permissions:
152
+ attributes:
153
+ base:
154
+ no_permissions_set: "Choose at least one role"
155
+ user/details:
156
+ attributes:
157
+ base:
158
+ update: "Could not update details"
159
+ phone:
160
+ invalid: "can only include numbers and +-. characters"
161
+
162
+ activerecord:
163
+ errors:
164
+ models:
165
+ user_registration:
166
+ attributes:
167
+ email:
168
+ duplicate: "has already been registered"
@@ -0,0 +1,11 @@
1
+ module CcApiStub
2
+ module AppUsageEvents
3
+ extend Helper
4
+
5
+ private
6
+
7
+ def self.collection_endpoint
8
+ %r{/v2/app_usage_events}
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,57 @@
1
+ module CcApiStub
2
+ module Applications
3
+ extend Helper
4
+
5
+ class << self
6
+ def succeed_to_load(options={})
7
+ response_body = Helper.load_fixtures(options.delete(:fixture) || "fake_cc_#{object_name}", options)
8
+ stub_get(object_endpoint(options[:id]), {}, response(200, response_body))
9
+ end
10
+
11
+ def succeed_to_create
12
+ response_body = Helper.load_fixtures("fake_cc_created_application")
13
+ stub_post(%r{/v2/apps$}, nil, response(201, response_body))
14
+ end
15
+
16
+ def succeed_to_update(options={})
17
+ response_body = Helper.load_fixtures(:fake_cc_application, options)
18
+ stub_put(object_endpoint(options[:id]), nil, response(200, response_body))
19
+ end
20
+
21
+ def succeed_to_map_route
22
+ stub_put(%r{/v2/apps/[^/]+/routes/[^/]+$}, {}, response(201, {}))
23
+ end
24
+
25
+ def succeed_to_load_stats
26
+ response_body = Helper.load_fixtures("fake_cc_stats")
27
+ stub_get(%r{/v2/apps/[^/]+/stats$}, {}, response(200, response_body))
28
+ end
29
+
30
+ def summary_fixture
31
+ Helper.load_fixtures("fake_cc_application_summary")
32
+ end
33
+
34
+ def succeed_to_load_summary(options={})
35
+ response = summary_fixture
36
+ response["state"] = options[:state] if options.has_key?(:state)
37
+ response["routes"] = options[:routes] if options.has_key?(:routes)
38
+ stub_get(%r{/v2/apps/[^/]+/summary$}, {}, response(200, response))
39
+ end
40
+
41
+ def succeed_to_load_service_bindings
42
+ response_body = Helper.load_fixtures("fake_cc_service_bindings")
43
+ stub_get(%r{/v2/apps/[^/]+/service_bindings/?(?:\?.+)?$}, {}, response(200, response_body))
44
+ end
45
+
46
+ def fail_to_find(app_id)
47
+ stub_get(%r{/v2/apps/#{app_id}}, {}, response(404, {:code => 100004, :description => "The app name could not be found:"}))
48
+ end
49
+
50
+ private
51
+
52
+ def object_endpoint(id = nil)
53
+ %r{/v2/apps/#{id}[^/]+$}
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ module CcApiStub
2
+ module Domains
3
+ extend Helper
4
+
5
+ class << self
6
+ def succeed_to_create
7
+ response_body = Helper.load_fixtures("fake_cc_created_domain")
8
+ stub_post(%r{/v2/domains/?(\?.+)?$}, {}, response(201, response_body))
9
+ end
10
+
11
+ def succeed_to_delete
12
+ stub_delete(%r{/v2/domains/[^/\?]+$}, {}, response(200))
13
+ end
14
+
15
+ def succeed_to_load_spaces
16
+ response_body = Helper.load_fixtures("fake_cc_domain_spaces")
17
+ stub_get(%r{/v2/domains/[^/]+/spaces.*$}, {}, response(200, response_body))
18
+ end
19
+
20
+ def succeed_to_add_space
21
+ response_body = Helper.load_fixtures("fake_cc_created_domain")
22
+ stub_put(%r{/v2/domains/[^/]+/spaces/[^/]+$}, {}, response(201, response_body))
23
+ end
24
+
25
+ private
26
+
27
+ def object_endpoint(id = nil)
28
+ %r{/v2/domains/#{id}[^/]+$}
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ module CcApiStub
2
+ module Events
3
+ extend Helper
4
+
5
+ private
6
+
7
+ def self.collection_endpoint
8
+ %r{/v2/events}
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ module CcApiStub
2
+ module Frameworks
3
+ extend Helper
4
+
5
+ class << self
6
+ def succeed_to_load
7
+ response_body = Helper.load_fixtures("fake_cc_frameworks")
8
+ stub_get(collection_endpoint, {}, response(200, response_body))
9
+ end
10
+
11
+ def fail_to_load
12
+ stub_get(collection_endpoint, {}, response(500))
13
+ end
14
+
15
+ private
16
+
17
+ def collection_endpoint
18
+ %r{/v2/frameworks\?inline-relations-depth=1$}
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,148 @@
1
+ require 'json'
2
+
3
+ module CcApiStub
4
+ module Helper
5
+ class << self
6
+ def response(code, body=nil)
7
+ {
8
+ :status => code,
9
+ :headers => {},
10
+ :body => body.nil? ? "--garbage--" : body.to_json
11
+ }
12
+ end
13
+
14
+ def fail_request(method = :any, code = 500, response_body = {}, path = /#{CcApiStub::Helper.host}/)
15
+ WebMock::API.stub_request(method, path).to_return(response(code, response_body))
16
+ end
17
+
18
+ def host=(host)
19
+ @@host = host
20
+ end
21
+
22
+ def host
23
+ @@host or raise 'No host set'
24
+ end
25
+
26
+ def fail_with_error(method, error_attributes=nil)
27
+ WebMock::API.
28
+ stub_request(method, /#{CcApiStub::Helper.host}/).
29
+ to_return(response(400, error_attributes))
30
+ end
31
+
32
+ def load_fixtures(fixture_name_or_path, options = {})
33
+ path = if options.delete(:use_local_fixture)
34
+ fixture_name_or_path
35
+ else
36
+ File.join(File.dirname(__FILE__), "..", "..", "spec/fixtures/#{fixture_name_or_path.to_s}.json")
37
+ end
38
+ JSON.parse(File.read(path)).tap do |fixture|
39
+ fixture["entity"].merge!(options.stringify_keys) if options.any?
40
+ end
41
+ end
42
+ end
43
+
44
+ def stub_get(*args)
45
+ stub_request(:get, *args)
46
+ end
47
+
48
+ def stub_post(*args)
49
+ stub_request(:post, *args)
50
+ end
51
+
52
+ def stub_put(*args)
53
+ stub_request(:put, *args)
54
+ end
55
+
56
+ def stub_delete(*args)
57
+ stub_request(:delete, *args)
58
+ end
59
+
60
+ def stub_request(method, path, params = nil, response = nil)
61
+ stub = WebMock::API.stub_request(method, path)
62
+ stub.to_return(response) if response
63
+ stub.with(params) if !params.nil? && !params.empty?
64
+ stub
65
+ end
66
+
67
+ def object_name
68
+ name.demodulize.underscore.singularize
69
+ end
70
+
71
+ def find_fixture(fixture_name)
72
+ begin
73
+ Helper.load_fixtures("fake_#{fixture_name}")
74
+ rescue
75
+ Helper.load_fixtures("fake_organization_#{fixture_name}")
76
+ end
77
+ end
78
+
79
+ def object_class
80
+ begin
81
+ object_name.camelcase.constantize
82
+ rescue
83
+ "Organization::#{object_name.camelcase}".constantize
84
+ rescue
85
+ "User::#{object_name.camelcase}".constantize
86
+ end
87
+ end
88
+
89
+ def response(code, body=nil)
90
+ CcApiStub::Helper.response(code, body)
91
+ end
92
+
93
+ def succeed_to_load(options={})
94
+ response_body = response_from_options(options.reverse_merge!({:fixture => "fake_cc_#{object_name}"}))
95
+ stub_get(object_endpoint(options[:id]), {}, response(200, response_body))
96
+ end
97
+
98
+ def fail_to_load(options = {})
99
+ stub_get(object_endpoint(options[:id]), {}, response(500))
100
+ end
101
+
102
+ def succeed_to_load_many(options={})
103
+ response_body = response_from_options(options.reverse_merge!({:fixture => "fake_cc_#{object_name.pluralize}"}))
104
+ stub_get(collection_endpoint, {}, response(200, response_body))
105
+ end
106
+
107
+ def succeed_to_load_empty(options = {})
108
+ root = options[:root] || object_name.pluralize
109
+ stub_get(collection_endpoint, {}, response(200, {root => [], "pagination" => {}}))
110
+ end
111
+
112
+ def fail_to_load_many
113
+ stub_get(collection_endpoint, {}, response(500))
114
+ end
115
+
116
+ def succeed_to_create
117
+ response_body = {object_name.to_sym => {:id => "#{object_name.gsub("_", "-")}-id-1"}}
118
+ stub_post(collection_endpoint, {}, response(201, response_body))
119
+ end
120
+
121
+ def succeed_to_update(options = {})
122
+ stub_put(object_endpoint(options[:id]), nil, response(200, response_from_options(options)))
123
+ end
124
+
125
+ def fail_to_update(options = {})
126
+ stub_put(object_endpoint(options[:id]), nil, response(500, {}))
127
+ end
128
+
129
+ def succeed_to_delete(options = {})
130
+ stub_delete(object_endpoint(options[:id]), nil, response(200))
131
+ end
132
+
133
+ alias_method :succeed_to_leave, :succeed_to_delete
134
+
135
+ def fixture_prefix
136
+ "_cc"
137
+ end
138
+
139
+ private
140
+
141
+ def response_from_options(options)
142
+ fixture = options.delete(:fixture)
143
+ return options[:response] if options[:response]
144
+ return CcApiStub::Helper.load_fixtures(fixture, options) if fixture
145
+ {}
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,21 @@
1
+ module CcApiStub
2
+ module Login
3
+ class << self
4
+ def succeeds_to_find_uaa(domain="http://some-other-random-domain.com:8181")
5
+ WebMock::API.stub_request(:get, "#{domain}/info").
6
+ to_return(
7
+ :status => 200,
8
+ :body => "{\"token_endpoint\":\"https://uaa.localhost\"}"
9
+ )
10
+ end
11
+
12
+ def succeeds_to_login_as_admin
13
+ WebMock::API.stub_request(:post, %r{uaa.localhost/oauth/authorize}).
14
+ to_return(
15
+ :status => 302,
16
+ :headers => {"Location" => "https://uaa.localhost/redirect/cf#access_token=sre-admin-access-token&token_type=bearer"}
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module CcApiStub
2
+ module OrganizationUsers
3
+ extend Helper
4
+
5
+ class << self
6
+ def succeed_to_delete(options = {})
7
+ if options.has_key? :roles
8
+ options[:roles].each do |role|
9
+ stub_delete(object_endpoint(options[:id], role.to_s.pluralize), {}, response(200, ""))
10
+ end
11
+ end
12
+
13
+ stub_delete(object_endpoint(options[:id]), {}, response(200, ""))
14
+ end
15
+
16
+ def fail_to_delete(options = {})
17
+ stub_delete(object_endpoint(options[:id]), {}, response(500))
18
+ end
19
+
20
+ private
21
+
22
+ def object_endpoint(id = nil, role="users")
23
+ %r{/v2/organizations/[^/]+/#{role}/#{id}[^/]+$}
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,82 @@
1
+ module CcApiStub
2
+ module Organizations
3
+ extend Helper
4
+
5
+ class << self
6
+ def succeed_to_create
7
+ response_body = Helper.load_fixtures("fake_cc_created_organization")
8
+ stub_post(collection_endpoint, {}, response(201, response_body))
9
+ end
10
+
11
+ def summary_fixture
12
+ Helper.load_fixtures("fake_cc_organization_summary")
13
+ end
14
+
15
+ def fail_to_find(org_id)
16
+ stub_get(%r{/v2/organizations/#{org_id}}, {}, response(404, {:code => 30003, :description => "The organization could not be found"}))
17
+ end
18
+
19
+ def succeed_to_load_summary(options={})
20
+ response_body = summary_fixture
21
+ response_body["spaces"] = [] if options[:no_spaces]
22
+ stub_get(%r{/v2/organizations/[^/]+/summary$}, {}, response(200, response_body))
23
+ end
24
+
25
+ def succeed_to_search(name)
26
+ response_body = Helper.load_fixtures("fake_cc_organization_search")
27
+ stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:#{name}$}, {}, response(200, response_body))
28
+ end
29
+
30
+ def succeed_to_search_none
31
+ response_body = Helper.load_fixtures("fake_cc_empty_search")
32
+ stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:.*$}, {}, response(200, response_body))
33
+ end
34
+
35
+ def domains_fixture
36
+ Helper.load_fixtures("fake_cc_organization_domains")
37
+ end
38
+
39
+ def domain_fixture_hash
40
+ MultiJson.load(domains_fixture["resources"].first.to_json, :symbolize_keys => true)
41
+ end
42
+
43
+ def succeed_to_load_domains
44
+ stub_get(%r{/v2/organizations/[^/]+/domains\?inline-relations-depth=1}, {}, response(200, domains_fixture))
45
+ end
46
+
47
+ def users_fixture
48
+ Helper.load_fixtures("fake_cc_organization_users")
49
+ end
50
+
51
+ def user_fixture_hash
52
+ MultiJson.load(users_fixture["resources"].first.to_json, :symbolize_keys => true)
53
+ end
54
+
55
+ def succeed_to_load_users
56
+ stub_get(%r{/v2/organizations/[^\/]+/users\?inline-relations-depth=1}, {}, response(200, users_fixture))
57
+ end
58
+
59
+ def spaces_fixture
60
+ Helper.load_fixtures("fake_cc_organization_spaces")
61
+ end
62
+
63
+ def space_fixture_hash
64
+ MultiJson.load(spaces_fixture["resources"].first.to_json, :symbolize_keys => true)
65
+ end
66
+
67
+ def succeed_to_load_spaces
68
+ stub_get(%r{/v2/organizations/[^\/]+/spaces\?inline-relations-depth=1}, {}, response(200, spaces_fixture))
69
+ end
70
+
71
+ private
72
+
73
+ def object_endpoint(id = nil)
74
+ %r{/v2/organizations/#{id}[^/]+$}
75
+ end
76
+
77
+ def collection_endpoint
78
+ %r{/v2/organizations\/?(\?.+)?$}
79
+ end
80
+ end
81
+ end
82
+ end