-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from k1LoW/add-type-iam_group
Add iam_group type
- Loading branch information
Showing
8 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Awspec::Generator | ||
module Doc | ||
module Type | ||
class IamGroup < Base | ||
def initialize | ||
super | ||
@type_name = 'IamGroup' | ||
@type = Awspec::Type::IamGroup.new('my-iam-group') | ||
@ret = @type.resource | ||
@matchers = [] | ||
@ignore_matchers = [] | ||
@describes = [] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Aws.config[:iam] = { | ||
stub_responses: { | ||
list_groups: { | ||
groups: [ | ||
path: '/', | ||
group_name: 'my-iam-group', | ||
group_id: 'GABCDEFGHI123455689', | ||
arn: 'arn:aws:iam::123456789012:group/my-iam-group', | ||
create_date: Time.local(2015) | ||
] | ||
}, | ||
list_users: { | ||
users: [ | ||
path: '/', | ||
user_name: 'my-iam-user', | ||
user_id: 'ABCDEFGHI1234556890', | ||
arn: 'arn:aws:iam::123456789012:user/my-iam-user', | ||
create_date: Time.local(2015) | ||
] | ||
}, | ||
list_groups_for_user: { | ||
groups: [ | ||
{ | ||
path: '/', | ||
group_name: 'my-iam-group', | ||
group_id: 'GABCDEFGHI123455689', | ||
arn: 'arn:aws:iam::123456789012:group/my-iam-group', | ||
create_date: Time.local(2015) | ||
} | ||
] | ||
}, | ||
list_attached_group_policies: { | ||
attached_policies: [ | ||
{ | ||
policy_arn: 'arn:aws:iam::aws:policy/ReadOnlyAccess', | ||
policy_name: 'ReadOnlyAccess' | ||
} | ||
], | ||
is_truncated: false, | ||
maker: nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Awspec::Type | ||
class IamGroup < Base | ||
def initialize(id) | ||
super | ||
@resource = find_iam_group(id) | ||
@id = @resource[:group_id] if @resource | ||
end | ||
|
||
def has_iam_user?(user_id) | ||
user = find_iam_user(user_id) | ||
return false unless user | ||
user_name = user[:user_name] | ||
groups = select_iam_group_by_user_name(user_name) | ||
groups.find do |group| | ||
group.group_id == @id | ||
end | ||
end | ||
|
||
def has_iam_policy?(policy_id) | ||
policies = select_iam_policy_by_group_name(@resource[:group_name]) | ||
policies.find do |policy| | ||
policy.policy_arn == policy_id || policy.policy_name == policy_id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'spec_helper' | ||
Awspec::Stub.load 'iam_group' | ||
|
||
describe iam_group('my-iam-group') do | ||
it { should exist } | ||
it { should have_iam_user('my-iam-user') } | ||
it { should have_iam_policy('ReadOnlyAccess') } | ||
end |