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,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Organizations do
|
6
|
+
let(:client) { build(:client) }
|
7
|
+
|
8
|
+
describe ".succeed_to_create" do
|
9
|
+
let(:url) { "http://example.com/v2/organizations/" }
|
10
|
+
subject { CcApiStub::Organizations.succeed_to_create }
|
11
|
+
|
12
|
+
it_behaves_like "a stubbed post request"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
describe '.summary_fixture' do
|
17
|
+
it 'returns the fake org' do
|
18
|
+
expect(CcApiStub::Organizations.summary_fixture).to be_a(Hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.fail_to_find' do
|
23
|
+
let(:url) { "http://example.com/v2/organizations/9234" }
|
24
|
+
subject { CcApiStub::Organizations.fail_to_find(9234) }
|
25
|
+
|
26
|
+
it_behaves_like "a stubbed get request", :code => 404
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.succeed_to_load_summary' do
|
30
|
+
let(:url) { "http://example.com/v2/organizations/9234/summary" }
|
31
|
+
subject { CcApiStub::Organizations.succeed_to_load_summary }
|
32
|
+
|
33
|
+
it_behaves_like "a stubbed get request"
|
34
|
+
|
35
|
+
context "when passed a no_spaces option" do
|
36
|
+
subject { CcApiStub::Organizations.succeed_to_load_summary(:no_spaces => true) }
|
37
|
+
|
38
|
+
it_behaves_like "a stubbed get request", :including_json => { "spaces" => [] }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.succeed_to_search' do
|
43
|
+
let(:url) { "http://example.com/v2/organizations?inline-relations-depth=1&q=name:orgname" }
|
44
|
+
subject { CcApiStub::Organizations.succeed_to_search("orgname") }
|
45
|
+
|
46
|
+
it_behaves_like "a stubbed get request"
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.succeed_to_search_none' do
|
50
|
+
let(:url) { "http://example.com/v2/organizations?inline-relations-depth=1&q=name:orgname" }
|
51
|
+
subject { CcApiStub::Organizations.succeed_to_search_none }
|
52
|
+
|
53
|
+
it_behaves_like "a stubbed get request"
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.domains_fixture' do
|
57
|
+
it 'returns the fake domain' do
|
58
|
+
expect(CcApiStub::Organizations.domains_fixture).to be_a(Hash)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.domains_fixture_hash' do
|
63
|
+
it 'returns the fake domain' do
|
64
|
+
fixture = CcApiStub::Organizations.domain_fixture_hash
|
65
|
+
expect(fixture).to be_a(Hash)
|
66
|
+
expect(fixture).to eq(fixture.symbolize_keys)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.succeed_to_load_domains' do
|
71
|
+
let(:url) { "http://example.com/v2/organizations/3434/domains?inline-relations-depth=1" }
|
72
|
+
subject { CcApiStub::Organizations.succeed_to_load_domains }
|
73
|
+
|
74
|
+
it_behaves_like "a stubbed get request"
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '.users_fixture' do
|
78
|
+
it "returns the fake users" do
|
79
|
+
expect(CcApiStub::Organizations.users_fixture).to be_a(Hash)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '.user_fixture_hash' do
|
84
|
+
it 'returns the fake user' do
|
85
|
+
fixture = CcApiStub::Organizations.user_fixture_hash
|
86
|
+
expect(fixture).to be_a(Hash)
|
87
|
+
expect(fixture).to eq(fixture.symbolize_keys)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '.succeed_to_load_users' do
|
92
|
+
let(:url) { "http://example.com/v2/organizations/2342/users?inline-relations-depth=1" }
|
93
|
+
subject { CcApiStub::Organizations.succeed_to_load_users }
|
94
|
+
|
95
|
+
it_behaves_like "a stubbed get request"
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '.spaces_fixture' do
|
99
|
+
it "returns the fake spaces" do
|
100
|
+
expect(CcApiStub::Organizations.spaces_fixture).to be_a(Hash)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.space_fixture_hash' do
|
105
|
+
it 'returns the fake space' do
|
106
|
+
fixture = CcApiStub::Organizations.space_fixture_hash
|
107
|
+
expect(fixture).to be_a(Hash)
|
108
|
+
expect(fixture).to eq(fixture.symbolize_keys)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '.succeed_to_load_spaces' do
|
113
|
+
let(:url) { "http://example.com/v2/organizations/2342/spaces?inline-relations-depth=1" }
|
114
|
+
subject { CcApiStub::Organizations.succeed_to_load_spaces }
|
115
|
+
|
116
|
+
it_behaves_like "a stubbed get request"
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Routes do
|
6
|
+
let(:url) { "http://example.com/v2/routes/" }
|
7
|
+
|
8
|
+
describe ".succeed_to_load_none" do
|
9
|
+
subject { CcApiStub::Routes.succeed_to_load_none }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request", :including_json => { "resources" => [] }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".succeed_to_create" do
|
15
|
+
subject { CcApiStub::Routes.succeed_to_create }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed post request"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Runtimes do
|
6
|
+
let(:url) { "http://example.com/v2/runtimes?inline-relations-depth=1" }
|
7
|
+
|
8
|
+
describe ".succeed_to_load" do
|
9
|
+
subject { CcApiStub::Runtimes.succeed_to_load }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".fail_to_load" do
|
15
|
+
subject { CcApiStub::Runtimes.fail_to_load }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed get request", :code => 500, :ignore_response => true
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::ServiceBindings do
|
6
|
+
let(:url) { "http://example.com/v2/service_bindings" }
|
7
|
+
|
8
|
+
describe ".succeed_to_create" do
|
9
|
+
subject { CcApiStub::ServiceBindings.succeed_to_create }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed post request"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::ServiceInstances do
|
6
|
+
describe ".succeed_to_create" do
|
7
|
+
let(:url) { "http://example.com/v2/service_instances" }
|
8
|
+
subject { CcApiStub::ServiceInstances.succeed_to_create }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed post request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_load" do
|
14
|
+
let(:url) { "http://example.com/v2/service_instances/123" }
|
15
|
+
subject { CcApiStub::ServiceInstances.succeed_to_load }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed get request"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::SpaceUsers do
|
6
|
+
let(:url) { "http://example.com/v2/spaces/123/users/94087" }
|
7
|
+
|
8
|
+
describe ".succeed_to_delete" do
|
9
|
+
subject { CcApiStub::SpaceUsers.succeed_to_delete }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed delete request"
|
12
|
+
|
13
|
+
context "when the :roles option is provided" do
|
14
|
+
let(:roles) { [:developer, :managers, :auditor] }
|
15
|
+
it "deletes the user from each specified role" do
|
16
|
+
CcApiStub::SpaceUsers.succeed_to_delete(roles: roles)
|
17
|
+
roles.each do |role|
|
18
|
+
url = "http://example.com/v2/spaces/123/#{role.to_s.pluralize}/94087"
|
19
|
+
uri = URI.parse(url)
|
20
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
21
|
+
request = Net::HTTP::Delete.new(url)
|
22
|
+
response = http.request(request)
|
23
|
+
check_response(response, code: 200, ignore_response: true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".fail_to_delete" do
|
31
|
+
subject { CcApiStub::SpaceUsers.fail_to_delete }
|
32
|
+
|
33
|
+
it_behaves_like "a stubbed delete request", :code => 500, :ignore_response => true
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Spaces do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/spaces/234" }
|
8
|
+
subject { CcApiStub::Spaces.succeed_to_load }
|
9
|
+
|
10
|
+
it_behaves_like "a stubbed get request"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".succeed_to_create" do
|
14
|
+
let(:url) { "http://example.com/v2/spaces" }
|
15
|
+
subject { CcApiStub::Spaces.succeed_to_create }
|
16
|
+
|
17
|
+
it_behaves_like "a stubbed post request"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".summary_fixture" do
|
21
|
+
it "returns a space fixture" do
|
22
|
+
expect(CcApiStub::Spaces.summary_fixture).to be_a(Hash)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".succeed_to_load_summary" do
|
27
|
+
let(:url) { "http://example.com/v2/spaces/234/summary" }
|
28
|
+
subject { CcApiStub::Spaces.succeed_to_load_summary }
|
29
|
+
|
30
|
+
it_behaves_like "a stubbed get request"
|
31
|
+
|
32
|
+
context "when specifying no_services" do
|
33
|
+
subject { CcApiStub::Spaces.succeed_to_load_summary(:no_services => true) }
|
34
|
+
|
35
|
+
it_behaves_like "a stubbed get request", :including_json => {"services" => []}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe CcApiStub::Users do
|
6
|
+
describe ".succeed_to_load" do
|
7
|
+
let(:url) { "http://example.com/v2/users/2345?inline-relations-depth=2" }
|
8
|
+
let(:options) { {} }
|
9
|
+
subject { CcApiStub::Users.succeed_to_load(options) }
|
10
|
+
|
11
|
+
it_behaves_like "a stubbed get request"
|
12
|
+
|
13
|
+
context "when setting a user id" do
|
14
|
+
let(:options) { { :id => "some-id" } }
|
15
|
+
|
16
|
+
it_behaves_like "a stubbed get request", :including_json => { "metadata" => { "guid" => "some-id" } }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when setting an organization_id" do
|
20
|
+
let(:options) { { :organization_id => "some-id" } }
|
21
|
+
|
22
|
+
it_behaves_like "a stubbed get request", :including_json => Proc.new { |json|
|
23
|
+
json["entity"]["organizations"][0]["metadata"]["guid"].should == "some-id"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when specifying no_spaces" do
|
28
|
+
let(:options) { { :no_spaces => true } }
|
29
|
+
|
30
|
+
it_behaves_like "a stubbed get request", :including_json => Proc.new { |json|
|
31
|
+
json["entity"]["organizations"][0]["entity"]["spaces"].should == []
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when specifying custom permissions" do
|
36
|
+
let(:options) { { :permissions => [:space_manager, :space2_auditor] } }
|
37
|
+
|
38
|
+
it_behaves_like "a stubbed get request", :including_json => {
|
39
|
+
"entity" =>
|
40
|
+
{
|
41
|
+
"managed_spaces" => [{"metadata" => { "guid" => "space-id-1" }, "entity" => {}}],
|
42
|
+
"audited_spaces" => [{"metadata" => { "guid" => "space-id-2" }, "entity" => {}}]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".fail_to_find" do
|
49
|
+
let(:url) { "http://example.com/v2/users/2345" }
|
50
|
+
subject { CcApiStub::Users.fail_to_find }
|
51
|
+
|
52
|
+
it_behaves_like "a stubbed get request", :code => 404
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".succeed_to_create" do
|
56
|
+
let(:url) { "http://example.com/v2/users" }
|
57
|
+
subject { CcApiStub::Users.succeed_to_create }
|
58
|
+
|
59
|
+
it_behaves_like "a stubbed post request"
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".fail_to_create" do
|
63
|
+
let(:url) { "http://example.com/v2/users" }
|
64
|
+
subject { CcApiStub::Users.fail_to_create }
|
65
|
+
|
66
|
+
it_behaves_like "a stubbed post request", :code => 500
|
67
|
+
end
|
68
|
+
|
69
|
+
describe ".succeed_to_replace_permissions" do
|
70
|
+
let(:url) { "http://example.com/v2/users/123" }
|
71
|
+
subject { CcApiStub::Users.succeed_to_replace_permissions }
|
72
|
+
|
73
|
+
it_behaves_like "a stubbed put request", :ignore_response => true
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ".fail_to_replace_permissions" do
|
77
|
+
let(:url) { "http://example.com/v2/users/123" }
|
78
|
+
subject { CcApiStub::Users.fail_to_replace_permissions }
|
79
|
+
|
80
|
+
it_behaves_like "a stubbed put request", :ignore_response => true, :code => 500
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".organizations_fixture" do
|
84
|
+
subject { CcApiStub::Users.organizations_fixture }
|
85
|
+
|
86
|
+
it "returns a fixture" do
|
87
|
+
expect(subject).to be_a Array
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe ".organizations_fixture_hash" do
|
92
|
+
subject { CcApiStub::Users.organization_fixture_hash }
|
93
|
+
|
94
|
+
it "returns a fixture" do
|
95
|
+
expect(subject).to be_a Hash
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when specifying options" do
|
99
|
+
subject { CcApiStub::Users.organization_fixture_hash(:no_spaces => true, :no_managers => true) }
|
100
|
+
|
101
|
+
it "takes options into account" do
|
102
|
+
expect(subject[:entity][:spaces]).to be_nil
|
103
|
+
expect(subject[:entity][:managers]).to be_nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe CFoundry::AuthToken do
|
5
|
+
describe ".from_uaa_token_info" do
|
6
|
+
let(:access_token) { Base64.encode64('{"algo": "h1234"}{"user_id": "a6", "email": "a@b.com"}random-bytes') }
|
7
|
+
let(:info_hash) do
|
8
|
+
{
|
9
|
+
:token_type => "bearer",
|
10
|
+
:access_token => access_token,
|
11
|
+
:refresh_token => "some-refresh-token"
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
let(:token_info) { CF::UAA::TokenInfo.new(info_hash) }
|
17
|
+
|
18
|
+
subject { CFoundry::AuthToken.from_uaa_token_info(token_info) }
|
19
|
+
|
20
|
+
describe "#auth_header" do
|
21
|
+
describe '#auth_header' do
|
22
|
+
subject { super().auth_header }
|
23
|
+
it { should eq "bearer #{access_token}" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#to_hash" do
|
28
|
+
let(:result_hash) do
|
29
|
+
{
|
30
|
+
:token => "bearer #{access_token}",
|
31
|
+
:refresh_token => "some-refresh-token"
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#to_hash' do
|
36
|
+
subject { super().to_hash }
|
37
|
+
it { should eq result_hash }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#token_data" do
|
42
|
+
context "when the access token is encoded as expected" do
|
43
|
+
describe '#token_data' do
|
44
|
+
subject { super().token_data }
|
45
|
+
it { should eq({ :user_id => "a6", :email => "a@b.com"}) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when the access token is not encoded as expected" do
|
50
|
+
let(:access_token) { Base64.encode64('random-bytes') }
|
51
|
+
|
52
|
+
describe '#token_data' do
|
53
|
+
subject { super().token_data }
|
54
|
+
it { should eq({}) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when the access token contains invalid json" do
|
59
|
+
let(:access_token) { Base64.encode64('{"algo": "h1234"}{"user_id", "a6", "email": "a@b.com"}random-bytes') }
|
60
|
+
|
61
|
+
describe '#token_data' do
|
62
|
+
subject { super().token_data }
|
63
|
+
it { should eq({}) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when the auth header is nil" do
|
68
|
+
before do
|
69
|
+
subject.auth_header = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#token_data' do
|
73
|
+
subject { super().token_data }
|
74
|
+
it { should eq({}) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".from_hash(hash)" do
|
81
|
+
let(:token_data) { '{"baz":"buzz"}' }
|
82
|
+
let(:token) { Base64.encode64("{\"foo\":1}#{token_data}") }
|
83
|
+
|
84
|
+
let(:hash) do
|
85
|
+
{
|
86
|
+
:token => "bearer #{token}",
|
87
|
+
:refresh_token => "some-refresh-token"
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
subject { CFoundry::AuthToken.from_hash(hash) }
|
92
|
+
|
93
|
+
describe "#auth_header" do
|
94
|
+
describe '#auth_header' do
|
95
|
+
subject { super().auth_header }
|
96
|
+
it { should eq("bearer #{token}") }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#to_hash" do
|
101
|
+
describe '#to_hash' do
|
102
|
+
subject { super().to_hash }
|
103
|
+
it { should eq(hash) }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#token_data" do
|
108
|
+
describe '#token_data' do
|
109
|
+
subject { super().token_data }
|
110
|
+
it { should eq({ :baz => "buzz" }) }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#auth_header=" do
|
116
|
+
let(:access_token) { Base64.encode64('{"algo": "h1234"}{"user_id": "a6", "email": "a@b.com"}random-bytes') }
|
117
|
+
let(:other_access_token) { Base64.encode64('{"algo": "h1234"}{"user_id": "b6", "email": "a@b.com"}random-bytes') }
|
118
|
+
|
119
|
+
subject { CFoundry::AuthToken.new("bearer #{access_token}") }
|
120
|
+
|
121
|
+
it "invalidates @token_data" do
|
122
|
+
subject.token_data
|
123
|
+
expect {
|
124
|
+
subject.auth_header = "bearer #{other_access_token}"
|
125
|
+
}.to change { subject.token_data[:user_id] }.from("a6").to("b6")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#expires_soon?" do
|
130
|
+
let(:access_token) { Base64.encode64(%Q|{"algo": "h1234"}{"exp":#{expiration.to_i}}random-bytes|) }
|
131
|
+
|
132
|
+
subject { CFoundry::AuthToken.new("bearer #{access_token}") }
|
133
|
+
|
134
|
+
context "when the token expires in less than 1 minute" do
|
135
|
+
let(:expiration) { Time.now + 59 }
|
136
|
+
|
137
|
+
it "returns true" do
|
138
|
+
Timecop.freeze do
|
139
|
+
expect(subject.expires_soon?).to be_true
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context "when the token expires in greater than or equal to 1 minute" do
|
145
|
+
let(:expiration) { Time.now + 60 }
|
146
|
+
|
147
|
+
it "returns false" do
|
148
|
+
Timecop.freeze do
|
149
|
+
expect(subject.expires_soon?).to be_false
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|