ncfoundry 4.9.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,282 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe Organization do
6
+ let(:client) { build(:client) }
7
+ let(:organization) { build(:organization, :client => client) }
8
+
9
+ it_behaves_like "a summarizeable model" do
10
+ subject { organization }
11
+ let(:summary_attributes) { {:name => "fizzbuzz"} }
12
+ end
13
+
14
+ it "has quota_definition" do
15
+ quota = build(:quota_definition)
16
+ organization.quota_definition = quota
17
+ expect(organization.quota_definition).to eq(quota)
18
+ end
19
+
20
+ it "has billing_enabled" do
21
+ [true, false].each do |v|
22
+ organization.billing_enabled = v
23
+ expect(organization.billing_enabled).to eq(v)
24
+ end
25
+ end
26
+
27
+ describe "#delete_user_from_all_roles" do
28
+ let(:user) { build(:user) }
29
+ let(:organization) do
30
+ build(:organization, client: client, users: [user],
31
+ managers: [user], billing_managers: [user], auditors: [user])
32
+ end
33
+
34
+ let(:status) { 201 }
35
+
36
+ let(:delete_from_org_response) do
37
+ <<-json
38
+ {
39
+ "metadata": {
40
+ "guid": "24113d03-204b-4d23-b320-4127ee9c0006",
41
+ "url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006",
42
+ "created_at": "2013-08-17T00:47:03+00:00",
43
+ "updated_at": "2013-08-17T00:47:04+00:00"
44
+ },
45
+ "entity": {
46
+ "name": "dsabeti-the-org",
47
+ "billing_enabled": false,
48
+ "quota_definition_guid": "b72b1acb-ff4f-468d-99c0-05cd91012b62",
49
+ "status": "active",
50
+ "quota_definition_url": "/v2/quota_definitions/b72b1acb-ff4f-468d-99c0-05cd91012b62",
51
+ "spaces_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/spaces",
52
+ "domains_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/domains",
53
+ "users_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/users",
54
+ "managers_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/managers",
55
+ "billing_managers_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/billing_managers",
56
+ "auditors_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/auditors",
57
+ "app_events_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006/app_events"
58
+ }
59
+ }
60
+ json
61
+ end
62
+
63
+ let(:delete_from_space_response) do
64
+ <<-json
65
+ {
66
+ "metadata": {
67
+ "guid": "6825e318-7a3f-4d50-a2a9-dd7088c95347",
68
+ "url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347",
69
+ "created_at": "2013-10-18T00:54:34+00:00",
70
+ "updated_at": null
71
+ },
72
+ "entity": {
73
+ "name": "asdf",
74
+ "organization_guid": "24113d03-204b-4d23-b320-4127ee9c0006",
75
+ "organization_url": "/v2/organizations/24113d03-204b-4d23-b320-4127ee9c0006",
76
+ "developers_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/developers",
77
+ "managers_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/managers",
78
+ "auditors_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/auditors",
79
+ "apps_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/apps",
80
+ "domains_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/domains",
81
+ "service_instances_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/service_instances",
82
+ "app_events_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/app_events",
83
+ "events_url": "/v2/spaces/6825e318-7a3f-4d50-a2a9-dd7088c95347/events"
84
+ }
85
+ }
86
+ json
87
+ end
88
+
89
+ let(:space1) do
90
+ build(:space, organization: organization,
91
+ developers: [user], auditors: [user], managers: [user])
92
+ end
93
+
94
+ let(:space2) do
95
+ build(:space, organization: organization,
96
+ developers: [user], auditors: [user], managers: [user])
97
+ end
98
+
99
+ before do
100
+ allow(organization).to receive(:spaces).and_return([space1, space2])
101
+
102
+ stub_request(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/users/#{user.guid}").to_return(status: status, body: delete_from_org_response)
103
+ stub_request(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/managers/#{user.guid}").to_return(status: status, body: delete_from_org_response)
104
+ stub_request(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/billing_managers/#{user.guid}").to_return(status: status, body: delete_from_org_response)
105
+ stub_request(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/auditors/#{user.guid}").to_return(status: status, body: delete_from_org_response)
106
+
107
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/developers/#{user.guid}").to_return(status: status, body: delete_from_space_response)
108
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/managers/#{user.guid}").to_return(status: status, body: delete_from_space_response)
109
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/auditors/#{user.guid}").to_return(status: status, body: delete_from_space_response)
110
+
111
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/developers/#{user.guid}").to_return(status: status, body: delete_from_space_response)
112
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/managers/#{user.guid}").to_return(status: status, body: delete_from_space_response)
113
+ stub_request(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/auditors/#{user.guid}").to_return(status: status, body: delete_from_space_response)
114
+ end
115
+
116
+ it "removes the given user from all roles in the org and all its spaces" do
117
+ organization.delete_user_from_all_roles(user)
118
+
119
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/users/#{user.guid}")
120
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/managers/#{user.guid}")
121
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/billing_managers/#{user.guid}")
122
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/organizations/#{organization.guid}/auditors/#{user.guid}")
123
+
124
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/auditors/#{user.guid}")
125
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/managers/#{user.guid}")
126
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space1.guid}/developers/#{user.guid}")
127
+
128
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/auditors/#{user.guid}")
129
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/managers/#{user.guid}")
130
+ expect(WebMock).to have_requested(:delete, "http://api.example.com/v2/spaces/#{space2.guid}/developers/#{user.guid}")
131
+ end
132
+ end
133
+
134
+ describe "#add_manager_by_username" do
135
+ let(:user) { build(:user) }
136
+ let(:organization) do
137
+ build(:organization, client: client, users: [],
138
+ managers: [], billing_managers: [], auditors: [])
139
+ end
140
+
141
+ let(:status) { 201 }
142
+
143
+ let(:add_manager_org_response) do
144
+ <<-json
145
+ {
146
+ "metadata": {
147
+ "guid": "8d2238e2-2fb3-4ede-b188-1fd3a533c4b4",
148
+ "url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4",
149
+ "created_at": "2015-11-30T23:38:59Z",
150
+ "updated_at": null
151
+ },
152
+ "entity": {
153
+ "name": "name-2523",
154
+ "billing_enabled": false,
155
+ "quota_definition_guid": "0e36ae22-a752-4e37-9dbf-0bac5c1b93c1",
156
+ "status": "active",
157
+ "quota_definition_url": "/v2/quota_definitions/0e36ae22-a752-4e37-9dbf-0bac5c1b93c1",
158
+ "spaces_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/spaces",
159
+ "domains_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/domains",
160
+ "private_domains_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/private_domains",
161
+ "users_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/users",
162
+ "managers_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/managers",
163
+ "billing_managers_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/billing_managers",
164
+ "auditors_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/auditors",
165
+ "app_events_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/app_events",
166
+ "space_quota_definitions_url": "/v2/organizations/8d2238e2-2fb3-4ede-b188-1fd3a533c4b4/space_quota_definitions"
167
+ }
168
+ }
169
+ json
170
+ end
171
+
172
+ before do
173
+ allow(user).to receive(:username).and_return("user_1")
174
+ stub_request(:put, "http://api.example.com/v2/organizations/#{organization.guid}/managers").to_return(status: status, body: add_manager_org_response)
175
+ end
176
+
177
+ it "adds the given user to OrgManager in the org" do
178
+ organization.add_manager_by_username("user_1")
179
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/organizations/#{organization.guid}/managers")
180
+ end
181
+ end
182
+
183
+ describe "#add_billing_manager_by_username" do
184
+ let(:user) { build(:user) }
185
+ let(:organization) do
186
+ build(:organization, client: client, users: [],
187
+ managers: [], billing_managers: [], auditors: [])
188
+ end
189
+
190
+ let(:status) { 201 }
191
+
192
+ let(:add_billing_manager_org_response) do
193
+ <<-json
194
+ {
195
+ "metadata": {
196
+ "guid": "c8d4f13c-8880-4859-8e03-fc690efd8f48",
197
+ "url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48",
198
+ "created_at": "2015-11-30T23:38:58Z",
199
+ "updated_at": null
200
+ },
201
+ "entity": {
202
+ "name": "name-2470",
203
+ "billing_enabled": false,
204
+ "quota_definition_guid": "4ad7378e-e90a-4714-b906-a451dd0d5507",
205
+ "status": "active",
206
+ "quota_definition_url": "/v2/quota_definitions/4ad7378e-e90a-4714-b906-a451dd0d5507",
207
+ "spaces_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/spaces",
208
+ "domains_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/domains",
209
+ "private_domains_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/private_domains",
210
+ "users_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/users",
211
+ "managers_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/managers",
212
+ "billing_managers_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/billing_managers",
213
+ "auditors_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/auditors",
214
+ "app_events_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/app_events",
215
+ "space_quota_definitions_url": "/v2/organizations/c8d4f13c-8880-4859-8e03-fc690efd8f48/space_quota_definitions"
216
+ }
217
+ }
218
+ json
219
+ end
220
+
221
+ before do
222
+ allow(user).to receive(:username).and_return("user_1")
223
+ stub_request(:put, "http://api.example.com/v2/organizations/#{organization.guid}/billing_managers").to_return(status: status, body: add_billing_manager_org_response)
224
+ end
225
+
226
+ it "adds the given user to OrgBillingMnager in the org" do
227
+ organization.add_billing_manager_by_username("user_1")
228
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/organizations/#{organization.guid}/billing_managers")
229
+ end
230
+ end
231
+
232
+ describe "#add_auditor_by_username" do
233
+ let(:user) { build(:user) }
234
+ let(:organization) do
235
+ build(:organization, client: client, users: [],
236
+ managers: [], billing_managers: [], auditors: [])
237
+ end
238
+
239
+ let(:status) { 201 }
240
+
241
+ let(:add_auditor_org_response) do
242
+ <<-json
243
+ {
244
+ "metadata": {
245
+ "guid": "50dfb04d-cd49-477d-a54c-32e00e180022",
246
+ "url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022",
247
+ "created_at": "2015-11-30T23:38:58Z",
248
+ "updated_at": null
249
+ },
250
+ "entity": {
251
+ "name": "name-2476",
252
+ "billing_enabled": false,
253
+ "quota_definition_guid": "8de0754e-bb1e-4739-be6e-91104bbab281",
254
+ "status": "active",
255
+ "quota_definition_url": "/v2/quota_definitions/8de0754e-bb1e-4739-be6e-91104bbab281",
256
+ "spaces_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/spaces",
257
+ "domains_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/domains",
258
+ "private_domains_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/private_domains",
259
+ "users_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/users",
260
+ "managers_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/managers",
261
+ "billing_managers_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/billing_managers",
262
+ "auditors_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/auditors",
263
+ "app_events_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/app_events",
264
+ "space_quota_definitions_url": "/v2/organizations/50dfb04d-cd49-477d-a54c-32e00e180022/space_quota_definitions"
265
+ }
266
+ }
267
+ json
268
+ end
269
+
270
+ before do
271
+ allow(user).to receive(:username).and_return("user_1")
272
+ stub_request(:put, "http://api.example.com/v2/organizations/#{organization.guid}/auditors").to_return(status: status, body: add_auditor_org_response)
273
+ end
274
+
275
+ it "adds the given user to OrgAuditor in the org" do
276
+ organization.add_auditor_by_username("user_1")
277
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/organizations/#{organization.guid}/auditors")
278
+ end
279
+ end
280
+ end
281
+ end
282
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe QuotaDefinition do
6
+ let(:quota_definition) { build(:quota_definition) }
7
+
8
+ it "has guid" do
9
+ quota_definition.guid = "quota-definition-1"
10
+ expect(quota_definition.guid).to eq("quota-definition-1")
11
+ end
12
+
13
+ it "has name" do
14
+ quota_definition.name = "name"
15
+ expect(quota_definition.name).to eq("name")
16
+ end
17
+
18
+ it "has non_basic_services_allowed" do
19
+ [true, false].each do |v|
20
+ quota_definition.non_basic_services_allowed = v
21
+ expect(quota_definition.non_basic_services_allowed).to eq(v)
22
+ end
23
+ end
24
+
25
+ it "has total_services" do
26
+ [0, 1].each do |v|
27
+ quota_definition.total_services = v
28
+ expect(quota_definition.total_services).to eq(v)
29
+ end
30
+ end
31
+
32
+ it "has total_services" do
33
+ [0, 1].each do |v|
34
+ quota_definition.total_services = v
35
+ expect(quota_definition.total_services).to eq(v)
36
+ end
37
+ end
38
+
39
+ describe "querying" do
40
+ let(:client) { build(:client) }
41
+
42
+ it "is queryable by name" do
43
+ expect(client).to receive(:quota_definitions).with({:query=>[:name, "quota-name"]}) {[]}
44
+
45
+ client.quota_definition_by_name("quota-name")
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ module CFoundry
5
+ module V2
6
+ describe Route do
7
+ let(:route) { build(:route) }
8
+ subject { route }
9
+
10
+ describe "validations" do
11
+ it { should validate_presence_of(:domain) }
12
+ it { should validate_presence_of(:space) }
13
+
14
+ # http://tools.ietf.org/html/rfc1035
15
+ it "only allows host names according to RFC1035" do
16
+ message = "can only include a-z, 0-9 and -"
17
+
18
+ expect(route).to allow_value("a", "starts-with-letter", "includes-9-digits", "ends-with-letter",
19
+ "ends-with-digit-9", "can--have--consecutive---dashes", "allows-UPPERCASE-chars").for(:host)
20
+
21
+ ["-must-start-with-letter", "9must-start-with-letter", "must-not-end-with-dash-", "must-not-include-punctuation-chars-@\#$%^&*()",
22
+ "must-not-include-special-chars-ä", "must.not.include.dots"].each do |bad_value|
23
+ expect(route).not_to allow_value(bad_value).for(:host).with_message(message)
24
+ end
25
+
26
+ expect(route).to ensure_length_of(:host).is_at_most(63)
27
+ end
28
+ end
29
+
30
+ describe "errors" do
31
+ before do
32
+ allow(route).to receive(:create!) { raise CFoundry::RouteHostTaken.new("the host is taken", 210003) }
33
+ end
34
+
35
+ it "populates errors on host" do
36
+ route.create
37
+ expect(route.errors[:host].first).to match(/the host is taken/i)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,53 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe ServicePlan do
6
+ let(:client) { build(:client) }
7
+
8
+ subject do
9
+ build(:service_plan)
10
+ end
11
+
12
+ before :each do
13
+ stub_request(:get, /\/service_plans\/service-plan-guid-\d{1,2}/).to_return :status => 200,
14
+ :headers => {'Content-Type' => 'application/json'},
15
+ :body => <<EOF
16
+ {
17
+ "metadata": {
18
+ "guid": "d1251ac1-fe42-4b4a-84d4-e31e95b547d8",
19
+ "url": "/v2/service_plans/d1251ac1-fe42-4b4a-84d4-e31e95b547d8",
20
+ "created_at": "2013-08-28T12:28:35+04:00",
21
+ "updated_at": "2013-08-28T12:33:27+04:00"
22
+ },
23
+ "entity": {
24
+ "name": "free",
25
+ "free": true,
26
+ "description": "free as in beer",
27
+ "unique_id": "0aa2f82c-6918-41df-b676-c275b5954ed7",
28
+ "extra": "",
29
+ "public": true
30
+ }
31
+ }
32
+ EOF
33
+ end
34
+
35
+ let(:uuid) { "4692e0ca-25ed-495e-9ae1-fcb0bcf26a96" }
36
+
37
+ it "has unique_id that can be mutated" do
38
+ expect(subject.unique_id).to eq("0aa2f82c-6918-41df-b676-c275b5954ed7")
39
+
40
+ subject.unique_id = uuid
41
+ expect(subject.unique_id).to eq(uuid)
42
+ end
43
+
44
+ it "has free/paid indicator attribute" do
45
+ expect(subject.free).to be_truthy
46
+ end
47
+
48
+ it "has a boolean 'public' attribute" do
49
+ expect(subject.public).to be_truthy
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe Service do
6
+ let(:client) { build(:client) }
7
+
8
+ subject do
9
+ build(:service)
10
+ end
11
+
12
+ before :each do
13
+ stub_request(:get, /\/services\/service-guid-\d{1,2}/).to_return :status => 200,
14
+ :headers => {'Content-Type' => 'application/json'},
15
+ :body => <<EOF
16
+ {
17
+ "metadata": {
18
+ "guid": "d1251ac1-fe42-4b4a-84d4-e31e95b547d8",
19
+ "url": "/v2/services/d1251ac1-fe42-4b4a-84d4-e31e95b547d8",
20
+ "created_at": "2013-08-28T12:28:35+04:00",
21
+ "updated_at": "2013-08-28T12:33:27+04:00"
22
+ },
23
+ "entity": {
24
+ "label": "rabbitmq",
25
+ "provider": "rabbitherd",
26
+ "url": "http://rabbitmq.com",
27
+ "description": "RabbitMQ service",
28
+ "version": "1.0",
29
+ "info_url": null,
30
+ "active": true,
31
+ "bindable": true,
32
+ "unique_id": "0aa2f82c-6918-41df-b676-c275b5954ed7",
33
+ "extra": "",
34
+ "tags": [
35
+
36
+ ],
37
+ "documentation_url": null,
38
+ "service_plans_url": "/v2/services/d1251ac1-fe42-4b4a-84d4-e31e95b547d8/service_plans"
39
+ }
40
+ }
41
+ EOF
42
+ end
43
+
44
+ let(:uuid) { "4692e0ca-25ed-495e-9ae1-fcb0bcf26a96" }
45
+
46
+ it "has unique_id that can be mutated" do
47
+ expect(subject.unique_id).to eq("0aa2f82c-6918-41df-b676-c275b5954ed7")
48
+
49
+ subject.unique_id = uuid
50
+ expect(subject.unique_id).to eq(uuid)
51
+ end
52
+
53
+ it "has tags" do
54
+ expect(subject.tags).to eq([])
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,160 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe Space do
6
+ let(:client) { build(:client) }
7
+ let(:space) { build(:space, :client => client) }
8
+
9
+ it_behaves_like "a summarizeable model" do
10
+ subject { space }
11
+ let(:summary_attributes) { {:name => "fizzbuzz"} }
12
+ end
13
+
14
+ describe "#add_manager_by_username" do
15
+ let(:user) { build(:user) }
16
+ let(:status) { 201 }
17
+
18
+ let(:add_manager_space_response) do
19
+ <<-json
20
+ {
21
+ "metadata": {
22
+ "guid": "4351f97b-3485-4738-821b-5bf77bed44eb",
23
+ "url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb",
24
+ "created_at": "2015-11-30T23:38:28Z",
25
+ "updated_at": null
26
+ },
27
+ "entity": {
28
+ "name": "name-98",
29
+ "organization_guid": "a488910d-2d69-46a2-bf6e-319248e03705",
30
+ "space_quota_definition_guid": null,
31
+ "allow_ssh": true,
32
+ "organization_url": "/v2/organizations/a488910d-2d69-46a2-bf6e-319248e03705",
33
+ "developers_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/developers",
34
+ "managers_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/managers",
35
+ "auditors_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/auditors",
36
+ "apps_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/apps",
37
+ "routes_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/routes",
38
+ "domains_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/domains",
39
+ "service_instances_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/service_instances",
40
+ "app_events_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/app_events",
41
+ "events_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/events",
42
+ "security_groups_url": "/v2/spaces/4351f97b-3485-4738-821b-5bf77bed44eb/security_groups"
43
+ }
44
+ }
45
+ json
46
+ end
47
+
48
+ before do
49
+ allow(user).to receive(:username).and_return("user_1")
50
+ stub_request(:put, "http://api.example.com/v2/spaces/#{space.guid}/managers").to_return(status: status, body: add_manager_space_response)
51
+ end
52
+
53
+ it "adds the given user to SpaceManager in the space" do
54
+ space.add_manager_by_username("user_1")
55
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/spaces/#{space.guid}/managers")
56
+ end
57
+ end
58
+
59
+ describe "#add_auditor_by_username" do
60
+ let(:user) { build(:user) }
61
+ let(:status) { 201 }
62
+
63
+ let(:add_auditor_space_response) do
64
+ <<-json
65
+ {
66
+ "metadata": {
67
+ "guid": "873193ee-878c-436f-80bd-10d68927937d",
68
+ "url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d",
69
+ "created_at": "2015-11-30T23:38:28Z",
70
+ "updated_at": null
71
+ },
72
+ "entity": {
73
+ "name": "name-101",
74
+ "organization_guid": "5fddaf61-092d-4b33-9490-8350963db89e",
75
+ "space_quota_definition_guid": null,
76
+ "allow_ssh": true,
77
+ "organization_url": "/v2/organizations/5fddaf61-092d-4b33-9490-8350963db89e",
78
+ "developers_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/developers",
79
+ "managers_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/managers",
80
+ "auditors_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/auditors",
81
+ "apps_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/apps",
82
+ "routes_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/routes",
83
+ "domains_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/domains",
84
+ "service_instances_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/service_instances",
85
+ "app_events_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/app_events",
86
+ "events_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/events",
87
+ "security_groups_url": "/v2/spaces/873193ee-878c-436f-80bd-10d68927937d/security_groups"
88
+ }
89
+ }
90
+ json
91
+ end
92
+
93
+ before do
94
+ allow(user).to receive(:username).and_return("user_1")
95
+ stub_request(:put, "http://api.example.com/v2/spaces/#{space.guid}/auditors").to_return(status: status, body: add_auditor_space_response)
96
+ end
97
+
98
+ it "adds the given user to SpaceAuditor in the space" do
99
+ space.add_auditor_by_username("user_1")
100
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/spaces/#{space.guid}/auditors")
101
+ end
102
+ end
103
+
104
+ describe "#add_developer_by_username" do
105
+ let(:user) { build(:user) }
106
+ let(:status) { 201 }
107
+
108
+ let(:add_developer_space_response) do
109
+ <<-json
110
+ {
111
+ "metadata": {
112
+ "guid": "b6d11f17-1cea-4c00-a951-fef3223b8c84",
113
+ "url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84",
114
+ "created_at": "2015-11-30T23:38:27Z",
115
+ "updated_at": null
116
+ },
117
+ "entity": {
118
+ "name": "name-58",
119
+ "organization_guid": "b13bbebe-427e-424d-8820-2937f7e218d5",
120
+ "space_quota_definition_guid": null,
121
+ "allow_ssh": true,
122
+ "organization_url": "/v2/organizations/b13bbebe-427e-424d-8820-2937f7e218d5",
123
+ "developers_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/developers",
124
+ "managers_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/managers",
125
+ "auditors_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/auditors",
126
+ "apps_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/apps",
127
+ "routes_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/routes",
128
+ "domains_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/domains",
129
+ "service_instances_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/service_instances",
130
+ "app_events_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/app_events",
131
+ "events_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/events",
132
+ "security_groups_url": "/v2/spaces/b6d11f17-1cea-4c00-a951-fef3223b8c84/security_groups"
133
+ }
134
+ }
135
+ json
136
+ end
137
+
138
+ before do
139
+ allow(user).to receive(:username).and_return("user_1")
140
+ stub_request(:put, "http://api.example.com/v2/spaces/#{space.guid}/developers").to_return(status: status, body: add_developer_space_response)
141
+ end
142
+
143
+ it "adds the given user to SpaceDeveloper in the space" do
144
+ space.add_developer_by_username("user_1")
145
+ expect(WebMock).to have_requested(:put, "http://api.example.com/v2/spaces/#{space.guid}/developers")
146
+ end
147
+ end
148
+
149
+ describe "#list_routes_for_space" do
150
+ let(:domain) { build(:domain, :name => "my-domain") }
151
+ let(:route) { build(:route, :domain => domain) }
152
+
153
+ it "returns the domain that the user has specified" do
154
+ allow(space).to receive(:routes).and_return([route])
155
+ expect(space.routes[0].domain.name).to eq("my-domain")
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end