Merge pull request #1879 from mikegrima/iamgroupfixes
Fixes for IAM Groups
This commit is contained in:
commit
e20d08435b
@ -255,7 +255,15 @@ class Group(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def arn(self):
|
def arn(self):
|
||||||
return "arn:aws:iam::{0}:group/{1}".format(ACCOUNT_ID, self.path)
|
if self.path == '/':
|
||||||
|
return "arn:aws:iam::{0}:group/{1}".format(ACCOUNT_ID, self.name)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return "arn:aws:iam::{0}:group/{1}/{2}".format(ACCOUNT_ID, self.path, self.name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def create_date(self):
|
||||||
|
return self.created
|
||||||
|
|
||||||
def get_policy(self, policy_name):
|
def get_policy(self, policy_name):
|
||||||
try:
|
try:
|
||||||
|
@ -285,7 +285,7 @@ class IamResponse(BaseResponse):
|
|||||||
|
|
||||||
def create_group(self):
|
def create_group(self):
|
||||||
group_name = self._get_param('GroupName')
|
group_name = self._get_param('GroupName')
|
||||||
path = self._get_param('Path')
|
path = self._get_param('Path', '/')
|
||||||
|
|
||||||
group = iam_backend.create_group(group_name, path)
|
group = iam_backend.create_group(group_name, path)
|
||||||
template = self.response_template(CREATE_GROUP_TEMPLATE)
|
template = self.response_template(CREATE_GROUP_TEMPLATE)
|
||||||
@ -1007,6 +1007,7 @@ CREATE_GROUP_TEMPLATE = """<CreateGroupResponse>
|
|||||||
<GroupName>{{ group.name }}</GroupName>
|
<GroupName>{{ group.name }}</GroupName>
|
||||||
<GroupId>{{ group.id }}</GroupId>
|
<GroupId>{{ group.id }}</GroupId>
|
||||||
<Arn>{{ group.arn }}</Arn>
|
<Arn>{{ group.arn }}</Arn>
|
||||||
|
<CreateDate>{{ group.create_date }}</CreateDate>
|
||||||
</Group>
|
</Group>
|
||||||
</CreateGroupResult>
|
</CreateGroupResult>
|
||||||
<ResponseMetadata>
|
<ResponseMetadata>
|
||||||
@ -1021,6 +1022,7 @@ GET_GROUP_TEMPLATE = """<GetGroupResponse>
|
|||||||
<GroupName>{{ group.name }}</GroupName>
|
<GroupName>{{ group.name }}</GroupName>
|
||||||
<GroupId>{{ group.id }}</GroupId>
|
<GroupId>{{ group.id }}</GroupId>
|
||||||
<Arn>{{ group.arn }}</Arn>
|
<Arn>{{ group.arn }}</Arn>
|
||||||
|
<CreateDate>{{ group.create_date }}</CreateDate>
|
||||||
</Group>
|
</Group>
|
||||||
<Users>
|
<Users>
|
||||||
{% for user in group.users %}
|
{% for user in group.users %}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import boto
|
import boto
|
||||||
import boto3
|
import boto3
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
@ -25,6 +28,25 @@ def test_get_group():
|
|||||||
conn.get_group('not-group')
|
conn.get_group('not-group')
|
||||||
|
|
||||||
|
|
||||||
|
@mock_iam()
|
||||||
|
def test_get_group_current():
|
||||||
|
conn = boto3.client('iam', region_name='us-east-1')
|
||||||
|
conn.create_group(GroupName='my-group')
|
||||||
|
result = conn.get_group(GroupName='my-group')
|
||||||
|
|
||||||
|
assert result['Group']['Path'] == '/'
|
||||||
|
assert result['Group']['GroupName'] == 'my-group'
|
||||||
|
assert isinstance(result['Group']['CreateDate'], datetime)
|
||||||
|
assert result['Group']['GroupId']
|
||||||
|
assert result['Group']['Arn'] == 'arn:aws:iam::123456789012:group/my-group'
|
||||||
|
assert not result['Users']
|
||||||
|
|
||||||
|
# Make a group with a different path:
|
||||||
|
other_group = conn.create_group(GroupName='my-other-group', Path='some/location')
|
||||||
|
assert other_group['Group']['Path'] == 'some/location'
|
||||||
|
assert other_group['Group']['Arn'] == 'arn:aws:iam::123456789012:group/some/location/my-other-group'
|
||||||
|
|
||||||
|
|
||||||
@mock_iam_deprecated()
|
@mock_iam_deprecated()
|
||||||
def test_get_all_groups():
|
def test_get_all_groups():
|
||||||
conn = boto.connect_iam()
|
conn = boto.connect_iam()
|
||||||
|
Loading…
Reference in New Issue
Block a user