Sha256: d7b65f8f95d61f358c060d51ca00c11a339a7a795a358d5a42c64bf61983e240

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

require "spec_helper"

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

  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://api." + a1_domain)
        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://api." + a1_domain
        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

9 entries across 9 versions & 1 rubygems

Version Path
cfoundry-4.0.2.rc4 spec/integration/client_spec.rb
cfoundry-4.0.2.rc3 spec/integration/client_spec.rb
cfoundry-4.0.2.rc2 spec/integration/client_spec.rb
cfoundry-4.0.2.rc1 spec/integration/client_spec.rb
cfoundry-4.0.1 spec/integration/client_spec.rb
cfoundry-4.0.0 spec/integration/client_spec.rb
cfoundry-3.0.1 spec/integration/client_spec.rb
cfoundry-3.0.0 spec/integration/client_spec.rb
cfoundry-2.4.1.rc1 spec/integration/client_spec.rb