cfoundry 0.5.1.rc2 → 0.5.1.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cc_api_stub.rb +17 -0
- data/lib/cc_api_stub/applications.rb +53 -0
- data/lib/cc_api_stub/domains.rb +16 -0
- data/lib/cc_api_stub/frameworks.rb +22 -0
- data/lib/cc_api_stub/helper.rb +131 -0
- data/lib/cc_api_stub/login.rb +21 -0
- data/lib/cc_api_stub/organization_users.rb +21 -0
- data/lib/cc_api_stub/organizations.rb +70 -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 +25 -0
- data/lib/cc_api_stub/spaces.rb +49 -0
- data/lib/cc_api_stub/users.rb +84 -0
- data/lib/cfoundry/baseclient.rb +24 -0
- data/lib/cfoundry/errors.rb +16 -133
- data/lib/cfoundry/v1/app.rb +6 -2
- data/lib/cfoundry/v2/app.rb +16 -4
- data/lib/cfoundry/v2/base.rb +10 -11
- data/lib/cfoundry/v2/client.rb +4 -0
- data/lib/cfoundry/version.rb +1 -1
- data/spec/cc_api_stub/applications_spec.rb +69 -0
- data/spec/cc_api_stub/domains_spec.rb +19 -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 +19 -0
- data/spec/cc_api_stub/organizations_spec.rb +103 -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 +12 -0
- data/spec/cc_api_stub/spaces_spec.rb +38 -0
- data/spec/cc_api_stub/users_spec.rb +107 -0
- data/spec/cfoundry/baseclient_spec.rb +42 -2
- data/spec/cfoundry/v2/app_spec.rb +95 -0
- data/spec/fixtures/fake_cc_application.json +24 -0
- data/spec/fixtures/fake_cc_application_summary.json +57 -0
- data/spec/fixtures/fake_cc_created_application.json +11 -0
- data/spec/fixtures/fake_cc_created_domain.json +10 -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_empty_search.json +7 -0
- data/spec/fixtures/fake_cc_frameworks.json +20 -0
- data/spec/fixtures/fake_cc_organization.json +144 -0
- data/spec/fixtures/fake_cc_organization_domains.json +34 -0
- data/spec/fixtures/fake_cc_organization_search.json +37 -0
- data/spec/fixtures/fake_cc_organization_summary.json +19 -0
- data/spec/fixtures/fake_cc_organization_users.json +81 -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 +81 -0
- data/spec/fixtures/fake_cc_service_instances.json +0 -0
- data/spec/fixtures/fake_cc_service_types.json +124 -0
- data/spec/fixtures/fake_cc_space.json +45 -0
- data/spec/fixtures/fake_cc_space_summary.json +86 -0
- data/spec/fixtures/fake_cc_stats.json +29 -0
- data/spec/fixtures/fake_cc_user.json +112 -0
- data/spec/fixtures/fake_cc_user_organizations.json +92 -0
- data/spec/fixtures/fake_cc_user_with_managers.json +85 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/fake_helper.rb +0 -36
- data/spec/support/shared_examples/cc_api_stub_request_examples.rb +79 -0
- metadata +254 -144
    
        data/lib/cc_api_stub.rb
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            require "cc_api_stub/helper"
         | 
| 2 | 
            +
            require "cc_api_stub/organizations"
         | 
| 3 | 
            +
            require "cc_api_stub/login"
         | 
| 4 | 
            +
            require "cc_api_stub/applications"
         | 
| 5 | 
            +
            require "cc_api_stub/domains"
         | 
| 6 | 
            +
            require "cc_api_stub/frameworks"
         | 
| 7 | 
            +
            require "cc_api_stub/organization_users"
         | 
| 8 | 
            +
            require "cc_api_stub/routes"
         | 
| 9 | 
            +
            require "cc_api_stub/runtimes"
         | 
| 10 | 
            +
            require "cc_api_stub/service_bindings"
         | 
| 11 | 
            +
            require "cc_api_stub/service_instances"
         | 
| 12 | 
            +
            require "cc_api_stub/services"
         | 
| 13 | 
            +
            require "cc_api_stub/spaces"
         | 
| 14 | 
            +
            require "cc_api_stub/users"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            module CcApiStub
         | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Applications
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_load(options={})
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures(options.delete(:fixture) || "fake_cc_#{object_name}", options)
         | 
| 8 | 
            +
                    stub_get(object_endpoint, {}, response(200, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def succeed_to_create
         | 
| 12 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_created_application")
         | 
| 13 | 
            +
                    stub_post(%r{/v2/apps$}, nil, response(201, response_body))
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def succeed_to_update(options={})
         | 
| 17 | 
            +
                    response_body = Helper.load_fixtures(:fake_cc_application, options)
         | 
| 18 | 
            +
                    stub_put(object_endpoint, nil, response(200, response_body))
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def succeed_to_map_route
         | 
| 22 | 
            +
                    stub_put(%r{/v2/apps/[^/]+/routes/[^/]+$}, {}, response(201, {}))
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def succeed_to_load_stats
         | 
| 26 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_stats")
         | 
| 27 | 
            +
                    stub_get(%r{/v2/apps/[^/]+/stats$}, {}, response(200, response_body))
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def summary_fixture
         | 
| 31 | 
            +
                    Helper.load_fixtures("fake_cc_application_summary")
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  def succeed_to_load_summary(options={})
         | 
| 35 | 
            +
                    response = summary_fixture
         | 
| 36 | 
            +
                    response["state"] = options[:state] if options.has_key?(:state)
         | 
| 37 | 
            +
                    response["routes"] = options[:routes] if options.has_key?(:routes)
         | 
| 38 | 
            +
                    stub_get(%r{/v2/apps/[^/]+/summary$}, {}, response(200, response))
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def succeed_to_load_service_bindings
         | 
| 42 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_service_bindings")
         | 
| 43 | 
            +
                    stub_get(%r{/v2/apps/[^/]+/service_bindings/?(?:\?.+)?$}, {}, response(200, response_body))
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  private
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def object_endpoint
         | 
| 49 | 
            +
                    %r{/v2/apps/[^/]+$}
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Domains
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_create
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_created_domain")
         | 
| 8 | 
            +
                    stub_post(%r{/v2/domains/?(\?.+)?$}, {}, response(201, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def succeed_to_delete
         | 
| 12 | 
            +
                    stub_delete(%r{/v2/domains/[^/\?]+$}, {}, response(200))
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Frameworks
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_load
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_frameworks")
         | 
| 8 | 
            +
                    stub_get(collection_endpoint, {}, response(200, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def fail_to_load
         | 
| 12 | 
            +
                    stub_get(collection_endpoint, {}, response(500))
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  private
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def collection_endpoint
         | 
| 18 | 
            +
                    %r{/v2/frameworks\?inline-relations-depth=1$}
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,131 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module CcApiStub
         | 
| 4 | 
            +
              module Helper
         | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def response(code, body=nil)
         | 
| 7 | 
            +
                    {
         | 
| 8 | 
            +
                      :status => code,
         | 
| 9 | 
            +
                      :headers => {},
         | 
| 10 | 
            +
                      :body => body.nil? ? "--garbage--" : body.to_json
         | 
| 11 | 
            +
                    }
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def fail_request(method = :any, code = 500, response_body = {}, path = /#{CcApiStub::Helper.host}/)
         | 
| 15 | 
            +
                    WebMock::API.stub_request(method, path).to_return(response(code, response_body))
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def host=(host)
         | 
| 19 | 
            +
                    @@host = host
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def host
         | 
| 23 | 
            +
                    @@host or raise 'No host set'
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def fail_with_error(method, error_attributes=nil)
         | 
| 27 | 
            +
                    WebMock::API.
         | 
| 28 | 
            +
                      stub_request(method, /#{CcApiStub::Helper.host}/).
         | 
| 29 | 
            +
                      to_return(response(400, error_attributes))
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def load_fixtures(fixtures_name, options = {})
         | 
| 33 | 
            +
                    path = File.join(File.dirname(__FILE__), "..", "..", "spec/fixtures/#{fixtures_name.to_s}.json")
         | 
| 34 | 
            +
                    JSON.parse(File.read(path)).tap do |fixture|
         | 
| 35 | 
            +
                      fixture["entity"].merge!(options.stringify_keys) if options.any?
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def stub_get(*args)
         | 
| 41 | 
            +
                  stub_request(:get, *args)
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def stub_post(*args)
         | 
| 45 | 
            +
                  stub_request(:post, *args)
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def stub_put(*args)
         | 
| 49 | 
            +
                  stub_request(:put, *args)
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                def stub_delete(*args)
         | 
| 53 | 
            +
                  stub_request(:delete, *args)
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def stub_request(method, path, params = nil, response = nil)
         | 
| 57 | 
            +
                  stub = WebMock::API.stub_request(method, path)
         | 
| 58 | 
            +
                  stub.to_return(response) if response
         | 
| 59 | 
            +
                  stub.with(params) if params
         | 
| 60 | 
            +
                  stub
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                def object_name
         | 
| 64 | 
            +
                  name.demodulize.underscore.singularize
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                def find_fixture(fixture_name)
         | 
| 68 | 
            +
                  begin
         | 
| 69 | 
            +
                    Helper.load_fixtures("fake_#{fixture_name}")
         | 
| 70 | 
            +
                  rescue
         | 
| 71 | 
            +
                    Helper.load_fixtures("fake_organization_#{fixture_name}")
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def object_class
         | 
| 76 | 
            +
                  begin
         | 
| 77 | 
            +
                    object_name.camelcase.constantize
         | 
| 78 | 
            +
                  rescue
         | 
| 79 | 
            +
                    "Organization::#{object_name.camelcase}".constantize
         | 
| 80 | 
            +
                  rescue
         | 
| 81 | 
            +
                    "User::#{object_name.camelcase}".constantize
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def response(code, body=nil)
         | 
| 86 | 
            +
                  CcApiStub::Helper.response(code, body)
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                def succeed_to_load(options={})
         | 
| 90 | 
            +
                  response_body = CcApiStub::Helper.load_fixtures(options.delete(:fixture) || "fake_cc_#{object_name}", options)
         | 
| 91 | 
            +
                  stub_get(object_endpoint, {}, response(200, response_body))
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                def fail_to_load
         | 
| 95 | 
            +
                  stub_get(object_endpoint, {}, response(500))
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                def succeed_to_load_many(options={})
         | 
| 99 | 
            +
                  response_body = CcApiStub::Helper.load_fixtures(options.delete(:fixture) || "fake_#{object_name.pluralize}", options)
         | 
| 100 | 
            +
                  stub_get(collection_endpoint, {}, response(200, response_body))
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                def succeed_to_load_empty(options = {})
         | 
| 104 | 
            +
                  root = options[:root] || object_name.pluralize
         | 
| 105 | 
            +
                  stub_get(collection_endpoint, {}, response(200, {root => [], "pagination" => {}}))
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                def fail_to_load_many
         | 
| 109 | 
            +
                  stub_get(collection_endpoint, {}, response(500))
         | 
| 110 | 
            +
                end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                def succeed_to_create
         | 
| 113 | 
            +
                  response_body = {object_name.to_sym => {:id => "#{object_name.gsub("_", "-")}-id-1"}}
         | 
| 114 | 
            +
                  stub_post(collection_endpoint, {}, response(201, response_body))
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                def succeed_to_update(attributes = {})
         | 
| 118 | 
            +
                  stub_put(object_endpoint, nil, response(200, {}))
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                def succeed_to_delete
         | 
| 122 | 
            +
                  stub_delete(object_endpoint, nil, response(200))
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                alias_method :succeed_to_leave, :succeed_to_delete
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                def fixture_prefix
         | 
| 128 | 
            +
                  "_cc"
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Login
         | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
                  def succeeds_to_find_uaa(domain="http://some-other-random-domain.com:8181")
         | 
| 5 | 
            +
                    WebMock::API.stub_request(:get, "#{domain}/info").
         | 
| 6 | 
            +
                      to_return(
         | 
| 7 | 
            +
                        :status => 200,
         | 
| 8 | 
            +
                        :body => "{\"authorization_endpoint\":\"https://uaa.localhost\"}"
         | 
| 9 | 
            +
                      )
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def succeeds_to_login_as_admin
         | 
| 13 | 
            +
                    WebMock::API.stub_request(:post, %r{uaa.localhost/oauth/authorize}).
         | 
| 14 | 
            +
                      to_return(
         | 
| 15 | 
            +
                        :status => 302,
         | 
| 16 | 
            +
                        :headers => {"Location" => "https://uaa.localhost/redirect/vmc#access_token=sre-admin-access-token&token_type=bearer"}
         | 
| 17 | 
            +
                      )
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module OrganizationUsers
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_delete
         | 
| 7 | 
            +
                    stub_delete(object_endpoint, {}, response(200, ""))
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def fail_to_delete
         | 
| 11 | 
            +
                    stub_delete(object_endpoint, {}, response(500))
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  private
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def object_endpoint
         | 
| 17 | 
            +
                    %r{/v2/organizations/[^/]+/users/[^/]+$}
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Organizations
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_create
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_created_organization")
         | 
| 8 | 
            +
                    stub_post(collection_endpoint, {}, response(201, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def summary_fixture
         | 
| 12 | 
            +
                    Helper.load_fixtures("fake_cc_organization_summary")
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def fail_to_find(org_id)
         | 
| 16 | 
            +
                    stub_get(%r{/v2/organizations/#{org_id}}, {}, response(404, {:code => 30003, :description => "The organization could not be found"}))
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def succeed_to_load_summary(options={})
         | 
| 20 | 
            +
                    response_body = summary_fixture
         | 
| 21 | 
            +
                    response_body["spaces"] = [] if options[:no_spaces]
         | 
| 22 | 
            +
                    stub_get(%r{/v2/organizations/[^/]+/summary$}, {}, response(200, response_body))
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def succeed_to_search(name)
         | 
| 26 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_organization_search")
         | 
| 27 | 
            +
                    stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:#{name}$}, {}, response(200, response_body))
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def succeed_to_search_none
         | 
| 31 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_empty_search")
         | 
| 32 | 
            +
                    stub_get(%r{/v2/organizations\?inline-relations-depth=1&q=name:.*$}, {}, response(200, response_body))
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def domains_fixture
         | 
| 36 | 
            +
                    Helper.load_fixtures("fake_cc_organization_domains")
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def domain_fixture_hash
         | 
| 40 | 
            +
                    MultiJson.load(domains_fixture["resources"].first.to_json, :symbolize_keys => true)
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def succeed_to_load_domains
         | 
| 44 | 
            +
                    stub_get(%r{/v2/organizations/[^/]+/domains\?inline-relations-depth=1}, {}, response(200, domains_fixture))
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  def users_fixture
         | 
| 48 | 
            +
                    Helper.load_fixtures("fake_cc_organization_users")
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  def user_fixture_hash
         | 
| 52 | 
            +
                    MultiJson.load(users_fixture["resources"].first.to_json, :symbolize_keys => true)
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def succeed_to_load_users
         | 
| 56 | 
            +
                    stub_get(%r{/v2/organizations/[^\/]+/users\?inline-relations-depth=1}, {}, response(200, users_fixture))
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  private
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  def object_endpoint
         | 
| 62 | 
            +
                    %r{/v2/organizations/[^/]+$}
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  def collection_endpoint
         | 
| 66 | 
            +
                    %r{/v2/organizations\/?(\?.+)?$}
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Routes
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_load_none
         | 
| 7 | 
            +
                    stub_get(collection_endpoint, {}, response(200, {:resources => []}))
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def succeed_to_create
         | 
| 11 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_created_route")
         | 
| 12 | 
            +
                    stub_post(collection_endpoint, {}, response(201, response_body))
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  private
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def collection_endpoint
         | 
| 18 | 
            +
                    %r{/v2/routes/?.*$}
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def object_endpoint
         | 
| 22 | 
            +
                    %r{/v2/routes/[^/]+$}
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module Runtimes
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_load
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_runtimes")
         | 
| 8 | 
            +
                    stub_get(collection_endpoint, {}, response(200, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def fail_to_load
         | 
| 12 | 
            +
                    stub_get(collection_endpoint, {}, response(500))
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  private
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def collection_endpoint
         | 
| 18 | 
            +
                    %r{/v2/runtimes\?inline-relations-depth=1$}
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module ServiceBindings
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_create
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_service_binding")
         | 
| 8 | 
            +
                    stub_post(collection_endpoint, {}, response(201, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  private
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def object_endpoint
         | 
| 14 | 
            +
                    %r{/v2/service_bindings/[^/]+$}
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def collection_endpoint
         | 
| 18 | 
            +
                    %r{/v2/service_bindings$}
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module CcApiStub
         | 
| 2 | 
            +
              module ServiceInstances
         | 
| 3 | 
            +
                extend Helper
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class << self
         | 
| 6 | 
            +
                  def succeed_to_create
         | 
| 7 | 
            +
                    response_body = Helper.load_fixtures("fake_cc_created_service_instance")
         | 
| 8 | 
            +
                    stub_post(collection_endpoint, {}, response(201, response_body))
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  private
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def object_endpoint
         | 
| 14 | 
            +
                    %r{/v2/service_instances/[^/]+$}
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def collection_endpoint
         | 
| 18 | 
            +
                    %r{/v2/service_instances$}
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         |