spec/config_spec.rb in simple_deploy-0.9.2 vs spec/config_spec.rb in simple_deploy-0.10.0.beta.1

- old
+ new

@@ -2,13 +2,14 @@ describe SimpleDeploy::Configuration do let(:config_data) do { 'environments' => { 'test_env' => { - 'secret_key' => 'secret', - 'access_key' => 'access', - 'region' => 'us-west-1' + 'access_key' => 'access', + 'secret_key' => 'secret', + 'security_token' => 'token', + 'region' => 'us-west-1' } }, 'notifications' => { 'campfire' => { 'token' => 'my_token' } } } @@ -47,10 +48,38 @@ @config = @the_module.configure 'test_env' @config.environment.should == config_data['environments']['test_env'] @config.notifications.should == config_data['notifications'] end + describe 'when the environment is :read_from_env' do + before do + ENV['AWS_ACCESS_KEY_ID'] = 'env_access' + ENV['AWS_REGION'] = 'env_region' + ENV['AWS_SECRET_ACCESS_KEY'] = 'env_secret' + ENV['AWS_SECURITY_TOKEN'] = 'env_token' + + @data = { + 'access_key' => 'env_access', + 'region' => 'env_region', + 'secret_key' => 'env_secret', + 'security_token' => 'env_token' + } + end + + after do + %w(ACCESS_KEY_ID REGION SECRET_ACCESS_KEY SECURITY_TOKEN).each do |i| + ENV["AWS_#{i}"] = nil + end + end + + it 'loads the config from env vars' do + @config = @the_module.configure :read_from_env + @config.environment.should eq(@data) + @config.notifications.should eq({}) + end + end + end describe "after creating a configuration" do before do @the_module = SimpleDeploy::Configuration @@ -71,10 +100,11 @@ it "should return the environment requested" do env_config = @config.environment env_config['access_key'].should == 'access' env_config['secret_key'].should == 'secret' + env_config['security_token'].should == 'token' env_config['region'].should == 'us-west-1' end it "should return the notifications available" do @config.notifications.should == ( { 'campfire' => { 'token' => 'my_token' } } ) @@ -86,17 +116,34 @@ it "should return the secret_key for the environment" do @config.secret_key.should == 'secret' end + it "should return the security token for the environment" do + @config.security_token.should == 'token' + end + it "should return the region for the environment" do @config.region.should == 'us-west-1' end it "should return the deploy script" do @config.deploy_script.should == '/opt/intu/admin/bin/configure.sh' end + describe 'temporary_credentials?' do + it 'is true when they are' do + @config.temporary_credentials?.should be_true + end + + describe 'when there is not a security token' do + it 'is false when they are not' do + config_data['environments']['test_env']['security_token'] = nil + @config = @the_module.configure 'test_env', config: config_data + @config.temporary_credentials?.should be_false + end + end + end end describe 'showing raw configuration for all instances' do before do @the_module = SimpleDeploy::Configuration