aws_runas 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 166b3e595ae6aa7dd121a945715a9eff29aae90c
4
- data.tar.gz: 76ce3d0b5522a93ce950bf849cfebc0227b068c0
3
+ metadata.gz: b42c61f6910d824c789cda5dfd180ee21526a4eb
4
+ data.tar.gz: 633b4c171c180074c8236fadbb0b1fd228d28286
5
5
  SHA512:
6
- metadata.gz: 3cf889367e458ed4ba71c87e2e263acfb56a1399a4bdb0bde55cc26fab7f237a67e0af8f3a5026972bf869f37e87c9dfef753cfbd9bffa6872f3e6e074c8c630
7
- data.tar.gz: c3e14f375de48a3260680376c23c1622c75bfa0e4ac78639a398a53b727d4a2d5a45d1fdeb3252700c184b3cbbe6e8c92298e5a125646543e27430aad3a32c68
6
+ metadata.gz: 89c0b88c7dc6ac5700b96934db1741c5a6847bb879d05675d6ab7d520d56a1e7ab4e169d216d77912c083062b59043f5596de9f4a51a7c872043f46b07f977e2
7
+ data.tar.gz: 950a1ab391f0508b074a824937ded7948b99137022b0d3b8fa69dc93ef5b43f00965e4f7cd1a0406b6937e17c2cb183378ab14ad7b2a24f75f98d4cdbb388881
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  aws_runas CHANGELOG
2
2
  ====================
3
3
 
4
+ 0.1.3 (Fri 27 Nov 2015 08:05:45 PST)
5
+ -------------------------------------
6
+
7
+ * Fixed #3 (better handling of invalid profile name).
8
+ * Added guard for invalid file as well.
9
+
4
10
  0.1.2 (Wed 25 Nov 2015 09:09:09 PST)
5
11
  -------------------------------------
6
12
 
@@ -29,6 +29,7 @@ module AwsRunAs
29
29
  def initialize(path:, profile:)
30
30
  @path = path
31
31
  @path = self.class.find_config_file unless @path
32
+ fail(Errno::ENOENT, "#{@path}") unless File.exist?(@path.to_s)
32
33
  @profile = profile
33
34
  end
34
35
 
@@ -36,8 +37,10 @@ module AwsRunAs
36
37
  def load_config_value(key:)
37
38
  section = @profile
38
39
  section = "profile #{@profile}" unless @profile == 'default'
39
- aws_config = IniFile.load(@path) if File.exist?(@path)
40
- nil unless aws_config
40
+ aws_config = IniFile.load(@path)
41
+ unless aws_config.has_section?(section)
42
+ fail(NameError, "Profile #{@profile} not found in #{@path}")
43
+ end
41
44
  aws_config[section][key]
42
45
  end
43
46
 
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module AwsRunAs
16
- VERSION = '0.1.2'
16
+ VERSION = '0.1.3'
17
17
  end
@@ -81,4 +81,28 @@ describe AwsRunAs::Config do
81
81
  end
82
82
  end
83
83
  end
84
+
85
+ context 'with profile set to an invalid profile' do
86
+ before(:context) do
87
+ @cfg = AwsRunAs::Config.new(path: MOCK_AWS_CONFIGPATH, profile: 'bad-profile')
88
+ end
89
+
90
+ describe '#load_config_value' do
91
+ it 'raises a NameError when a value load is attempted' do
92
+ expect { @cfg.load_config_value(key: 'region') }.to raise_error(NameError)
93
+ end
94
+ end
95
+ end
96
+
97
+ context 'with an invalid config file supplied' do
98
+ describe '#load_config_value' do
99
+ it 'raises a Errno::ENOENT error' do
100
+ expect do
101
+ AwsRunAs::Config.new(
102
+ path: '/bad/path/here', profile: 'default'
103
+ )
104
+ end.to raise_error(Errno::ENOENT)
105
+ end
106
+ end
107
+ end
84
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_runas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Marchesi
@@ -31,7 +31,7 @@ cert_chain:
31
31
  reriQxVYXGlD8ZDuaKlDyVqUbF026ZHIlHKIgg90O037qFPxCBACTtxtYTP2hwug
32
32
  Yis=
33
33
  -----END CERTIFICATE-----
34
- date: 2015-11-25 00:00:00.000000000 Z
34
+ date: 2015-11-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aws-sdk
metadata.gz.sig CHANGED
Binary file