ncfoundry 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/Checkfile +2 -0
- data/Gemfile +3 -0
- data/LICENSE +987 -0
- data/NOTICE +10 -0
- data/README.md +9 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/cfoundry.gemspec +41 -0
- data/config/locales/en.yml +168 -0
- data/lib/cc_api_stub/app_usage_events.rb +11 -0
- data/lib/cc_api_stub/applications.rb +57 -0
- data/lib/cc_api_stub/domains.rb +32 -0
- data/lib/cc_api_stub/events.rb +11 -0
- data/lib/cc_api_stub/frameworks.rb +22 -0
- data/lib/cc_api_stub/helper.rb +148 -0
- data/lib/cc_api_stub/login.rb +21 -0
- data/lib/cc_api_stub/organization_users.rb +27 -0
- data/lib/cc_api_stub/organizations.rb +82 -0
- data/lib/cc_api_stub/routes.rb +26 -0
- data/lib/cc_api_stub/runtimes.rb +22 -0
- data/lib/cc_api_stub/service_bindings.rb +22 -0
- data/lib/cc_api_stub/service_instances.rb +22 -0
- data/lib/cc_api_stub/services.rb +21 -0
- data/lib/cc_api_stub/space_users.rb +27 -0
- data/lib/cc_api_stub/spaces.rb +58 -0
- data/lib/cc_api_stub/users.rb +85 -0
- data/lib/cc_api_stub.rb +20 -0
- data/lib/cfoundry/auth_token.rb +62 -0
- data/lib/cfoundry/baseclient.rb +220 -0
- data/lib/cfoundry/chatty_hash.rb +46 -0
- data/lib/cfoundry/client.rb +42 -0
- data/lib/cfoundry/concerns/login_helpers.rb +14 -0
- data/lib/cfoundry/concerns/proxy_options.rb +14 -0
- data/lib/cfoundry/errors.rb +163 -0
- data/lib/cfoundry/rest_client.rb +316 -0
- data/lib/cfoundry/test_support.rb +3 -0
- data/lib/cfoundry/trace_helpers.rb +64 -0
- data/lib/cfoundry/uaaclient.rb +151 -0
- data/lib/cfoundry/upload_helpers.rb +222 -0
- data/lib/cfoundry/v2/app.rb +313 -0
- data/lib/cfoundry/v2/app_event.rb +13 -0
- data/lib/cfoundry/v2/app_instance.rb +74 -0
- data/lib/cfoundry/v2/app_usage_event.rb +14 -0
- data/lib/cfoundry/v2/base.rb +112 -0
- data/lib/cfoundry/v2/client.rb +104 -0
- data/lib/cfoundry/v2/domain.rb +20 -0
- data/lib/cfoundry/v2/event.rb +17 -0
- data/lib/cfoundry/v2/helper.rb +11 -0
- data/lib/cfoundry/v2/managed_service_instance.rb +13 -0
- data/lib/cfoundry/v2/model.rb +213 -0
- data/lib/cfoundry/v2/model_magic/attribute.rb +49 -0
- data/lib/cfoundry/v2/model_magic/client_extensions.rb +170 -0
- data/lib/cfoundry/v2/model_magic/has_summary.rb +49 -0
- data/lib/cfoundry/v2/model_magic/query_multi_value_helper.rb +21 -0
- data/lib/cfoundry/v2/model_magic/query_value_helper.rb +33 -0
- data/lib/cfoundry/v2/model_magic/queryable_by.rb +39 -0
- data/lib/cfoundry/v2/model_magic/to_many.rb +145 -0
- data/lib/cfoundry/v2/model_magic/to_one.rb +81 -0
- data/lib/cfoundry/v2/model_magic.rb +134 -0
- data/lib/cfoundry/v2/organization.rb +44 -0
- data/lib/cfoundry/v2/quota_definition.rb +12 -0
- data/lib/cfoundry/v2/route.rb +25 -0
- data/lib/cfoundry/v2/service.rb +22 -0
- data/lib/cfoundry/v2/service_auth_token.rb +9 -0
- data/lib/cfoundry/v2/service_binding.rb +10 -0
- data/lib/cfoundry/v2/service_broker.rb +12 -0
- data/lib/cfoundry/v2/service_instance.rb +14 -0
- data/lib/cfoundry/v2/service_plan.rb +16 -0
- data/lib/cfoundry/v2/space.rb +31 -0
- data/lib/cfoundry/v2/stack.rb +10 -0
- data/lib/cfoundry/v2/user.rb +97 -0
- data/lib/cfoundry/v2/user_provided_service_instance.rb +16 -0
- data/lib/cfoundry/validator.rb +41 -0
- data/lib/cfoundry/version.rb +4 -0
- data/lib/cfoundry/zip.rb +56 -0
- data/lib/cfoundry.rb +6 -0
- data/release_notes/release_1_5_3.md +177 -0
- data/release_notes/release_2.3.1.md +14 -0
- data/release_notes/release_2.3.3.md +38 -0
- data/release_notes/release_2.3.4.md +16 -0
- data/release_notes/release_2.3.5.md +14 -0
- data/release_notes/release_2.3.6.md +14 -0
- data/release_notes/release_2.3.6.rc1.md +29 -0
- data/release_notes/release_2.3.6.rc2.md +19 -0
- data/release_notes/release_2.3.7.rc1.md +14 -0
- data/release_notes/release_2.4.0.md +41 -0
- data/release_notes/release_2.4.1.rc1.md +58 -0
- data/release_notes/release_3.0.0.md +21 -0
- data/release_notes/release_3.0.1.md +16 -0
- data/release_notes/release_3.0.2.rc1.md +19 -0
- data/release_notes/release_4.0.0.md +19 -0
- data/release_notes/release_4.0.1.md +14 -0
- data/release_notes/release_4.0.2.rc1.md +14 -0
- data/release_notes/release_4.0.2.rc2.md +11 -0
- data/release_notes/release_4.0.2.rc3.md +11 -0
- data/release_notes/release_4.0.2.rc4.md +19 -0
- data/release_notes/release_4.0.2.rc5.md +14 -0
- data/release_notes/release_4.0.3.md +19 -0
- data/release_notes/release_4.0.4.rc1.md +14 -0
- data/release_notes/release_4.0.4.rc2.md +14 -0
- data/release_notes/release_4.1.0.md +19 -0
- data/release_notes/release_4.2.0.rc.md +24 -0
- data/release_notes/release_4.3.0.md +22 -0
- data/release_notes/release_4.3.1.md +14 -0
- data/release_notes/release_4.3.10.md +14 -0
- data/release_notes/release_4.3.11.md +14 -0
- data/release_notes/release_4.3.12.md +14 -0
- data/release_notes/release_4.3.2.rc1.md +21 -0
- data/release_notes/release_4.3.3.md +24 -0
- data/release_notes/release_4.3.4.md +11 -0
- data/release_notes/release_4.3.4.rc1.md +24 -0
- data/release_notes/release_4.3.5.md +36 -0
- data/release_notes/release_4.3.5.rc1.md +21 -0
- data/release_notes/release_4.3.6.md +14 -0
- data/release_notes/release_4.3.7.md +50 -0
- data/release_notes/release_4.3.8.md +19 -0
- data/release_notes/release_4.3.9.md +14 -0
- data/release_notes/release_4.4.0.md +16 -0
- data/release_notes/release_4.5.1.md +11 -0
- data/release_notes/release_4.5.2.md +14 -0
- data/release_notes/release_4.5.3.md +29 -0
- data/release_notes/release_4.6.0.md +24 -0
- data/release_notes/release_4.6.1.md +14 -0
- data/release_notes/release_4.6.2.md +16 -0
- data/release_notes/release_4.6.3.rc1.md +14 -0
- data/release_notes/release_4.6.3.rc2.md +14 -0
- data/release_notes/release_4.6.3.rc3.md +17 -0
- data/release_notes/release_4.7.0.md +11 -0
- data/release_notes/release_4.7.1.md +14 -0
- data/release_notes/release_4.7.1.rc.1.md +14 -0
- data/release_notes/release_4.7.1.rc1.md +19 -0
- data/script/gpp +3 -0
- data/spec/cc_api_stub/app_usage_events_spec.rb +12 -0
- data/spec/cc_api_stub/applications_spec.rb +69 -0
- data/spec/cc_api_stub/domains_spec.rb +40 -0
- data/spec/cc_api_stub/events_spec.rb +12 -0
- data/spec/cc_api_stub/frameworks_spec.rb +19 -0
- data/spec/cc_api_stub/login_spec.rb +20 -0
- data/spec/cc_api_stub/organization_users_spec.rb +35 -0
- data/spec/cc_api_stub/organizations_spec.rb +118 -0
- data/spec/cc_api_stub/routes_spec.rb +19 -0
- data/spec/cc_api_stub/runtimes_spec.rb +19 -0
- data/spec/cc_api_stub/service_bindings_spec.rb +13 -0
- data/spec/cc_api_stub/service_instances_spec.rb +19 -0
- data/spec/cc_api_stub/services_spec.rb +11 -0
- data/spec/cc_api_stub/space_users_spec.rb +35 -0
- data/spec/cc_api_stub/spaces_spec.rb +38 -0
- data/spec/cc_api_stub/users_spec.rb +107 -0
- data/spec/cfoundry/auth_token_spec.rb +153 -0
- data/spec/cfoundry/baseclient_spec.rb +284 -0
- data/spec/cfoundry/client_spec.rb +13 -0
- data/spec/cfoundry/errors_spec.rb +117 -0
- data/spec/cfoundry/rest_client_spec.rb +367 -0
- data/spec/cfoundry/trace_helpers_spec.rb +91 -0
- data/spec/cfoundry/uaaclient_spec.rb +421 -0
- data/spec/cfoundry/upload_helpers_spec.rb +182 -0
- data/spec/cfoundry/v2/app_event_spec.rb +97 -0
- data/spec/cfoundry/v2/app_instance_spec.rb +31 -0
- data/spec/cfoundry/v2/app_spec.rb +354 -0
- data/spec/cfoundry/v2/app_usage_event_spec.rb +15 -0
- data/spec/cfoundry/v2/base_spec.rb +375 -0
- data/spec/cfoundry/v2/client_spec.rb +121 -0
- data/spec/cfoundry/v2/domain_spec.rb +63 -0
- data/spec/cfoundry/v2/event_spec.rb +15 -0
- data/spec/cfoundry/v2/managed_service_instance_spec.rb +149 -0
- data/spec/cfoundry/v2/model_magic/attribute_spec.rb +123 -0
- data/spec/cfoundry/v2/model_magic/has_summary_spec.rb +17 -0
- data/spec/cfoundry/v2/model_magic/to_many_spec.rb +53 -0
- data/spec/cfoundry/v2/model_magic/to_one_spec.rb +106 -0
- data/spec/cfoundry/v2/model_magic_spec.rb +43 -0
- data/spec/cfoundry/v2/model_spec.rb +472 -0
- data/spec/cfoundry/v2/organization_spec.rb +282 -0
- data/spec/cfoundry/v2/quota_definition_spec.rb +50 -0
- data/spec/cfoundry/v2/route_spec.rb +42 -0
- data/spec/cfoundry/v2/service_plan_spec.rb +53 -0
- data/spec/cfoundry/v2/service_spec.rb +58 -0
- data/spec/cfoundry/v2/space_spec.rb +160 -0
- data/spec/cfoundry/v2/user_provided_service_instance_spec.rb +57 -0
- data/spec/cfoundry/v2/user_spec.rb +206 -0
- data/spec/cfoundry/validator_spec.rb +94 -0
- data/spec/factories/app_events_factory.rb +7 -0
- data/spec/factories/app_usage_events_factory.rb +32 -0
- data/spec/factories/apps_factory.rb +11 -0
- data/spec/factories/clients_factory.rb +7 -0
- data/spec/factories/domains_factory.rb +10 -0
- data/spec/factories/events_factory.rb +50 -0
- data/spec/factories/organizations_factory.rb +12 -0
- data/spec/factories/quota_definitions_factory.rb +8 -0
- data/spec/factories/routes_factory.rb +10 -0
- data/spec/factories/service_instances_factory.rb +10 -0
- data/spec/factories/service_plans_factory.rb +10 -0
- data/spec/factories/services_factory.rb +10 -0
- data/spec/factories/spaces_factory.rb +10 -0
- data/spec/factories/user_provided_service_instances_factory.rb +10 -0
- data/spec/factories/users_factory.rb +10 -0
- data/spec/fixtures/apps/with_cfignore/.cfignore +4 -0
- data/spec/fixtures/apps/with_cfignore/.hidden_file +1 -0
- data/spec/fixtures/apps/with_cfignore/ambiguous_ignored +0 -0
- data/spec/fixtures/apps/with_cfignore/ignored_dir/file_in_ignored_dir.txt +1 -0
- data/spec/fixtures/apps/with_cfignore/ignored_file.txt +1 -0
- data/spec/fixtures/apps/with_cfignore/non_ignored_dir/file_in_non_ignored_dir.txt +1 -0
- data/spec/fixtures/apps/with_cfignore/non_ignored_dir/ignored_file.txt +1 -0
- data/spec/fixtures/apps/with_cfignore/non_ignored_dir/toplevel_ignored.txt +0 -0
- data/spec/fixtures/apps/with_cfignore/non_ignored_file.txt +1 -0
- data/spec/fixtures/apps/with_cfignore/toplevel_ignored.txt +0 -0
- data/spec/fixtures/apps/with_dotfiles/.dotfile +1 -0
- data/spec/fixtures/apps/with_dotfiles/xyz +1 -0
- data/spec/fixtures/apps/with_external_symlink/foo +1 -0
- data/spec/fixtures/apps/with_ignored_external_symlink/.cfignore +1 -0
- data/spec/fixtures/apps/with_ignored_external_symlink/foo +1 -0
- data/spec/fixtures/apps/with_nested_directories/foo/bar/baz/fizz +0 -0
- data/spec/fixtures/apps/with_nested_directories/xyz +0 -0
- data/spec/fixtures/empty_file +0 -0
- data/spec/fixtures/fake_cc_app_usage_events.json +152 -0
- data/spec/fixtures/fake_cc_application.json +20 -0
- data/spec/fixtures/fake_cc_application_summary.json +56 -0
- data/spec/fixtures/fake_cc_created_application.json +11 -0
- data/spec/fixtures/fake_cc_created_domain.json +15 -0
- data/spec/fixtures/fake_cc_created_organization.json +11 -0
- data/spec/fixtures/fake_cc_created_route.json +13 -0
- data/spec/fixtures/fake_cc_created_service_instance.json +11 -0
- data/spec/fixtures/fake_cc_created_space.json +11 -0
- data/spec/fixtures/fake_cc_created_user.json +11 -0
- data/spec/fixtures/fake_cc_domain.json +55 -0
- data/spec/fixtures/fake_cc_domain_spaces.json +27 -0
- data/spec/fixtures/fake_cc_empty_search.json +7 -0
- data/spec/fixtures/fake_cc_events.json +419 -0
- data/spec/fixtures/fake_cc_frameworks.json +20 -0
- data/spec/fixtures/fake_cc_managed_service_instance.json +83 -0
- data/spec/fixtures/fake_cc_organization.json +161 -0
- data/spec/fixtures/fake_cc_organization_domains.json +59 -0
- data/spec/fixtures/fake_cc_organization_search.json +37 -0
- data/spec/fixtures/fake_cc_organization_spaces.json +99 -0
- data/spec/fixtures/fake_cc_organization_summary.json +20 -0
- data/spec/fixtures/fake_cc_organization_users.json +81 -0
- data/spec/fixtures/fake_cc_route.json +16 -0
- data/spec/fixtures/fake_cc_runtimes.json +20 -0
- data/spec/fixtures/fake_cc_service_binding.json +22 -0
- data/spec/fixtures/fake_cc_service_bindings.json +24 -0
- data/spec/fixtures/fake_cc_service_instance.json +83 -0
- data/spec/fixtures/fake_cc_service_instances.json +72 -0
- data/spec/fixtures/fake_cc_services.json +160 -0
- data/spec/fixtures/fake_cc_space.json +45 -0
- data/spec/fixtures/fake_cc_space_apps.json +49 -0
- data/spec/fixtures/fake_cc_space_summary.json +84 -0
- data/spec/fixtures/fake_cc_spaces.json +92 -0
- data/spec/fixtures/fake_cc_stats.json +29 -0
- data/spec/fixtures/fake_cc_user.json +139 -0
- data/spec/fixtures/fake_cc_user_organizations.json +92 -0
- data/spec/fixtures/fake_cc_user_provided_service_instance.json +51 -0
- data/spec/fixtures/fake_cc_user_with_managers.json +85 -0
- data/spec/integration/client_spec.rb +38 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/shared_examples/cc_api_stub_request_examples.rb +79 -0
- data/spec/support/shared_examples/client_login_examples.rb +46 -0
- data/spec/support/shared_examples/model_summary_examples.rb +34 -0
- data/spec/support/test_model_builder.rb +10 -0
- data/vendor/errors/v1.yml +189 -0
- data/vendor/errors/v2.yml +845 -0
- metadata +712 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
{
|
2
|
+
"total_results": 3,
|
3
|
+
"total_pages": 1,
|
4
|
+
"prev_url": null,
|
5
|
+
"next_url": null,
|
6
|
+
"resources": [
|
7
|
+
{
|
8
|
+
"metadata": {
|
9
|
+
"guid": "organization-id-1",
|
10
|
+
"url": "/v2/organizations/organization-id-1"
|
11
|
+
},
|
12
|
+
"entity": {
|
13
|
+
"name": "organization-name-1",
|
14
|
+
"spaces": [{
|
15
|
+
"metadata": {
|
16
|
+
"guid": "space-id-1",
|
17
|
+
"url": "/v2/users/space-id-1"
|
18
|
+
},
|
19
|
+
"entity": {
|
20
|
+
"name": "space-name-1"
|
21
|
+
}
|
22
|
+
}],
|
23
|
+
"managers": [{
|
24
|
+
"metadata": {
|
25
|
+
"guid": "user-id-1",
|
26
|
+
"url": "/v2/users/user-id-1"
|
27
|
+
},
|
28
|
+
"entity": {
|
29
|
+
"admin": false,
|
30
|
+
"active": false,
|
31
|
+
"default_space_guid": "space-id-1"
|
32
|
+
}
|
33
|
+
}]
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"metadata": {
|
38
|
+
"guid": "two-managers-organization-id-1",
|
39
|
+
"url": "/v2/organizations/two-managers-organization-id-1"
|
40
|
+
},
|
41
|
+
"entity": {
|
42
|
+
"name": "two-managers-organization-name-1",
|
43
|
+
"managers": [
|
44
|
+
{
|
45
|
+
"metadata": {
|
46
|
+
"guid": "user-id-1",
|
47
|
+
"url": "/v2/users/user-id-1"
|
48
|
+
},
|
49
|
+
"entity": {
|
50
|
+
"admin": false,
|
51
|
+
"active": false,
|
52
|
+
"default_space_guid": "two-managers-space-id-1"
|
53
|
+
}
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"metadata": {
|
57
|
+
"guid": "other-user-id-1",
|
58
|
+
"url": "/v2/users/other-user-id-1",
|
59
|
+
"created_at": "2012-10-24 12:14:54 -0700",
|
60
|
+
"updated_at": "2012-10-24 12:16:11 -0700"
|
61
|
+
},
|
62
|
+
"entity": {
|
63
|
+
"admin": false,
|
64
|
+
"active": false,
|
65
|
+
"default_space_guid": "two-managers-space-id-1"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
]
|
69
|
+
}
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"metadata": {
|
73
|
+
"guid": "other-organization-id-1",
|
74
|
+
"url": "/v2/organizations/other-organization-id-1"
|
75
|
+
},
|
76
|
+
"entity": {
|
77
|
+
"name": "other-organization-name-1",
|
78
|
+
"managers": [{
|
79
|
+
"metadata": {
|
80
|
+
"guid": "other-user-id-1",
|
81
|
+
"url": "/v2/users/other-user-id-1"
|
82
|
+
},
|
83
|
+
"entity": {
|
84
|
+
"admin": false,
|
85
|
+
"active": false,
|
86
|
+
"default_space_guid": "other-space-id-1"
|
87
|
+
}
|
88
|
+
}]
|
89
|
+
}
|
90
|
+
}
|
91
|
+
]
|
92
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
"metadata": {
|
3
|
+
"guid": "user-provided-service-instance-id-1",
|
4
|
+
"url": "/v2/service_instances/user-provided-service-instance-id-1",
|
5
|
+
"created_at": "2012-10-23 00:00:00 +0000",
|
6
|
+
"updated_at": null
|
7
|
+
},
|
8
|
+
"entity": {
|
9
|
+
"type": "user_provided_service_instance",
|
10
|
+
"name": "service-instance-name-1",
|
11
|
+
"space_guid": "space-id-1",
|
12
|
+
"service_bindings_url": "/v2/service_instances/user-provided-service-instance-id-1/service_bindings",
|
13
|
+
"service_bindings": [
|
14
|
+
{
|
15
|
+
"metadata": {
|
16
|
+
"guid": "service-binding-id-1",
|
17
|
+
"url": "/v2/service_bindings/service-binding-id-1",
|
18
|
+
"created_at": "2012-10-23 00:34:18 +0000",
|
19
|
+
"updated_at": null
|
20
|
+
},
|
21
|
+
"entity": {
|
22
|
+
"app_guid": "application-id-1",
|
23
|
+
"service_instance_guid": "user-provided-service-instance-id-1",
|
24
|
+
"binding_options": null,
|
25
|
+
"app_url": "/v2/apps/application-id-1",
|
26
|
+
"service_instance_url": "/v2/service_instances/user-provided-service-instance-id-1"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
],
|
30
|
+
"space_url": "/v2/spaces/space-id-1",
|
31
|
+
"space": {
|
32
|
+
"metadata": {
|
33
|
+
"guid": "space-id-1",
|
34
|
+
"url": "/v2/spaces/space-id-1",
|
35
|
+
"created_at": "2012-09-26 00:00:00 +0000",
|
36
|
+
"updated_at": null
|
37
|
+
},
|
38
|
+
"entity": {
|
39
|
+
"name": "organization-name-1",
|
40
|
+
"organization_guid": "organization-id-1",
|
41
|
+
"developers_url": "/v2/spaces/space-id-1/developers",
|
42
|
+
"managers_url": "/v2/spaces/space-id-1/managers",
|
43
|
+
"auditors_url": "/v2/spaces/space-id-1/auditors",
|
44
|
+
"apps_url": "/v2/spaces/space-id-1/apps",
|
45
|
+
"domains_url": "/v2/spaces/space-id-1/domains",
|
46
|
+
"service_instances_url": "/v2/spaces/space-id-1/service_instances",
|
47
|
+
"organization_url": "/v2/organizations/organization-id-1"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
{
|
2
|
+
"metadata":{
|
3
|
+
"guid":"user-id-1",
|
4
|
+
"url":"/v2/users/user-id-1",
|
5
|
+
"created_at":"2012-08-13 12:48:41 -0700",
|
6
|
+
"updated_at":"2012-08-13 12:55:10 -0700"
|
7
|
+
},
|
8
|
+
"entity":{
|
9
|
+
"organizations":[
|
10
|
+
{
|
11
|
+
"metadata":{
|
12
|
+
"guid":"organization-id-1",
|
13
|
+
"url":"/v2/organizations/organization-id-1"
|
14
|
+
},
|
15
|
+
"entity":{
|
16
|
+
"name":"organization-name-1",
|
17
|
+
"spaces":[{
|
18
|
+
"metadata":{
|
19
|
+
"guid":"space-id-1",
|
20
|
+
"url":"/v2/users/space-id-1"
|
21
|
+
},
|
22
|
+
"entity":{
|
23
|
+
"name":"space-name-1"
|
24
|
+
}
|
25
|
+
}],
|
26
|
+
"managers":[{
|
27
|
+
"metadata":{
|
28
|
+
"guid":"user-id-1",
|
29
|
+
"url":"/v2/users/user-id-1"
|
30
|
+
},
|
31
|
+
"entity":{}
|
32
|
+
}]
|
33
|
+
}
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"metadata":{
|
37
|
+
"guid":"organization-two-managers-id-1",
|
38
|
+
"url":"/v2/organizations/organization-two-managers-id-1"
|
39
|
+
},
|
40
|
+
"entity":{
|
41
|
+
"name":"organization-two-managers-name-1",
|
42
|
+
"managers":[{
|
43
|
+
"metadata":{
|
44
|
+
"guid":"user-id-1",
|
45
|
+
"url":"/v2/users/user-id-1"
|
46
|
+
},
|
47
|
+
"entity":{}
|
48
|
+
}, {
|
49
|
+
"metadata":{
|
50
|
+
"guid":"other-user-id-1",
|
51
|
+
"url":"/v2/users/other-user-id-1",
|
52
|
+
"created_at":"2012-10-24 12:14:54 -0700",
|
53
|
+
"updated_at":"2012-10-24 12:16:11 -0700"
|
54
|
+
},
|
55
|
+
"entity":{}
|
56
|
+
}]
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"metadata":{
|
61
|
+
"guid":"organization-other-managers-id-1",
|
62
|
+
"url":"/v2/organizations/organization-other-managers-id-1"
|
63
|
+
},
|
64
|
+
"entity":{
|
65
|
+
"name":"organization-other-managers-name-1",
|
66
|
+
"managers":[{
|
67
|
+
"metadata":{
|
68
|
+
"guid":"other-user-id-1",
|
69
|
+
"url":"/v2/users/other-user-id-1"
|
70
|
+
},
|
71
|
+
"entity":{}
|
72
|
+
}]
|
73
|
+
}
|
74
|
+
}
|
75
|
+
],
|
76
|
+
|
77
|
+
"managed_organizations":[],
|
78
|
+
"billing_managed_organizations":[],
|
79
|
+
"audited_organizations":[],
|
80
|
+
|
81
|
+
"spaces":[],
|
82
|
+
"managed_spaces":[],
|
83
|
+
"audited_spaces":[]
|
84
|
+
}
|
85
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFoundry::V2::Client do
|
4
|
+
before do
|
5
|
+
WebMock.allow_net_connect!
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:environment_api) { ENV["CF_V2_TEST_TARGET"] || "api.#{a1_domain}"}
|
9
|
+
let(:a1_domain) { "a1.cf-app.com" }
|
10
|
+
let(:prod_domain) { "run.pivotal.io" }
|
11
|
+
|
12
|
+
describe "setting a new target" do
|
13
|
+
it "switches the target cc" do
|
14
|
+
client = CFoundry::V2::Client.new("http://api." + a1_domain)
|
15
|
+
auth_endpoint = client.info[:authorization_endpoint]
|
16
|
+
expect(auth_endpoint).to match a1_domain
|
17
|
+
|
18
|
+
client.target = "http://api." + prod_domain
|
19
|
+
auth_endpoint = client.info[:authorization_endpoint]
|
20
|
+
expect(auth_endpoint).to match prod_domain
|
21
|
+
end
|
22
|
+
|
23
|
+
if ENV["CF_V2_RUN_INTEGRATION"]
|
24
|
+
it "requires a re-login" do
|
25
|
+
client = CFoundry::V2::Client.new("http://#{environment_api}")
|
26
|
+
client.login({username: ENV["CF_V2_TEST_USER"], password: ENV["CF_V2_TEST_PASSWORD"]})
|
27
|
+
client.quota_definitions # Getting quota definitions will always be the shortest request that requires auth
|
28
|
+
|
29
|
+
client.target = nil
|
30
|
+
client.target = "http://#{environment_api}"
|
31
|
+
expect { client.quota_definitions }.to raise_error(CFoundry::InvalidAuthToken)
|
32
|
+
|
33
|
+
client.login({username: ENV["CF_V2_TEST_USER"], password: ENV["CF_V2_TEST_PASSWORD"]})
|
34
|
+
client.quota_definitions
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
SPEC_ROOT = File.dirname(__FILE__).freeze
|
2
|
+
|
3
|
+
require "pry"
|
4
|
+
require "rspec"
|
5
|
+
require "putsinator"
|
6
|
+
require "cfoundry"
|
7
|
+
require "webmock/rspec"
|
8
|
+
require "ostruct"
|
9
|
+
require "timecop"
|
10
|
+
require "active_support"
|
11
|
+
require "active_support/core_ext"
|
12
|
+
require "cc_api_stub"
|
13
|
+
require "shoulda/matchers/integrations/rspec" # requiring all of shoulda matchers makes test unit run
|
14
|
+
|
15
|
+
require "support/shared_examples/cc_api_stub_request_examples"
|
16
|
+
require "support/shared_examples/client_login_examples"
|
17
|
+
require "support/shared_examples/model_summary_examples"
|
18
|
+
require "support/factory_girl"
|
19
|
+
require "support/test_model_builder"
|
20
|
+
|
21
|
+
RSpec.configure do |c|
|
22
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
shared_examples_for 'a stubbed get request' do |*options|
|
2
|
+
options = {:code => 200}.merge(options.first || {})
|
3
|
+
|
4
|
+
it "stubs a get request" do
|
5
|
+
subject
|
6
|
+
response = Net::HTTP.get_response(URI.parse(url))
|
7
|
+
check_response(response, options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
shared_examples_for 'a stubbed post request' do |*options|
|
12
|
+
options = {:code => 201, :params => {}}.merge(options.first || {})
|
13
|
+
|
14
|
+
it "stubs a post request" do
|
15
|
+
subject
|
16
|
+
response = Net::HTTP.post_form(URI.parse(url), options[:params])
|
17
|
+
check_response(response, options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
shared_examples_for 'a stubbed put request' do |*options|
|
22
|
+
options = {:code => 200, :params => {}}.merge(options.first || {})
|
23
|
+
|
24
|
+
it "stubs a put request" do
|
25
|
+
subject
|
26
|
+
uri = URI.parse(url)
|
27
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
28
|
+
request = Net::HTTP::Put.new(url, options[:params])
|
29
|
+
response = http.request(request)
|
30
|
+
check_response(response, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
shared_examples_for 'a stubbed delete request' do |*options|
|
36
|
+
options = {:code => 200, :ignore_response => true}.merge(options.first || {})
|
37
|
+
|
38
|
+
it "stubs a delete request" do
|
39
|
+
subject
|
40
|
+
uri = URI.parse(url)
|
41
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
42
|
+
request = Net::HTTP::Delete.new(url)
|
43
|
+
response = http.request(request)
|
44
|
+
check_response(response, options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def check_response(response, options)
|
50
|
+
expect(response.code).to eq(options[:code].to_s)
|
51
|
+
|
52
|
+
unless options[:ignore_response]
|
53
|
+
json = JSON.parse(response.body)
|
54
|
+
expect(json).to be_a(Hash)
|
55
|
+
|
56
|
+
if options[:including_json]
|
57
|
+
if Proc === options[:including_json]
|
58
|
+
options[:including_json][json]
|
59
|
+
else
|
60
|
+
expect(json).to deep_hash_include(options[:including_json])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
RSpec::Matchers.define :deep_hash_include do |expected|
|
67
|
+
def deep_hash_include_rec(actual_hash, partial_hash)
|
68
|
+
partial_hash.reduce(true) do |bool, (key, val)|
|
69
|
+
actual_val = actual_hash[key]
|
70
|
+
bool && ((Hash === actual_val) ?
|
71
|
+
deep_hash_include_rec(actual_val, partial_hash[key]) :
|
72
|
+
actual_val == val)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
match do |actual|
|
77
|
+
deep_hash_include_rec(actual, expected)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
shared_examples_for 'client login prompts' do
|
2
|
+
let(:uaa) { CFoundry::UAAClient.new('http://uaa.example.com') }
|
3
|
+
let(:prompts) do
|
4
|
+
{
|
5
|
+
:user_id => ["text", "User ID"],
|
6
|
+
:pin => ["password", "Your 8-digit Pin #"]
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(client.base).to receive(:uaa) { uaa }
|
12
|
+
allow(uaa).to receive(:prompts) { prompts }
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { client.login_prompts }
|
16
|
+
|
17
|
+
it 'returns the prompts provided by UAA' do
|
18
|
+
expect(subject).to eq(prompts)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_examples_for 'client login' do
|
23
|
+
let(:email) { 'test@test.com' }
|
24
|
+
let(:password) { 'secret' }
|
25
|
+
let(:uaa) { CFoundry::UAAClient.new('http://uaa.example.com') }
|
26
|
+
let(:access_token) { "some-access-token" }
|
27
|
+
let(:token_info) { CF::UAA::TokenInfo.new({ :access_token => access_token, :token_type => "bearer" }) }
|
28
|
+
|
29
|
+
before do
|
30
|
+
allow(client.base).to receive(:uaa) { uaa }
|
31
|
+
allow(uaa).to receive(:authorize).with(:username => email, :password => password) { token_info }
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { client.login(:username => email, :password => password) }
|
35
|
+
|
36
|
+
it 'returns a UAA token' do
|
37
|
+
expect(subject).to be_a(CFoundry::AuthToken)
|
38
|
+
expect(subject.auth_header).to eq("bearer #{access_token}")
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'saves the data as the token' do
|
42
|
+
subject
|
43
|
+
expect(client.token).to be_a(CFoundry::AuthToken)
|
44
|
+
expect(client.token.auth_header).to eq("bearer #{access_token}")
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
3
|
+
shared_examples_for "a summarizeable model" do
|
4
|
+
describe "#summary" do
|
5
|
+
let(:summary_endpoint) {
|
6
|
+
[ client.target,
|
7
|
+
"v2",
|
8
|
+
subject.class.plural_object_name,
|
9
|
+
subject.guid,
|
10
|
+
"summary"
|
11
|
+
].join("/")
|
12
|
+
}
|
13
|
+
|
14
|
+
it "returns the summary endpoint payload" do
|
15
|
+
req = stub_request(:get, summary_endpoint).to_return :status => 200,
|
16
|
+
:body => MultiJson.encode(summary_attributes)
|
17
|
+
|
18
|
+
expect(subject.summary).to eq(summary_attributes)
|
19
|
+
expect(req).to have_been_requested
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#summarize!" do
|
24
|
+
it "defines basic attributes via #summary" do
|
25
|
+
allow(subject).to receive(:summary) { summary_attributes }
|
26
|
+
|
27
|
+
subject.summarize!
|
28
|
+
|
29
|
+
summary_attributes.each do |k, v|
|
30
|
+
expect(subject.send(k)).to eq v
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
100:
|
2
|
+
name: BadRequest
|
3
|
+
http_code: 400
|
4
|
+
message: "Bad request"
|
5
|
+
|
6
|
+
101:
|
7
|
+
name: DatabaseError
|
8
|
+
http_code: 500
|
9
|
+
message: "Error talking with the database"
|
10
|
+
|
11
|
+
102:
|
12
|
+
name: LockingError
|
13
|
+
http_code: 400
|
14
|
+
message: "Optimistic locking failure"
|
15
|
+
|
16
|
+
111:
|
17
|
+
name: SystemError
|
18
|
+
http_code: 500
|
19
|
+
message: "System Exception Encountered"
|
20
|
+
|
21
|
+
200:
|
22
|
+
name: Forbidden
|
23
|
+
http_code: 403
|
24
|
+
message: "Operation not permitted"
|
25
|
+
|
26
|
+
201:
|
27
|
+
name: UserNotFound
|
28
|
+
http_code: 403
|
29
|
+
message: "User not found"
|
30
|
+
|
31
|
+
202:
|
32
|
+
name: HttpsRequired
|
33
|
+
http_code: 403
|
34
|
+
message: "HTTPS required"
|
35
|
+
|
36
|
+
300:
|
37
|
+
name: AppInvalid
|
38
|
+
http_code: 400
|
39
|
+
message: "Invalid application description"
|
40
|
+
|
41
|
+
301:
|
42
|
+
name: AppNotFound
|
43
|
+
http_code: 404
|
44
|
+
message: "Application not found"
|
45
|
+
|
46
|
+
302:
|
47
|
+
name: AppNoResources
|
48
|
+
http_code: 404
|
49
|
+
message: "Couldn't find a place to run an app"
|
50
|
+
|
51
|
+
303:
|
52
|
+
name: AppFileNotFound
|
53
|
+
http_code: 404
|
54
|
+
message: "Could not find : '%s'"
|
55
|
+
|
56
|
+
304:
|
57
|
+
name: AppInstanceNotFound
|
58
|
+
http_code: 400
|
59
|
+
message: "Could not find instance: '%s'"
|
60
|
+
|
61
|
+
305:
|
62
|
+
name: AppStopped
|
63
|
+
http_code: 400
|
64
|
+
message: "Operation not permitted on a stopped app"
|
65
|
+
|
66
|
+
306:
|
67
|
+
name: AppFileError
|
68
|
+
http_code: 500
|
69
|
+
message: "Error retrieving file '%s'"
|
70
|
+
|
71
|
+
307:
|
72
|
+
name: AppInvalidRuntime
|
73
|
+
http_code: 400
|
74
|
+
message: "Invalid runtime specification [%s] for framework: '%s'"
|
75
|
+
|
76
|
+
308:
|
77
|
+
name: AppInvalidFramework
|
78
|
+
http_code: 400
|
79
|
+
message: "Invalid framework description: '%s'"
|
80
|
+
|
81
|
+
309:
|
82
|
+
name: AppDebugDisallowed
|
83
|
+
http_code: 400
|
84
|
+
message: "Cloud controller has disallowed debugging."
|
85
|
+
|
86
|
+
310:
|
87
|
+
name: AppStagingError
|
88
|
+
http_code: 500
|
89
|
+
message: "Staging failed: '%s'"
|
90
|
+
|
91
|
+
400:
|
92
|
+
name: ResourcesUnknownPackageType
|
93
|
+
http_code: 400
|
94
|
+
message: 'Unknown package type requested: "%"'
|
95
|
+
|
96
|
+
401:
|
97
|
+
name: ResourcesMissingResource
|
98
|
+
http_code: 400
|
99
|
+
message: "Could not find the requested resource"
|
100
|
+
|
101
|
+
402:
|
102
|
+
name: ResourcesPackagingFailed
|
103
|
+
http_code: 500
|
104
|
+
message: "App packaging failed: '%s'"
|
105
|
+
|
106
|
+
500:
|
107
|
+
name: ServiceNotFound
|
108
|
+
http_code: 404
|
109
|
+
message: "Service not found"
|
110
|
+
|
111
|
+
501:
|
112
|
+
name: BindingNotFound
|
113
|
+
http_code: 404
|
114
|
+
message: "Binding not found"
|
115
|
+
|
116
|
+
502:
|
117
|
+
name: TokenNotFound
|
118
|
+
http_code: 404
|
119
|
+
message: "Token not found"
|
120
|
+
|
121
|
+
503:
|
122
|
+
name: ServiceGatewayError
|
123
|
+
http_code: 502
|
124
|
+
message: "Unexpected response from service gateway"
|
125
|
+
|
126
|
+
504:
|
127
|
+
name: AccountTooManyServices
|
128
|
+
http_code: 403
|
129
|
+
message: "Too many Services provisioned: %s, you're allowed: %s"
|
130
|
+
|
131
|
+
505:
|
132
|
+
name: ExtensionNotImpl
|
133
|
+
http_code: 501
|
134
|
+
message: "Service extension %s is not implemented."
|
135
|
+
|
136
|
+
506:
|
137
|
+
name: UnsupportedVersion
|
138
|
+
http_code: 404
|
139
|
+
message: "Unsupported service version %s."
|
140
|
+
|
141
|
+
507:
|
142
|
+
name: SdsError
|
143
|
+
http_code: 500
|
144
|
+
message: "Get error from serialization_data_server: '%s'"
|
145
|
+
|
146
|
+
508:
|
147
|
+
name: SdsNotFound
|
148
|
+
http_code: 500
|
149
|
+
message: "No available active serialization data server"
|
150
|
+
|
151
|
+
600:
|
152
|
+
name: AccountNotEnoughMemory
|
153
|
+
http_code: 403
|
154
|
+
message: "Not enough memory capacity, you're allowed: %s"
|
155
|
+
|
156
|
+
601:
|
157
|
+
name: AccountAppsTooMany
|
158
|
+
http_code: 403
|
159
|
+
message: "Too many applications: %s, you're allowed: %s"
|
160
|
+
|
161
|
+
602:
|
162
|
+
name: AccountAppTooManyUris
|
163
|
+
http_code: 403
|
164
|
+
message: "Too many URIs: %s, you're allowed: %s"
|
165
|
+
|
166
|
+
700:
|
167
|
+
name: UriInvalid
|
168
|
+
http_code: 400
|
169
|
+
message: 'Invalid URI: "%s"'
|
170
|
+
|
171
|
+
701:
|
172
|
+
name: UriAlreadyTaken
|
173
|
+
http_code: 400
|
174
|
+
message: 'The URI: "%s" has already been taken or reserved'
|
175
|
+
|
176
|
+
702:
|
177
|
+
name: UriNotAllowed
|
178
|
+
http_code: 403
|
179
|
+
message: "External URIs are not enabled for this account"
|
180
|
+
|
181
|
+
800:
|
182
|
+
name: StagingTimedOut
|
183
|
+
http_code: 500
|
184
|
+
message: "Timed out waiting for staging to complete"
|
185
|
+
|
186
|
+
801:
|
187
|
+
name: StagingFailed
|
188
|
+
http_code: 500
|
189
|
+
message: "Staging failed"
|