source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/route_mappings_spec.rb
Ruby
apache-2.0
203
main
9,600
require 'spec_helper' RSpec.describe 'RouteMappings' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } before do space.organization.add_user(user) space.add_developer(user) TestConfig.override(kubernetes: {}) end describe 'GET /v2/route_mapping...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/apps_spec.rb
Ruby
apache-2.0
203
main
88,733
require 'spec_helper' require 'diego/lrp_constants' RSpec.describe 'Apps' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } let(:build_client) { instance_double(HTTPClient, post: nil) } before do space.organization.add_user(user) space.add_developer(u...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/service_keys_spec.rb
Ruby
apache-2.0
203
main
5,523
require 'spec_helper' RSpec.describe 'ServiceKeys' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } before do space.organization.add_user(user) space.add_developer(user) end describe 'GET /v2/service_keys' do let(:service_instance) { VCAP::Clo...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/shared_domains_spec.rb
Ruby
apache-2.0
203
main
9,942
require 'spec_helper' RSpec.describe 'SharedDomains' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } before do space.organization.add_user(user) space.add_developer(user) UAARequests.stub_all stub_request(:get, 'http://localhost:3000/routing...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/service_brokers_spec.rb
Ruby
apache-2.0
203
main
6,240
require 'spec_helper' RSpec.describe 'ServiceBrokers' do describe 'PUT /v2/service_brokers' do context 'when ccng fails to parse the service broker endpoint' do let!(:service_broker) { VCAP::CloudController::ServiceBroker.make } before do stub_request(:get, 'https://broker.example.com/v2/cat...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/space_quota_definitions_spec.rb
Ruby
apache-2.0
203
main
1,291
require 'spec_helper' RSpec.describe 'SpaceQuotaDefinitions' do let(:user) { VCAP::CloudController::User.make } let(:org) { VCAP::CloudController::Organization.make } describe 'PUT /v2/space_quota_definitions/guid/spaces/space_guid' do context 'when the quota has a finite log rate limit and there are apps w...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/service_instances_spec.rb
Ruby
apache-2.0
203
main
27,528
require 'spec_helper' RSpec.describe 'ServiceInstances' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } before do space.organization.add_user(user) space.add_developer(user) end describe 'POST /v2/service_instances' do let(:service_plan) { VC...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/service_plans_spec.rb
Ruby
apache-2.0
203
main
4,268
require 'spec_helper' RSpec.describe 'ServicePlans' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } let(:service) { VCAP::CloudController::Service.make } let!(:service_plan) do VCAP::CloudController::ServicePlan.make( service: service, maint...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/services_spec.rb
Ruby
apache-2.0
203
main
5,887
require 'spec_helper' RSpec.describe 'Services' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } before do space.organization.add_user(user) space.add_developer(user) end describe 'GET /v2/services' do let!(:service_1) { VCAP::CloudController:...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/v2/auth_spec.rb
Ruby
apache-2.0
203
main
5,469
require 'spec_helper' require 'request_spec_shared_examples' RSpec.describe 'Auth' do let(:user) { VCAP::CloudController::User.make } let(:user_header) { headers_for(user) } before do allow(ENV).to receive(:fetch).with('CC_TEST', nil).and_return(nil) allow(ENV).to receive(:fetch).and_call_original end...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/internal/log_access_spec.rb
Ruby
apache-2.0
203
main
804
require 'spec_helper' require 'request_spec_shared_examples' RSpec.describe 'Internal Log Access Endpoint' do let(:user) { VCAP::CloudController::User.make } let(:space) { VCAP::CloudController::Space.make } let(:org) { space.organization } let(:app_model) { VCAP::CloudController::AppModel.make(space:) } de...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/internal/asg_update_timestamp_spec.rb
Ruby
apache-2.0
203
main
596
require 'spec_helper' require 'request_spec_shared_examples' RSpec.describe 'App Security Group Update Timestamp' do let(:user) { VCAP::CloudController::User.make(guid: 'user-guid') } let(:admin_header) { admin_headers_for(user) } describe 'GET /internal/v4/asg_latest_update' do it 'returns a timestamp' do ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/internal/metrics_spec.rb
Ruby
apache-2.0
203
main
8,849
require 'spec_helper' RSpec.describe 'Metrics' do let(:user) { VCAP::CloudController::User.make } let(:user_header) { headers_for(user) } let(:metrics_webserver) { VCAP::CloudController::ApiMetricsWebserver.new } let(:periodic_updater) { CloudController::DependencyLocator.instance.periodic_updater } delegat...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/lifecycle/service_route_bindings_synoptic_spec.rb
Ruby
apache-2.0
203
main
5,169
require 'spec_helper' require 'cloud_controller' # This lifecycle test aims to use different v3 service endpoints together RSpec.describe 'V3 service route bindings synoptic' do before do stub_request(:get, 'http://example.org/amazing-service-broker/v2/catalog'). with(basic_auth: %w[admin password]). ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/lifecycle/service_credential_bindings_synoptic_spec.rb
Ruby
apache-2.0
203
main
4,741
require 'spec_helper' require 'cloud_controller' # This lifecycle test aims to use different v3 service endpoints together RSpec.describe 'V3 service credential bindings synoptic' do before do stub_request(:get, 'http://example.org/amazing-service-broker/v2/catalog'). with(basic_auth: %w[admin password]). ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/lifecycle/service_brokers_spec.rb
Ruby
apache-2.0
203
main
15,648
require 'spec_helper' require 'request_spec_shared_examples' require 'cloud_controller' require 'services' require 'messages/service_broker_update_message' # The request specs test single actions. # The lifecycle tests are about combinations of actions RSpec.describe 'V3 service brokers' do let(:catalog) do { ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/request/lifecycle/services_synoptic_spec.rb
Ruby
apache-2.0
203
main
5,199
require 'spec_helper' require 'request_spec_shared_examples' require 'cloud_controller' require 'services' require 'messages/service_broker_update_message' # This lifecycle test aims to use different v3 service endpoints together # rubocop:disable Naming/AccessorMethodName RSpec.describe 'V3 services synoptic' do be...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/temp_file_creator.rb
Ruby
apache-2.0
203
main
418
module TempFileCreator def self.included(spec) spec.after do delete_created_temp_files end end def temp_file_with_content(content=Sham.guid) file = Tempfile.new('a_file') file.write(content) file.flush @created_temp_files ||= [] @created_temp_files << file file end def ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/fake_loggregator_server.rb
Ruby
apache-2.0
203
main
947
require 'grpc' require 'loggregator-api/v2/ingress_services_pb' class FakeLoggregatorServer attr_reader :port def initialize(port) @port = port @envelopes = [] @mutex = Mutex.new end def start service = FakeIngressService.new(@envelopes, @mutex) @server = GRPC::RpcServer.new @server.a...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/service_broker_helpers.rb
Ruby
apache-2.0
203
main
6,614
module ServiceBrokerHelpers def stub_provision(broker, opts={}, &block) url = provision_url_for_broker(broker, accepts_incomplete: opts[:accepts_incomplete]) status = opts[:status] || 201 body = opts[:body] || '{}' if block stub_request(:put, url).to_return(&block) else stub_request(:p...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/broker_api_helper.rb
Ruby
apache-2.0
203
main
12,584
module VCAP::CloudController::BrokerApiHelper def service_name 'MySQL' end def stubbed_broker_url "http://#{stubbed_broker_host}" end def stubbed_broker_host 'broker-url' end def stubbed_broker_username 'username' end def stubbed_broker_password 'password' end def stub_cat...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/fake_uaa_server.rb
Ruby
apache-2.0
203
main
833
require 'webrick' class FakeUAAServer attr_reader :thread, :server def initialize(port) @server = WEBrick::HTTPServer.new( BindAddress: 'localhost', Port: port, AccessLog: [], Logger: WEBrick::Log.new(File::NULL) ) server.mount '/.well-known/openid-configuration', UAAIssuer ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/paths.rb
Ruby
apache-2.0
203
main
226
module Paths FIXTURES = File.expand_path('../fixtures', File.dirname(__FILE__)) ARTIFACTS = File.expand_path('../artifacts', File.dirname(__FILE__)) CONFIG = File.expand_path('../../config', File.dirname(__FILE__)) end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/lifecycle_tests_helpers.rb
Ruby
apache-2.0
203
main
5,874
module LifecycleSpecHelper BINDINGS_ENDPOINT = '/v3/service_credential_bindings/'.freeze def create_org org_request_body = { name: 'my-organization' } post '/v3/organizations', org_request_body.to_json, admin_headers expect(last_response).to have_status_code(201) parsed_response['guid'] end d...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/database_isolation.rb
Ruby
apache-2.0
203
main
823
module DatabaseIsolation def self.choose(isolation, db) case isolation when :truncation TruncateTables.new(db) else RollbackTransaction.new end end class TruncateTables def initialize(db) @db = db end def cleanly yield ensure reset_tables end ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/log_helpers.rb
Ruby
apache-2.0
203
main
773
module LogHelpers class TailedLogs def initialize(io_log) @io_log = io_log end def read @io_log.string.split("\n").map { |l| Oj.load(l) } end end def tail_logs(&block) steno_config_backup = ::Steno.config begin io_log = ::StringIO.new io_sink = ::Steno::Sink::IO....
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/rack_test_monkey_patch.rb
Ruby
apache-2.0
203
main
599
module Rack module Test class Session private alias_method :orig_env_for, :env_for def env_for(uri, env) params = env[:params] new_env = orig_env_for(uri, env) if %w[GET DELETE].include?(env[:method]) # merge :params with the query string if params.p...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/avoid_relying_on_id_order.rb
Ruby
apache-2.0
203
main
330
# Ensures that entries are not returned ordered by the id field by # default. Breaks the tests (deliberately) unless we order by id # explicitly. In postgres the order is random unless specified. class VCAP::CloudController::ProcessModel set_dataset dataset.order(:"#{VCAP::CloudController::ProcessModel.table_name}__g...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/legacy_api_dsl.rb
Ruby
apache-2.0
203
main
10,086
require 'active_support/concern' module LegacyApiDsl extend ActiveSupport::Concern def validate_response(model, json, expected_values: {}, ignored_attributes: [], expected_attributes: nil) ignored_attributes.push :guid, :options (expected_attributes || expected_attributes_for_model(model)).each do |expect...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/controller_helpers.rb
Ruby
apache-2.0
203
main
3,036
module ControllerHelpers include VCAP::CloudController def self.description_for_inline_depth(depth, pagination=50) if depth "?inline-relations-depth=#{depth}&results-per-page=#{pagination}" else '' end end def query_params_for_inline_depth(depth, pagination=50) if depth { 'in...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/test_models.rb
Ruby
apache-2.0
203
main
4,903
require 'access/base_access' require 'controllers/base/model_controller' module VCAP::CloudController class TestModelDestroyDep < Sequel::Model; end class TestModelNullifyDep < Sequel::Model; end class TestModelManyToOne < Sequel::Model many_to_one :test_model export_attributes :test_model_guid end c...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/stepper.rb
Ruby
apache-2.0
203
main
6,562
# This class is used to instrument and test concurrent behaviour of our code. # It helps finding race-conditions, DB deadlocks and lock timeouts. # # To use it, you'll need to instrument some of your methods with steps before and after. # Usually, you'll need to instrument database calls or calls to 3rd party services....
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/referential_integrity.rb
Ruby
apache-2.0
203
main
706
class ReferentialIntegrity def initialize(db) @db = db end def without(&) case db.database_type when :postgres without_referential_integrity_postgres(&) when :mysql without_referential_integrity_mysql(&) end end private attr_reader :db def without_referential_integrity_...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/link_helpers.rb
Ruby
apache-2.0
203
main
278
require 'support/bootstrap/test_config' module LinkHelpers include VCAP::CloudController def link_prefix "#{scheme}://#{host}" end private def scheme TestConfig.config[:external_protocol] end def host TestConfig.config[:external_domain] end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/integration_helpers.rb
Ruby
apache-2.0
203
main
506
module IntegrationHelpers def org_with_default_quota(authed_headers) quota = make_get_request( '/v2/quota_definitions?q=name%3Adefault', authed_headers ) default_quota_guid = quota.json_body['resources'][0]['metadata']['guid'] make_post_request( '/v2/organizations', { ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/test_tgz.rb
Ruby
apache-2.0
203
main
468
require 'zlib' require 'rubygems/package' module TestTgz def self.create(tgz_name, file_count, file_size=1024, &) File.open(tgz_name, 'wb') do |file| Zlib::GzipWriter.wrap(file) do |gzip| Gem::Package::TarWriter.new(gzip) do |tar| file_count.times do |i| tar.add_file_simple("z...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/rspec_api_documentation_patch.rb
Ruby
apache-2.0
203
main
406
# Monkey patch to provide a robust read_request_body helper compatible with Rack 3 # See: # https://github.com/zipmark/rspec_api_documentation/pull/550 # https://github.com/zipmark/rspec_api_documentation/issues/548 module RspecApiDocumentation class ClientBase def read_request_body input = last_request.en...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/request_spec_helper.rb
Ruby
apache-2.0
203
main
388
module RequestSpecHelper ENV['RACK_ENV'] = 'test' def app test_config = TestConfig.config_instance request_metrics = VCAP::CloudController::Metrics::RequestMetrics.new request_logs = VCAP::CloudController::Logs::RequestLogs.new(Steno.logger('request.logs')) VCAP::CloudController::RackAppBuil...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/tmpdir_cleaner.rb
Ruby
apache-2.0
203
main
525
class TmpdirCleaner def self.dir_paths @dir_paths ||= [] end def self.clean_later(dir_path) dir_path = File.realpath(dir_path) tmpdir_path = File.realpath(Dir.tmpdir) raise ArgumentError.new("dir '#{dir_path}' is not in #{tmpdir_path}") unless dir_path.start_with?(tmpdir_path) dir_paths << ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/test_zip.rb
Ruby
apache-2.0
203
main
342
require 'zip' module TestZip def self.create(zip_name, file_count, file_size=1024, &blk) Zip::File.open(zip_name, create: true) do |zipfile| file_count.times do |i| zipfile.get_output_stream("ziptest_#{i}") do |f| f.write('A' * file_size) end end blk.call(zipfile) if ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/uaa_requests.rb
Ruby
apache-2.0
203
main
763
module UAARequests def self.stub_all # stub token request WebMock::API.stub_request(:post, 'https://uaa.service.cf.internal/oauth/token').to_return( status: 200, body: { token_type: 'token-type', access_token: 'access-token' }.to_json, headers: { 'content-type' => 'application/json' } ) ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/and_record_arguments.rb
Ruby
apache-2.0
203
main
476
require 'rspec/mocks' module RSpec module Mocks class MessageExpectation def and_record_arguments arg_recorder = ArgumentRecorder.new self.argument_list_matcher = arg_recorder arg_recorder.arguments end end class ArgumentRecorder < ArgumentListMatcher attr_reade...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/api_dsl.rb
Ruby
apache-2.0
203
main
985
require 'active_support/concern' module RspecApiDocumentation class Example def has_body_parameters? respond_to?(:body_parameters) && body_parameters.present? end def has_parameter_type? body_parameters.each do |parameter| return true unless parameter[:parameter_type].nil? end ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/tables.rb
Ruby
apache-2.0
203
main
202
class Tables def initialize(db, tables) @db = db @tables = tables end def counts @tables.inject({}) do |counts, table| counts.merge(table => @db[table].count) end end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/model_creation.rb
Ruby
apache-2.0
203
main
2,357
module ModelCreation def make_user_for_org(org) user = VCAP::CloudController::User.make user.add_organization org org.refresh user end def make_domain_for_org(org) VCAP::CloudController::PrivateDomain.make(owning_organization: org) end def make_user_for_space(space) make_user_for_org...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/space_restricted_response_generators.rb
Ruby
apache-2.0
203
main
5,364
module SpaceRestrictedResponseGenerators def self.default_permitted_roles %w[ admin admin_read_only global_auditor space_developer space_manager space_auditor space_supporter org_manager ] end def self.default_write_permitted_roles %w[ admin ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/user_helpers.rb
Ruby
apache-2.0
203
main
11,024
module UserHelpers def set_current_user(user, opts={}) token_decoder = VCAP::CloudController::UaaTokenDecoder.new(TestConfig.config_instance.get(:uaa)) header_token = user ? "bearer #{user_token(user, opts)}" : nil token_information = opts[:token] || token_decoder.decode_token(header_token) VCAP::Clou...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/fake_nginx_reverse_proxy.rb
Ruby
apache-2.0
203
main
2,445
require 'rack/test' require 'tmpdir' class FakeNginxReverseProxy def initialize(app) @app = app end def call(env) tmpdir = nil if multipart?(env) form_hash = Rack::Multipart.parse_multipart(env.dup) tmpdir = Dir.mktmpdir('ngx.uploads') offload_files!(form_hash, tmpdir) offloa...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/test_cnb.rb
Ruby
apache-2.0
203
main
389
require 'zlib' require 'rubygems/package' module TestCnb def self.create(name, file_count, file_size=1024, &) File.open(name, 'wb') do |file| Gem::Package::TarWriter.new(file) do |tar| file_count.times do |i| tar.add_file_simple("test_#{i}", 0o644, file_size) do |f| f.write('A...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/user_header_helpers.rb
Ruby
apache-2.0
203
main
6,729
module UserHeaderHelpers def base_json_headers(headers={}) headers.merge({ 'CONTENT_TYPE' => 'application/json' }) end def set_user_with_header(user, opts={}) opts = { email: Sham.email, user_name: Sham.name, https: false }.merge(opts) headers = {} headers['HTTP_AUTHORIZATI...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/deprecation_helpers.rb
Ruby
apache-2.0
203
main
264
module DeprecationHelpers def it_should_be_removed(by:, explanation:) it 'is deprecated and should be removed' do skip 'Ignoring time bomb tests' if ENV['SKIP_TIME_BOMBS'] raise(explanation) if Time.zone.today >= Date.parse(by) end end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/table_truncator.rb
Ruby
apache-2.0
203
main
655
class TableTruncator def initialize(db, tables=nil) @db = db @tables = tables || self.class.isolated_tables(db) end def self.isolated_tables(db) db.tables - [:schema_migrations] end def truncate_tables referential_integrity = ReferentialIntegrity.new(db) referential_integrity.without do ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/machinist_monkey_patch.rb
Ruby
apache-2.0
203
main
227
require 'machinist/sequel' raise 'Tear down this monkey patch!' unless Machinist.const_defined?('SequelExtensions') module Machinist::SequelExtensions::ClassMethods def returning(value) yield(value) value end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/background_job_helpers.rb
Ruby
apache-2.0
203
main
1,187
module BackgroundJobHelpers include VCAP::CloudController def execute_all_jobs(expected_successes:, expected_failures:, jobs_to_execute: 100) # SecurityContext is not available for worker threads in production, so we clear it # for testing jobs to avoid false positives saved_user = VCAP::CloudControlle...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/time_helpers.rb
Ruby
apache-2.0
203
main
369
module TimeHelpers include VCAP::CloudController def iso8601 /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/ end # https://gist.github.com/marcelotmelo/b67f58a08bee6c2468f8 def rfc3339 /^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|(...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/integration/http.rb
Ruby
apache-2.0
203
main
2,142
require 'net/http' require 'uri' module IntegrationHttp def auth_token(opts) token = { 'user_id' => opts[:user_id], 'aud' => 'cloud_controller', 'exp' => Time.now.utc.to_i + 10_000, 'scope' => opts[:scope], 'iss' => UAAIssuer::ISSUER, 'jti' => 'valid-jti' } CF::UAA::To...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/integration/setup.rb
Ruby
apache-2.0
203
main
2,841
require 'English' module IntegrationSetup CC_START_TIMEOUT = 60 SLEEP_INTERVAL = 0.5 def start_cc(opts={}) @cc_pids ||= [] config_file = opts[:config] || 'config/cloud_controller.yml' config = VCAP::CloudController::YAMLConfig.safe_load_file(config_file) FileUtils.rm(config['pid_filename']) if...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/v3_service_binding_create.rb
Ruby
apache-2.0
203
main
14,792
require 'spec_helper' require 'services/service_brokers/v2/errors/service_broker_bad_response' require 'services/service_brokers/v2/errors/service_broker_request_rejected' require 'cloud_controller/http_request_error' RSpec.shared_examples 'service binding creation' do |binding_model| describe '#bind' do let(:se...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/v3_service_binding_delete.rb
Ruby
apache-2.0
203
main
10,661
require 'db_spec_helper' require 'services/service_brokers/v2/errors/service_broker_bad_response' require 'services/service_brokers/v2/errors/service_broker_request_rejected' require 'cloud_controller/http_request_error' RSpec.shared_examples 'service binding deletion' do |binding_model| describe '#delete' do le...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/request/suspended_orgs_permissions.rb
Ruby
apache-2.0
203
main
1,320
RSpec.shared_examples 'permissions for create endpoint when organization is suspended' do |success_code, suspended_roles| before do org.update(status: VCAP::CloudController::Organization::SUSPENDED) end it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS do let(:expected_codes_and_r...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/request/last_operation_response_handling.rb
Ruby
apache-2.0
203
main
3,052
RSpec.shared_examples 'binding last operation response handling' do |operation_type| context 'failure http codes' do valid_responses = [ { code: 400, body: { description: 'helpful message' } }, { code: 200, body: { state: 'failed', description: 'something went wrong' } } ] valid_responses.eac...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/request/bindings_create.rb
Ruby
apache-2.0
203
main
15,693
RSpec.shared_examples 'service credential binding create endpoint' do |klass, check_app, audit_event_type, display_name| describe 'managed instance' do let(:api_call) { ->(user_headers) { post '/v3/service_credential_bindings', create_body.to_json, user_headers } } let(:job) { VCAP::CloudController::PollableJ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/request/bindings_orphan_mitigation.rb
Ruby
apache-2.0
203
main
9,955
RSpec.shared_examples 'create binding orphan mitigation' do let(:job) { VCAP::CloudController::PollableJobModel.last } let(:bind_response_body) { '{}' } let(:broker_bind_status_code) { 200 } before do stub_request(:delete, bind_url). with(query: { accepts_incomplete: true, p...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/request/service_brokers.rb
Ruby
apache-2.0
203
main
2,076
RSpec.shared_examples 'a successful broker delete' do before do clear_events delete "/v3/service_brokers/#{broker.guid}", {}, user_headers end it 'returns 204 No Content' do expect(last_response).to have_status_code(204) end it 'deletes the broker' do expect(subject).not_to find_broker(broke...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/jobs/delete_binding_job.rb
Ruby
apache-2.0
203
main
6,608
require 'support/shared_examples/jobs/delayed_job' require 'jobs/v3/delete_service_binding_job_factory' RSpec.shared_examples 'delete binding job' do |binding_type| it_behaves_like 'delayed job', described_class let(:subject) do described_class.new( binding_type, binding.guid, user_audit_inf...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/jobs/delayed_job.rb
Ruby
apache-2.0
203
main
1,357
RSpec.shared_examples 'delayed job' do |job_class| raise 'Please provide a job_class argument' unless job_class describe 'behaves like a delayed job' do it 'does not store complicated objects' do job = create_job(job_class) serialized = job.to_yaml complicated_objects_count = serialized.sca...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/jobs/create_binding_job.rb
Ruby
apache-2.0
203
main
7,582
require 'support/shared_examples/jobs/delayed_job' require 'jobs/v3/create_service_binding_job_factory' RSpec.shared_examples 'create binding job' do |binding_type| it_behaves_like 'delayed job', described_class let(:subject) do described_class.new( binding_type, binding.guid, parameters: pa...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/controllers/permissions.rb
Ruby
apache-2.0
203
main
3,201
RSpec.shared_context 'permissions' do before do @org_a = VCAP::CloudController::Organization.make @org_a_manager = VCAP::CloudController::User.make @org_a_member = VCAP::CloudController::User.make @org_a_billing_manager = VCAP::CloudController::User.make @org_a_auditor = VCAP::CloudController::Use...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/controllers/resource_pool.rb
Ruby
apache-2.0
203
main
1,850
RSpec.shared_context 'resource pool' do before(:all) do @max_file_size = 1098 # this is arbitrary num_dirs = 3 num_unique_allowed_files_per_dir = 7 file_duplication_factor = 2 @total_allowed_files = num_dirs * num_unique_allowed_files_per_dir * file_duplication_factor @nonexisting_desc...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/access/access_levels.rb
Ruby
apache-2.0
203
main
2,694
RSpec.shared_examples 'full access' do it { is_expected.to allow_op_on_object :create, object } it { is_expected.to allow_op_on_object :read, object } it { is_expected.to allow_op_on_object :read_for_update, object } it { is_expected.to allow_op_on_object :update, object } it { is_expected.to allow_op_on_obje...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/access/access_spec_helper.rb
Ruby
apache-2.0
203
main
2,954
RSpec.shared_examples 'an access control' do |operation, table, expected_error=nil| describe "#{operation}? and #{operation}_with_token?" do table.each do |role, expected_return_value| it "returns #{expected_return_value} if user is a(n) #{role}" do o = respond_to?(:org) ? org : nil s = resp...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/models/ignored_unique_constraint_violation_errors.rb
Ruby
apache-2.0
203
main
1,293
RSpec::Matchers.define :have_primary_key_constraint do |table_name, constraint_name| match do |db| !db.fetch('SELECT 1 AS one FROM information_schema.table_constraints ' \ "WHERE constraint_type = 'PRIMARY KEY' " \ "AND table_name = '#{table_name}' " \ "AND constraint_nam...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/models/stager_interface.rb
Ruby
apache-2.0
203
main
348
module VCAP::CloudController RSpec.shared_examples 'a stager' do it 'defines #stage' do expect(subject).to respond_to(:stage) end it 'defines #stop_stage' do expect(subject).to respond_to(:stop_stage) end it 'defines #staging_complete' do expect(subject).to respond_to(:staging_...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/models/encrypted_attribute.rb
Ruby
apache-2.0
203
main
2,654
require 'cloud_controller/encryptor' module VCAP::CloudController RSpec.shared_examples 'a model with an encrypted attribute' do before do allow(Encryptor).to receive(:database_encryption_keys). and_return({ Encryptor.current_encryption_key_label.to_sym => 'correct-key' }) end def new_mode...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/models/domain_validation.rb
Ruby
apache-2.0
203
main
5,399
module VCAP::CloudController RSpec.shared_examples_for 'domain validation' do context 'when the name is not present' do before { subject.name = nil } it { is_expected.not_to be_valid } it 'fails to validate' do subject.validate expect(subject.errors[:name]).to include(:presence...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/models/operations.rb
Ruby
apache-2.0
203
main
1,362
RSpec.shared_examples 'operation' do let(:updated_at_time) { Time.utc(2018, 5, 2, 3, 30, 0) } let(:created_at_time) { Time.utc(2018, 5, 2, 3, 30, 0) } let(:operation_attributes) do { state: 'in progress', description: '10%', type: 'create' } end let(:operation) { described_class.mak...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/messages/pagination_validation.rb
Ruby
apache-2.0
203
main
2,614
RSpec.shared_examples_for 'a page validator' do describe 'page' do it 'is invalid if page is a string' do message = described_class.new page: 'a string' expect(message).not_to be_valid expect(message.errors[:page]).to include('must be a positive integer') end it 'is invalid if page is 0...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/shared_examples/middleware/rate_limiting.rb
Ruby
apache-2.0
203
main
583
RSpec.shared_examples_for 'exempted from rate limiting' do |header_suffix=''| it 'exempts them from rate limiting' do allow(ActionDispatch::Request).to receive(:new).and_return(fake_request) if defined?(fake_request) _, response_headers, = middleware.call(env) expect(expiring_request_counter).not_to have_...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_attributes.rb
Ruby
apache-2.0
203
main
3,789
RSpec::Matchers.define :have_creatable_attributes do |attributes| match do |controller| create_message = controller.const_get(:CreateMessage) @attribute_validator = AttributeValidator.new(create_message, attributes, 'creatable') @attribute_validator.valid? end failure_message do |actual| @attribu...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/sequel_validations.rb
Ruby
apache-2.0
203
main
2,132
RSpec::Matchers.define :validate_presence do |attribute, options={}| description do "validate presence of #{attribute}" end match do |instance| unless instance.valid? errors = instance.errors.on(attribute) expected_error = options[:message] || :presence errors && errors.include?(expected...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_timestamp_columns.rb
Ruby
apache-2.0
203
main
209
RSpec::Matchers.define :have_timestamp_columns do description do 'have timestamp columns' end match do |instance| instance.respond_to?(:created_at) && instance.respond_to?(:updated_at) end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/model_extensions.rb
Ruby
apache-2.0
203
main
1,120
RSpec::Matchers.define :strip_whitespace do |attribute| description do "strip #{attribute}" end match do |instance| instance[attribute] = ' foo ' instance[attribute] == 'foo' end end RSpec::Matchers.define :export_attributes do |*attributes| failure_message do |_actual| instance = described_c...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_status_code.rb
Ruby
apache-2.0
203
main
582
RSpec::Matchers.define :have_status_code do |expected_code| match do |response| status_code_for(response) == expected_code end failure_message do |response| body = Oj.dump(Oj.load(response.body)) "Expected #{expected_code} response, got:\n code: #{status_code_for(response)}\n body: \"#{body}\"" res...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/be_reported_as_events.rb
Ruby
apache-2.0
203
main
375
RSpec::Matchers.define :be_reported_as_events do events = [] match do |expected_events| events = VCAP::CloudController::Event.all.sort_by(&:type).map { |e| { type: e.type, actor: e.actor_name } } expected_events.all? do |e| events.include?(e) end end failure_message do "Expected events we...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/allow_op_on_object.rb
Ruby
apache-2.0
203
main
262
RSpec::Matchers.define :allow_op_on_object do |op, object| match do |access| access.can?(:"#{op}_with_token", object) && access.can?(op, object) end failure_message do "Expected to be able to perform operation #{op} on object #{object}" end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/be_queryable_by.rb
Ruby
apache-2.0
203
main
203
RSpec::Matchers.define :be_queryable_by do |attribute| description do "is queryable by #{attribute}" end match do |controller| controller.query_parameters.include? attribute.to_s end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/be_a_valid_job.rb
Ruby
apache-2.0
203
main
308
RSpec::Matchers.define :be_a_valid_job do problems = [] match do |actual_job| problems << 'max_attempts not implemented' unless actual_job.respond_to?(:max_attempts) problems.empty? end failure_message do |_actual_job| "Not a valid Job. Problems were:\n" + problems.join("\n") end end
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/find_broker.rb
Ruby
apache-2.0
203
main
406
RSpec::Matchers.define :find_broker do |expected| match do get("/v3/service_brokers/#{expected[:broker_guid]}", {}, expected[:with] || nil) last_response.status == 200 end failure_message do "expected broker with GUID '#{expected[:broker_guid]}' to be found" end failure_message_when_negated do ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_associated.rb
Ruby
apache-2.0
203
main
945
RSpec::Matchers.define :have_associated do |association, options={}| description do "have associated #{association}" end match do |_| instance = options[:test_instance] instance ||= described_class.make associated_instance = get_associated_instance(instance, association, options) if associati...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/match_broker.rb
Ruby
apache-2.0
203
main
2,946
RSpec::Matchers.define :match_broker do |expected| problems = [] match do |actual| problems << "Expected #{actual['url']} to be equal to #{expected.broker_url}" unless actual['url'] == expected.broker_url problems << "Expected #{actual['created_at']} to be equal to #{expected.created_at.iso8601}" unless ac...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/match_app.rb
Ruby
apache-2.0
203
main
2,351
RSpec::Matchers.define :match_app do |expected_app| problems = [] match do |actual_event| problems << "event.state: #{actual_event.state}, app.state: #{expected_app.state}" unless actual_event.state == expected_app.state unless actual_event.package_state == expected_app.package_state problems << "even...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/match_service_instance.rb
Ruby
apache-2.0
203
main
2,983
RSpec::Matchers.define :match_service_instance do |expected_service_instance| problems = [] space = expected_service_instance.space match do |actual_event| unless actual_event.org_guid == space.organization_guid problems << "event.org_guid: #{actual_event.org_guid}, service_instance.space.organization_...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/include_error_message.rb
Ruby
apache-2.0
203
main
530
RSpec::Matchers.define :include_error_message do |expected_code| match do |response| error_messages = error_messages(response) if expected_code.is_a?(Regexp) error_messages.any?(a_string_matching(expected_code)) else error_messages.any?(a_string_including(expected_code)) end end failu...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/be_a_response_like.rb
Ruby
apache-2.0
203
main
3,093
require 'hashdiff' RSpec::Matchers.define :be_a_response_like do |expected, problem_keys=[]| define_method :init_problem_keys do @problem_keys ||= problem_keys # rubocop:disable Naming/MemoizedInstanceVariableName end define_method :bad_key! do |key| @problem_keys << key end define_method :truncate...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/be_a_fully_wrapped_job_of.rb
Ruby
apache-2.0
203
main
966
RSpec::Matchers.define :be_a_fully_wrapped_job_of do |expected_job_class| match do |actual_job| next_job = actual_job.payload_object return false unless next_job.is_a? VCAP::CloudController::Jobs::LoggingContextJob next_job = next_job.handler return false unless next_job.is_a? VCAP::CloudController::...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_error_message.rb
Ruby
apache-2.0
203
main
484
RSpec::Matchers.define :have_error_message do |expected_code| match do |response| error_message = error_message(response) if expected_code.is_a?(Regexp) error_message.match(expected_code) else error_message.include?(expected_code) end end failure_message do |response| "Expected er...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_warning_message.rb
Ruby
apache-2.0
203
main
348
RSpec::Matchers.define :have_warning_message do |expected_message| match do |actual| unescaped_header = CGI.unescape(actual.headers['X-Cf-Warnings']) unescaped_header == expected_message end failure_message do |actual| "expected that #{actual.headers} to have a header [X-Cf-Warnings: #{expected_messa...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/match_json.rb
Ruby
apache-2.0
203
main
348
RSpec::Matchers.define :match_json do |expected| # RSpect matcher? if expected.respond_to?(:matches?) match do |json| actual = Oj.load(json) expected.matches?(actual) end # regular values or RSpec Mocks argument matchers else match do |json| actual = Oj.load(json) expected ...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/have_labels.rb
Ruby
apache-2.0
203
main
1,115
RSpec::Matchers.define :have_labels do |*expected| actual_labels = [] match do |actual| actual_labels = actual.labels.map do |label| { prefix: label.key_prefix, key_name: label.key_name, value: label.value } end if expected.any? expected = expected.map do |lab...
github
cloudfoundry/cloud_controller_ng
https://github.com/cloudfoundry/cloud_controller_ng
spec/support/matchers/match_json_response.rb
Ruby
apache-2.0
203
main
1,894
require 'hashdiff' RSpec::Matchers.define :match_json_response do |expected| match do |actual| actual = actual.deep_symbolize_keys expect(actual).to match(expected.deep_symbolize_keys) end summary = [] exception = nil failure_message do |actual| actual = actual.deep_symbolize_keys begin ...