Supporting tags in KMS (#2332)
The CreateKey API method accepts tags but does not return them.
This commit is contained in:
parent
5dbdff7ca7
commit
348dc54e6a
5 changed files with 71 additions and 21 deletions
|
|
@ -11,21 +11,29 @@ import sure # noqa
|
|||
from moto import mock_kms, mock_kms_deprecated
|
||||
from nose.tools import assert_raises
|
||||
from freezegun import freeze_time
|
||||
from datetime import date
|
||||
from datetime import datetime
|
||||
from dateutil.tz import tzutc
|
||||
|
||||
|
||||
@mock_kms_deprecated
|
||||
@mock_kms
|
||||
def test_create_key():
|
||||
conn = boto.kms.connect_to_region("us-west-2")
|
||||
conn = boto3.client('kms', region_name='us-east-1')
|
||||
with freeze_time("2015-01-01 00:00:00"):
|
||||
key = conn.create_key(policy="my policy",
|
||||
description="my key", key_usage='ENCRYPT_DECRYPT')
|
||||
key = conn.create_key(Policy="my policy",
|
||||
Description="my key",
|
||||
KeyUsage='ENCRYPT_DECRYPT',
|
||||
Tags=[
|
||||
{
|
||||
'TagKey': 'project',
|
||||
'TagValue': 'moto',
|
||||
},
|
||||
])
|
||||
|
||||
key['KeyMetadata']['Description'].should.equal("my key")
|
||||
key['KeyMetadata']['KeyUsage'].should.equal("ENCRYPT_DECRYPT")
|
||||
key['KeyMetadata']['Enabled'].should.equal(True)
|
||||
key['KeyMetadata']['CreationDate'].should.equal("1420070400")
|
||||
key['KeyMetadata']['CreationDate'].should.be.a(date)
|
||||
|
||||
|
||||
@mock_kms_deprecated
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ from __future__ import unicode_literals
|
|||
|
||||
import boto3
|
||||
import sure # noqa
|
||||
from moto import mock_resourcegroupstaggingapi, mock_s3, mock_ec2, mock_elbv2
|
||||
from moto import mock_ec2
|
||||
from moto import mock_elbv2
|
||||
from moto import mock_kms
|
||||
from moto import mock_resourcegroupstaggingapi
|
||||
from moto import mock_s3
|
||||
|
||||
|
||||
@mock_s3
|
||||
|
|
@ -225,10 +229,12 @@ def test_get_tag_values_ec2():
|
|||
|
||||
@mock_ec2
|
||||
@mock_elbv2
|
||||
@mock_kms
|
||||
@mock_resourcegroupstaggingapi
|
||||
def test_get_resources_elbv2():
|
||||
conn = boto3.client('elbv2', region_name='us-east-1')
|
||||
def test_get_many_resources():
|
||||
elbv2 = boto3.client('elbv2', region_name='us-east-1')
|
||||
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
||||
kms = boto3.client('kms', region_name='us-east-1')
|
||||
|
||||
security_group = ec2.create_security_group(
|
||||
GroupName='a-security-group', Description='First One')
|
||||
|
|
@ -242,7 +248,7 @@ def test_get_resources_elbv2():
|
|||
CidrBlock='172.28.7.0/26',
|
||||
AvailabilityZone='us-east-1b')
|
||||
|
||||
conn.create_load_balancer(
|
||||
elbv2.create_load_balancer(
|
||||
Name='my-lb',
|
||||
Subnets=[subnet1.id, subnet2.id],
|
||||
SecurityGroups=[security_group.id],
|
||||
|
|
@ -259,13 +265,27 @@ def test_get_resources_elbv2():
|
|||
]
|
||||
)
|
||||
|
||||
conn.create_load_balancer(
|
||||
elbv2.create_load_balancer(
|
||||
Name='my-other-lb',
|
||||
Subnets=[subnet1.id, subnet2.id],
|
||||
SecurityGroups=[security_group.id],
|
||||
Scheme='internal',
|
||||
)
|
||||
|
||||
kms.create_key(
|
||||
KeyUsage='ENCRYPT_DECRYPT',
|
||||
Tags=[
|
||||
{
|
||||
'TagKey': 'key_name',
|
||||
'TagValue': 'a_value'
|
||||
},
|
||||
{
|
||||
'TagKey': 'key_2',
|
||||
'TagValue': 'val2'
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
rtapi = boto3.client('resourcegroupstaggingapi', region_name='us-east-1')
|
||||
|
||||
resp = rtapi.get_resources(ResourceTypeFilters=['elasticloadbalancer:loadbalancer'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue