new_cfoundry 4.8.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 +40 -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 +63 -0
- data/lib/cfoundry/baseclient.rb +216 -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 +17 -0
- data/lib/cfoundry/errors.rb +163 -0
- data/lib/cfoundry/rest_client.rb +317 -0
- data/lib/cfoundry/test_support.rb +3 -0
- data/lib/cfoundry/trace_helpers.rb +64 -0
- data/lib/cfoundry/uaaclient.rb +160 -0
- data/lib/cfoundry/upload_helpers.rb +222 -0
- data/lib/cfoundry/v2/app.rb +303 -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 +108 -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 +12 -0
- data/lib/cfoundry/v2/model.rb +211 -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 +138 -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 +30 -0
- data/lib/cfoundry/v2/stack.rb +10 -0
- data/lib/cfoundry/v2/user.rb +93 -0
- data/lib/cfoundry/v2/user_provided_service_instance.rb +15 -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 +5 -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 +154 -0
- data/spec/cfoundry/baseclient_spec.rb +298 -0
- data/spec/cfoundry/client_spec.rb +13 -0
- data/spec/cfoundry/errors_spec.rb +117 -0
- data/spec/cfoundry/rest_client_spec.rb +349 -0
- data/spec/cfoundry/trace_helpers_spec.rb +91 -0
- data/spec/cfoundry/uaaclient_spec.rb +435 -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 +434 -0
- data/spec/cfoundry/v2/organization_spec.rb +135 -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 +13 -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/README.md +4 -0
- data/vendor/errors/v1.yml +189 -0
- data/vendor/errors/v2.yml +384 -0
- metadata +693 -0
@@ -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_true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "has a boolean 'public' attribute" do
|
49
|
+
expect(subject.public).to be_true
|
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,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe Space do
|
6
|
+
it_behaves_like "a summarizeable model" do
|
7
|
+
let(:summary_attributes) { {:name => "fizzbuzz"} }
|
8
|
+
let(:client) { build(:client) }
|
9
|
+
subject { build(:space, :client => client) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe UserProvidedServiceInstance do
|
6
|
+
let(:client) { build(:client) }
|
7
|
+
subject { build(:user_provided_service_instance, :client => client) }
|
8
|
+
|
9
|
+
describe 'space' do
|
10
|
+
let(:space) { build(:space) }
|
11
|
+
|
12
|
+
it 'has a space' do
|
13
|
+
subject.space = space
|
14
|
+
expect(subject.space).to eq(space)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when an invalid value is assigned' do
|
18
|
+
it 'raises a Mismatch exception' do
|
19
|
+
expect {
|
20
|
+
subject.space = [build(:organization)]
|
21
|
+
}.to raise_error(CFoundry::Mismatch)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'creating' do
|
27
|
+
let(:body) {
|
28
|
+
{
|
29
|
+
'metadata' => {
|
30
|
+
'guid' => 'someguid'
|
31
|
+
}
|
32
|
+
}.to_json
|
33
|
+
}
|
34
|
+
|
35
|
+
it 'calls the correct endpoint' do
|
36
|
+
stub_request(:any, %r[.*]).
|
37
|
+
to_return(:body => body, :status => 200)
|
38
|
+
|
39
|
+
subject.create!
|
40
|
+
|
41
|
+
expect(a_request(:post, 'http://api.example.com/v2/user_provided_service_instances')).to have_been_made
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'deleting' do
|
46
|
+
it 'calls the correct endpoint' do
|
47
|
+
stub_request(:any, %r[.*])
|
48
|
+
|
49
|
+
subject.delete!
|
50
|
+
|
51
|
+
expect(a_request(:delete, "http://api.example.com/v2/service_instances/#{subject.guid}")).to have_been_made
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,206 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CFoundry
|
4
|
+
module V2
|
5
|
+
describe User do
|
6
|
+
let(:client) { build(:client) }
|
7
|
+
subject { build(:user, client: client) }
|
8
|
+
|
9
|
+
describe '#delete!' do
|
10
|
+
describe 'when cloud controller was able to delete the user' do
|
11
|
+
before do
|
12
|
+
stub_request(:delete, /v2\/users\/.*/).to_return(:status => 200, :body => "", :headers => {})
|
13
|
+
allow(client.base).to receive(:info).and_return({:authorization_endpoint => 'some_endpoint'})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "also removes the user from uaa" do
|
17
|
+
expect_any_instance_of(CFoundry::UAAClient).to receive(:delete_user)
|
18
|
+
|
19
|
+
expect(subject.delete!).to be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "when cloud controller was unable to delete the user" do
|
24
|
+
before do
|
25
|
+
allow(client.base).to receive(:delete).and_raise(CFoundry::APIError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "allows the exception to bubble up" do
|
29
|
+
expect{ subject.delete! }.to raise_error(CFoundry::APIError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#get_meta_from_uaa' do
|
35
|
+
|
36
|
+
let(:api_target) { 'http://api.example.com' }
|
37
|
+
let(:login_target) { 'https://login.example.com' }
|
38
|
+
let(:uaa_target) { 'https://uaa.example.com' }
|
39
|
+
let(:user_email) { 'test-user@example.com' }
|
40
|
+
let(:given_name) { 'John' }
|
41
|
+
let(:family_name) { 'Doe' }
|
42
|
+
|
43
|
+
before do
|
44
|
+
|
45
|
+
stub_request(:get, "#{api_target}/info").to_return :status => 200,
|
46
|
+
:headers => {'Content-Type' => 'application/json'},
|
47
|
+
:body => <<EOF
|
48
|
+
{
|
49
|
+
"name": "vcap",
|
50
|
+
"build": "2222",
|
51
|
+
"support": "http://support.example.com",
|
52
|
+
"version": 2,
|
53
|
+
"description": "Cloud Foundry sponsored by Pivotal",
|
54
|
+
"authorization_endpoint": "https://login.example.com",
|
55
|
+
"token_endpoint": "https://uaa.example.com",
|
56
|
+
"allow_debug": true,
|
57
|
+
"user": "00000000-0000-0000-0000-000000000000",
|
58
|
+
"limits": {
|
59
|
+
"memory": 2048,
|
60
|
+
"app_uris": 4,
|
61
|
+
"services": 16,
|
62
|
+
"apps": 20
|
63
|
+
},
|
64
|
+
"usage": {
|
65
|
+
"memory": 896,
|
66
|
+
"apps": 4,
|
67
|
+
"services": 6
|
68
|
+
}
|
69
|
+
}
|
70
|
+
EOF
|
71
|
+
|
72
|
+
stub_request(:get, "#{login_target}/login").to_return :status => 200,
|
73
|
+
:headers => {'Content-Type' => 'application/json'},
|
74
|
+
:body => <<EOF
|
75
|
+
{
|
76
|
+
"timestamp": "2013-06-12T22:32:57-0700",
|
77
|
+
"app": {
|
78
|
+
"artifact": "cloudfoundry-login-server",
|
79
|
+
"description": "Cloud Foundry Login App",
|
80
|
+
"name": "Cloud Foundry Login",
|
81
|
+
"version": "1.2.3"
|
82
|
+
},
|
83
|
+
"links": {
|
84
|
+
"register": "https://console.example.com/register",
|
85
|
+
"passwd": "https://console.example.com/password_resets/new",
|
86
|
+
"home": "https://console.example.com",
|
87
|
+
"login": "https://login.example.com",
|
88
|
+
"uaa": "https://uaa.example.com"
|
89
|
+
},
|
90
|
+
"analytics": {
|
91
|
+
"code": "UA-00000000-00",
|
92
|
+
"domain": "example.com"
|
93
|
+
},
|
94
|
+
"commit_id": "0000000",
|
95
|
+
"prompts": {
|
96
|
+
"username": [
|
97
|
+
"text",
|
98
|
+
"Email"
|
99
|
+
],
|
100
|
+
"password": [
|
101
|
+
"password",
|
102
|
+
"Password"
|
103
|
+
]
|
104
|
+
}
|
105
|
+
}
|
106
|
+
EOF
|
107
|
+
|
108
|
+
stub_request(:get, /#{uaa_target}\/Users\/user-guid-\d{1,2}/).to_return :status => 200,
|
109
|
+
:headers => {'Content-Type' => 'application/json'},
|
110
|
+
:body => <<EOF
|
111
|
+
{
|
112
|
+
"id": "00000000-0000-0000-0000-000000000000",
|
113
|
+
"meta": {
|
114
|
+
"version": 0,
|
115
|
+
"created": "2013-06-24T13:44:38.000Z",
|
116
|
+
"lastModified": "2013-06-24T13:44:38.000Z"
|
117
|
+
},
|
118
|
+
"userName": "#{user_email}",
|
119
|
+
"name": {
|
120
|
+
"familyName": "#{family_name}",
|
121
|
+
"givenName": "#{given_name}"
|
122
|
+
},
|
123
|
+
"emails": [
|
124
|
+
{
|
125
|
+
"value": "#{user_email}"
|
126
|
+
}
|
127
|
+
],
|
128
|
+
"groups": [
|
129
|
+
{
|
130
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
131
|
+
"display": "password.write",
|
132
|
+
"type": "DIRECT"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
136
|
+
"display": "openid",
|
137
|
+
"type": "DIRECT"
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
141
|
+
"display": "uaa.user",
|
142
|
+
"type": "DIRECT"
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
146
|
+
"display": "scim.userids",
|
147
|
+
"type": "DIRECT"
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
151
|
+
"display": "approvals.me",
|
152
|
+
"type": "DIRECT"
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
156
|
+
"display": "cloud_controller.write",
|
157
|
+
"type": "DIRECT"
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
161
|
+
"display": "scim.me",
|
162
|
+
"type": "DIRECT"
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"value": "00000000-0000-0000-0000-000000000000",
|
166
|
+
"display": "cloud_controller.read",
|
167
|
+
"type": "DIRECT"
|
168
|
+
}
|
169
|
+
],
|
170
|
+
"approvals": [
|
171
|
+
|
172
|
+
],
|
173
|
+
"active": true,
|
174
|
+
"schemas": [
|
175
|
+
"urn:scim:schemas:core:1.0"
|
176
|
+
]
|
177
|
+
}
|
178
|
+
EOF
|
179
|
+
end
|
180
|
+
|
181
|
+
it "retrieves metadata from the UAA" do
|
182
|
+
expect(subject.email).to eq(user_email)
|
183
|
+
expect(subject.given_name).to eq(given_name)
|
184
|
+
expect(subject.family_name).to eq(family_name)
|
185
|
+
expect(subject.full_name).to eq("#{given_name} #{family_name}")
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should be nil if user doesn't have permission to query uaa" do
|
189
|
+
|
190
|
+
stub_request(:get, /#{uaa_target}\/Users\/user-guid-\d{1,2}/).to_return :status => 200,
|
191
|
+
:headers => {'Content-Type' => 'application/json'},
|
192
|
+
:body => <<EOF
|
193
|
+
{
|
194
|
+
"error": "access_denied",
|
195
|
+
"error_description": "Access is denied"
|
196
|
+
}
|
197
|
+
EOF
|
198
|
+
expect(subject.email).to eq(nil)
|
199
|
+
expect(subject.given_name).to eq(nil)
|
200
|
+
expect(subject.family_name).to eq(nil)
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CFoundry
|
4
|
+
describe Validator do
|
5
|
+
let(:validator) { described_class }
|
6
|
+
|
7
|
+
describe "value_matches?" do
|
8
|
+
it "returns true on nil values" do
|
9
|
+
expect(validator.value_matches?(nil, :something)).to be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with a type of Class" do
|
13
|
+
it "returns true when value is of type class" do
|
14
|
+
expect(validator.value_matches?(1, Integer)).to be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with a Regex" do
|
19
|
+
it "returns true when the regex matches" do
|
20
|
+
expect(validator.value_matches?("value", /lue/)).to eq(true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with type of url" do
|
25
|
+
it "requires http or https urls" do
|
26
|
+
expect(validator.value_matches?("http:whatever", :url)).to be_true
|
27
|
+
expect(validator.value_matches?("https:whatever", :url)).to be_true
|
28
|
+
expect(validator.value_matches?("htt_no:whatever", :url)).to be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with type of https_url" do
|
33
|
+
it "requires http or https urls" do
|
34
|
+
expect(validator.value_matches?("https:whatever", :https_url)).to be_true
|
35
|
+
expect(validator.value_matches?("http:whatever", :https_url)).to be_false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "with type boolean" do
|
40
|
+
it "returns true on presence of true or false" do
|
41
|
+
expect(validator.value_matches?(true, :boolean)).to be_true
|
42
|
+
expect(validator.value_matches?(false, :boolean)).to be_true
|
43
|
+
expect(validator.value_matches?("no boolean", :boolean)).to be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with an Array" do
|
48
|
+
it "returns true when all elements are of same type" do
|
49
|
+
expect(validator.value_matches?(["https:whatever"], [String])).to be_true
|
50
|
+
expect(validator.value_matches?(["https:whatever"], [Integer])).to be_false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a hash" do
|
55
|
+
it "returns true when specified types match" do
|
56
|
+
expect(validator.value_matches?({:name => "thing"}, {:name => String})).to be_true
|
57
|
+
expect(validator.value_matches?({:name => "thing", :unspecified => 1}, {:name => String})).to be_true
|
58
|
+
expect(validator.value_matches?({:name => 1}, {:name => String})).to be_false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true when type is nil" do
|
63
|
+
expect(validator.value_matches?("some value", nil)).to be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with a symbol" do
|
67
|
+
it "returns true when the value is of specified type" do
|
68
|
+
expect(validator.value_matches?("some value", :string)).to be_true
|
69
|
+
expect(validator.value_matches?("some value", :integer)).to be_false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "validate_type" do
|
75
|
+
it "passes validation with a nil value" do
|
76
|
+
expect {
|
77
|
+
validator.validate_type(nil, :whatever)
|
78
|
+
}.to_not raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
it "passes validation when the value matches" do
|
82
|
+
expect {
|
83
|
+
validator.validate_type("string", :string)
|
84
|
+
}.to_not raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
it "raises a validation error when value does not match" do
|
88
|
+
expect {
|
89
|
+
validator.validate_type("string", :integer)
|
90
|
+
}.to raise_error(CFoundry::Mismatch)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :app_usage_event, :class => CFoundry::V2::AppUsageEvent do
|
3
|
+
sequence(:guid) { |n| "app-usage-event-guid-#{n}" }
|
4
|
+
created_at '2013-01-01T12:00:00+00:00'
|
5
|
+
state 'STARTED'
|
6
|
+
memory_in_mb_per_instance 512
|
7
|
+
instance_count 1
|
8
|
+
app_guid 'app-guid-1'
|
9
|
+
app_name 'app-name-1'
|
10
|
+
space_guid 'space-guid-1'
|
11
|
+
space_name 'space-name-1'
|
12
|
+
org_guid 'org-guid-1'
|
13
|
+
|
14
|
+
initialize_with do
|
15
|
+
new(guid, build(:client), {
|
16
|
+
metadata: {
|
17
|
+
created_at: created_at
|
18
|
+
},
|
19
|
+
entity: {
|
20
|
+
state: state,
|
21
|
+
memory_in_mb_per_instance: memory_in_mb_per_instance,
|
22
|
+
instance_count: instance_count,
|
23
|
+
app_guid: app_guid,
|
24
|
+
app_name: app_name,
|
25
|
+
space_guid: space_guid,
|
26
|
+
space_name: space_name,
|
27
|
+
org_guid: org_guid
|
28
|
+
}
|
29
|
+
})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :event, :class => CFoundry::V2::Event do
|
3
|
+
sequence(:guid) { |n| "event-guid-#{n}" }
|
4
|
+
timestamp '2013-01-01T12:00:00+00:00'
|
5
|
+
actee 'app-guid-1'
|
6
|
+
actee_type 'app'
|
7
|
+
actor 'actor-guid-1'
|
8
|
+
actor_type 'user'
|
9
|
+
organization_guid 'organization-guid-1'
|
10
|
+
space_guid 'space-guid-1'
|
11
|
+
type ''
|
12
|
+
metadata {}
|
13
|
+
|
14
|
+
initialize_with do
|
15
|
+
new(guid, build(:client), {
|
16
|
+
entity: {
|
17
|
+
type: type,
|
18
|
+
actee: actee,
|
19
|
+
actee_type: actee_type,
|
20
|
+
actor: actor,
|
21
|
+
actor_type: actor_type,
|
22
|
+
organization_guid: organization_guid,
|
23
|
+
space_guid: space_guid,
|
24
|
+
timestamp: timestamp,
|
25
|
+
metadata: metadata
|
26
|
+
}
|
27
|
+
})
|
28
|
+
end
|
29
|
+
|
30
|
+
trait :app_update do
|
31
|
+
type 'audit.app.update'
|
32
|
+
|
33
|
+
changes do
|
34
|
+
{state: 'STARTED'}
|
35
|
+
end
|
36
|
+
|
37
|
+
metadata do
|
38
|
+
{
|
39
|
+
request: changes,
|
40
|
+
desired_memory: 128,
|
41
|
+
desired_instances: 1
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
trait :app_delete do
|
47
|
+
type 'audit.app.delete'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :organization, :class => CFoundry::V2::Organization do
|
3
|
+
sequence(:guid) { |n| "organization-guid-#{n}" }
|
4
|
+
status "active"
|
5
|
+
|
6
|
+
transient do
|
7
|
+
client { FactoryGirl.build(:client) }
|
8
|
+
end
|
9
|
+
|
10
|
+
initialize_with { new(guid, client) }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :service_instance, :class => CFoundry::V2::ManagedServiceInstance do
|
3
|
+
sequence(:guid) { |n| "service-instance-guid-#{n}" }
|
4
|
+
transient do
|
5
|
+
client { FactoryGirl.build(:client) }
|
6
|
+
end
|
7
|
+
|
8
|
+
initialize_with { new(guid, client) }
|
9
|
+
end
|
10
|
+
end
|