spec/lib/api_spec.rb in conjur-api-4.3.0 vs spec/lib/api_spec.rb in conjur-api-4.4.0
- old
+ new
@@ -1,35 +1,36 @@
require 'spec_helper'
shared_examples_for "API endpoint" do
+ before { Conjur.configuration = Conjur::Configuration.new }
subject { api }
let(:service_name) { api.name.split('::')[-2].downcase }
context "in development" do
before(:each) do
- Conjur.stub(:env).and_return "development"
+ Conjur::Configuration.any_instance.stub(:env).and_return "development"
end
- its "default_host" do
- should == "http://localhost:#{Conjur.service_base_port + port_offset}"
+ its "host" do
+ should == "http://localhost:#{Conjur.configuration.service_base_port + port_offset}"
end
end
context "'ci' account" do
before {
- Conjur.stub(:account).and_return 'ci'
+ Conjur::Configuration.any_instance.stub(:account).and_return 'ci'
}
context "in stage" do
before(:each) do
- Conjur.stub(:env).and_return "stage"
+ Conjur::Configuration.any_instance.stub(:env).and_return "stage"
end
- its "default_host" do
+ its "host" do
should == "https://#{service_name}-ci-conjur.herokuapp.com"
end
end
context "in ci" do
before(:each) do
- Conjur.stub(:env).and_return "ci"
+ Conjur::Configuration.any_instance.stub(:env).and_return "ci"
end
- its "default_host" do
+ its "host" do
should == "https://#{service_name}-ci-conjur.herokuapp.com"
end
end
end
end
@@ -109,10 +110,11 @@
end
end
end
context "host construction" do
+ before { Conjur.configuration = Conjur::Configuration.new }
context "of authn service" do
let(:port_offset) { 0 }
let(:api) { Conjur::Authn::API }
it_should_behave_like "API endpoint"
end
@@ -120,55 +122,53 @@
let(:port_offset) { 100 }
let(:api) { Conjur::Authz::API }
subject { api }
context "'ci' account" do
before {
- Conjur.stub(:account).and_return 'ci'
+ Conjur::Configuration.any_instance.stub(:account).and_return 'ci'
}
context "in stage" do
before(:each) do
# Looks at "ENV['CONJUR_STACK']" first, stub this out
ENV.stub(:[]).with('CONJUR_STACK').and_return nil
- Conjur.stub(:env).and_return "stage"
+ Conjur::Configuration.any_instance.stub(:env).and_return "stage"
end
- its "default_host" do
+ its "host" do
should == "https://authz-stage-conjur.herokuapp.com"
end
end
context "in ci" do
before(:each) do
# Looks at "ENV['CONJUR_STACK']" first, stub this out
ENV.stub(:[]).with('CONJUR_STACK').and_return nil
- Conjur.stub(:env).and_return "ci"
+ Conjur::Configuration.any_instance.stub(:env).and_return "ci"
end
- its "default_host" do
+ its "host" do
should == "https://authz-ci-conjur.herokuapp.com"
end
end
context "when ENV['CONJUR_STACK'] is set to 'v12'" do
before do
- ENV.stub(:[]).and_call_original
- ENV.stub(:[]).with('CONJUR_STACK').and_return 'v12'
- # If the "real" env is used ('test') then the URL is always localhost:<someport>
- Conjur.stub(:env).and_return "ci"
+ Conjur::Configuration.any_instance.stub(:stack).and_return "v12"
+ Conjur::Configuration.any_instance.stub(:env).and_return "ci"
end
- its(:default_host){ should == "https://authz-v12-conjur.herokuapp.com"}
+ its(:host){ should == "https://authz-v12-conjur.herokuapp.com"}
end
end
context "in production" do
before(:each) do
- Conjur.stub(:env).and_return "production"
+ Conjur::Configuration.any_instance.stub(:env).and_return "production"
end
- its "default_host" do
+ its "host" do
should == "https://authz-v4-conjur.herokuapp.com"
end
end
context "in named production version" do
before(:each) do
- Conjur.stub(:env).and_return "production"
- Conjur.stub(:stack).and_return "waffle"
+ Conjur::Configuration.any_instance.stub(:env).and_return "production"
+ Conjur::Configuration.any_instance.stub(:stack).and_return "waffle"
end
- its "default_host" do
+ its "host" do
should == "https://authz-waffle-conjur.herokuapp.com"
end
end
end
context "of core service" do