aws_cred_vault 0.0.1 → 0.0.2

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: 8f18052c7c70445d864dc5f74b4a2d1bc14385ab
4
- data.tar.gz: d63f2499210a770bee24c3ab9c5ef9b75b643b73
3
+ metadata.gz: 307b3e31e8b93bb5c886d47336d815aff0a7735f
4
+ data.tar.gz: f542140f62254af624cec4932ab6e26e3a9db4a9
5
5
  SHA512:
6
- metadata.gz: 34ca2bfe6e4f92449f48bce23f2bc6f53a6bb15bb86b317c36157e449cc41d7f023b22621222b40d5e28b4f33790219447482d931bc07eab2d2f26a8905420a3
7
- data.tar.gz: 2871e70be9fe85efeff6597db498d209337107b4f6f961af40fe9719ca6bbf926b674c769bd2e2328fd6eec90a5935a2eb81678571a92c998c5bbd42a0c086c9
6
+ metadata.gz: 1e86e295c4d63175d3d8369a4e6827fe3ce191d83b83cfc4294d96e6a41ffedfb6d250b19d4d03b36dd6d135fe1cf31d1a2e506d951d984eb37d1679b4893982
7
+ data.tar.gz: ade788fd581eaaeccb3e104f0dd65c164dbd1d2ad79cdd2d33f5a9a5c8fd7dbf56dd5fc205d71943a3ad350cd6fb9a19f33e5b905f35db98b8c43a25ae60d40e
@@ -0,0 +1,15 @@
1
+ require_relative 'user'
2
+
3
+ module AwsCredVault
4
+ class Account
5
+ attr_reader :name, :users
6
+ def initialize name
7
+ @name = name
8
+ @users = []
9
+ end
10
+
11
+ def add_user user
12
+ @users << user
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,5 @@
1
1
  require 'toml'
2
+ require_relative 'account'
2
3
 
3
4
  module AwsCredVault
4
5
  class Toml
@@ -8,11 +9,17 @@ module AwsCredVault
8
9
  end
9
10
 
10
11
  def accounts
11
- toml["accounts"] || {}
12
+ account_hash.map do |name, user_list|
13
+ account = Account.new name
14
+ user_list.each do |name, credentials|
15
+ account.add_user User.new name, credentials[:access_key], credentials[:secret]
16
+ end
17
+ account
18
+ end
12
19
  end
13
20
 
14
21
  def add_account site, name, access_key, secret
15
- new_accounts = accounts || {}
22
+ new_accounts = account_hash || {}
16
23
  new_accounts[site] = {
17
24
  name => {
18
25
  'access_key' => access_key,
@@ -28,6 +35,10 @@ module AwsCredVault
28
35
  ::TOML.load_file(file)
29
36
  end
30
37
 
38
+ def account_hash
39
+ toml["accounts"] || {}
40
+ end
41
+
31
42
  def save accounts
32
43
  File.open file, 'w' do |file|
33
44
  file.write(::TOML::Generator.new(accounts).body)
@@ -0,0 +1,20 @@
1
+
2
+ module AwsCredVault
3
+ class User
4
+ attr_reader :name, :access_key, :secret
5
+
6
+ def initialize name, access_key, secret
7
+ @name = name
8
+ @access_key = access_key
9
+ @secret = secret
10
+ end
11
+
12
+ def credentials
13
+ {
14
+ aws_access_key_id: access_key,
15
+ aws_secret_access_key: secret
16
+ }
17
+ end
18
+ end
19
+
20
+ end
@@ -1,3 +1,3 @@
1
1
  module AwsCredVault
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require "aws_cred_vault/version"
2
+ require 'aws_cred_vault/account'
3
+ require 'aws_cred_vault/user'
2
4
  require 'aws_cred_vault/toml'
3
5
 
4
6
  module AwsCredVault
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe AwsCredVault::Account do
4
+ describe 'name' do
5
+ let(:account) { AwsCredVault::Account.new 'test' }
6
+
7
+ it 'has the right name' do
8
+ expect(account.name).to eq 'test'
9
+ end
10
+ end
11
+
12
+ describe 'add_user' do
13
+ let(:account) { AwsCredVault::Account.new 'test' }
14
+ let(:user) { AwsCredVault::User.new 'test_user', 'id', 'key' }
15
+
16
+ subject { account.add_user user }
17
+
18
+ it 'adds the user' do
19
+ expect { subject }.to change {account.users.length}.by(1)
20
+ end
21
+ end
22
+ end
@@ -22,7 +22,7 @@ describe AwsCredVault::Toml do
22
22
  let(:file) { '/notthing/here' }
23
23
 
24
24
  it 'has no accounts' do
25
- expect(subject).to eq({})
25
+ expect(subject).to eq([])
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe AwsCredVault::User do
4
+ let(:user) { AwsCredVault::User.new 'test', 'id', 'key' }
5
+
6
+ describe 'name' do
7
+ it 'has the right name' do
8
+ expect(user.name).to eq 'test'
9
+ end
10
+ end
11
+
12
+ describe 'credentials' do
13
+ subject { user.credentials }
14
+
15
+ it 'adds the user' do
16
+
17
+ expect(subject).to eq(
18
+ {
19
+ aws_access_key_id: 'id',
20
+ aws_secret_access_key: 'key'
21
+ }
22
+ )
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_cred_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clarke Brunsdon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml
@@ -80,10 +80,14 @@ files:
80
80
  - Rakefile
81
81
  - aws_cred_vault.gemspec
82
82
  - lib/aws_cred_vault.rb
83
+ - lib/aws_cred_vault/account.rb
83
84
  - lib/aws_cred_vault/toml.rb
85
+ - lib/aws_cred_vault/user.rb
84
86
  - lib/aws_cred_vault/version.rb
85
87
  - spec/files/accounts.toml
86
- - spec/lib/aws_cred_vault/toml.rb
88
+ - spec/lib/aws_cred_vault/account_spec.rb
89
+ - spec/lib/aws_cred_vault/toml_spec.rb
90
+ - spec/lib/aws_cred_vault/user_spec.rb
87
91
  - spec/lib/aws_cred_vault_spec.rb
88
92
  - spec/spec_helper.rb
89
93
  homepage: ''
@@ -112,6 +116,8 @@ specification_version: 4
112
116
  summary: Stores your amazon credentials for multiple IAM accounts.
113
117
  test_files:
114
118
  - spec/files/accounts.toml
115
- - spec/lib/aws_cred_vault/toml.rb
119
+ - spec/lib/aws_cred_vault/account_spec.rb
120
+ - spec/lib/aws_cred_vault/toml_spec.rb
121
+ - spec/lib/aws_cred_vault/user_spec.rb
116
122
  - spec/lib/aws_cred_vault_spec.rb
117
123
  - spec/spec_helper.rb