Sha256: 512f615ed350e4d82aa0954c52d0aa52ae92f7ef9721b4c97e88e3be79a9ead2

Contents?: true

Size: 1.32 KB

Versions: 44

Compression:

Stored size: 1.32 KB

Contents

require "spec_helper"

describe CFoundry::V2::Client do
  before do
    WebMock.allow_net_connect!
  end

  let(:environment_api) { ENV["CF_V2_TEST_TARGET"] || "api.#{a1_domain}"}
  let(:a1_domain) { "a1.cf-app.com" }
  let(:prod_domain) { "run.pivotal.io" }

  describe "setting a new target" do
    it "switches the target cc" do
      client = CFoundry::V2::Client.new("http://api." + a1_domain)
      auth_endpoint = client.info[:authorization_endpoint]
      expect(auth_endpoint).to match a1_domain

      client.target = "http://api." + prod_domain
      auth_endpoint = client.info[:authorization_endpoint]
      expect(auth_endpoint).to match prod_domain
    end

    if ENV["CF_V2_RUN_INTEGRATION"]
      it "requires a re-login" do
        client = CFoundry::V2::Client.new("http://#{environment_api}")
        client.login({username: ENV["CF_V2_TEST_USER"], password: ENV["CF_V2_TEST_PASSWORD"]})
        client.quota_definitions # Getting quota definitions will always be the shortest request that requires auth

        client.target = nil
        client.target = "http://#{environment_api}"
        expect { client.quota_definitions }.to raise_error(CFoundry::InvalidAuthToken)

        client.login({username: ENV["CF_V2_TEST_USER"], password: ENV["CF_V2_TEST_PASSWORD"]})
        client.quota_definitions
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 3 rubygems

Version Path
new_cfoundry-4.9.3 spec/integration/client_spec.rb
ncfoundry-4.9.4 spec/integration/client_spec.rb
ncfoundry-4.9.3 spec/integration/client_spec.rb
ncfoundry-4.9.2 spec/integration/client_spec.rb
new_cfoundry-4.9.2 spec/integration/client_spec.rb
new_cfoundry-4.9.1 spec/integration/client_spec.rb
new_cfoundry-4.9.0 spec/integration/client_spec.rb
new_cfoundry-4.8.3 spec/integration/client_spec.rb
new_cfoundry-4.8.2 spec/integration/client_spec.rb
cfoundry-4.7.2.rc1 spec/integration/client_spec.rb
cfoundry-4.7.1 spec/integration/client_spec.rb
cfoundry-4.7.1.rc1 spec/integration/client_spec.rb
cfoundry-4.7.0 spec/integration/client_spec.rb
cfoundry-4.6.3.rc3 spec/integration/client_spec.rb
cfoundry-4.6.3.rc2 spec/integration/client_spec.rb
cfoundry-4.6.3.rc1 spec/integration/client_spec.rb
cfoundry-4.6.2 spec/integration/client_spec.rb
cfoundry-4.6.1 spec/integration/client_spec.rb
cfoundry-4.6.0 spec/integration/client_spec.rb
cfoundry-4.5.3 spec/integration/client_spec.rb