Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import unittest
from stacker.blueprints.testutil import BlueprintTestCase
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.generic import GenericResourceCreator
class TestGenericResourceCreator(BlueprintTestCase):
def setUp(self):
self.ctx = Context(config=Config({'namespace': 'test'}))
def test_create_template(self):
blueprint = GenericResourceCreator(
'test_generic_GenericResourceCreator', self.ctx
)
blueprint.resolve_variables(
[
Variable('Class', 'ec2.Volume'),
Variable('Output', 'VolumeId'),
Variable('Properties', {
'VolumeType': 'gp2',
'Size': '600',
'Encrypted': 'true',
'AvailabilityZone': 'us-east-1b',
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.route53 import (
DNSRecords,
get_record_set_md5,
)
from stacker.blueprints.testutil import BlueprintTestCase
class TestRoute53(BlueprintTestCase):
def setUp(self):
self.ctx = Context(config=Config({'namespace': 'test'}))
def test_create_template_hosted_zone_id(self):
blueprint = DNSRecords('route53_dnsrecords', self.ctx)
blueprint.resolve_variables(
[
Variable(
"RecordSets",
[
{
"Name": "host.testdomain.com.",
"Type": "A",
"ResourceRecords": ["10.0.0.1"],
},
{
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker.blueprints.testutil import BlueprintTestCase
import stacker_blueprints.dynamodb
class TestDynamoDB(BlueprintTestCase):
def setUp(self):
self.dynamodb_variables = [
Variable(
'Tables',
{
"UserTable": {
"TableName": "test-user-table",
"KeySchema": [
{
"AttributeName": "id",
"KeyType": "HASH",
},
{
"AttributeName": "name",
"KeyType": "RANGE",
},
import unittest
from stacker.context import Context, Config
from stacker.variables import Variable
from stacker_blueprints.s3 import Buckets
from stacker.blueprints.testutil import BlueprintTestCase
class TestBlueprint(BlueprintTestCase):
def setUp(self):
self.variables = [
Variable('Buckets', {
'Simple': {},
'Cycle': {
'LifecycleConfiguration': {
'Rules': [{
'Status': 'Enabled',
'ExpirationInDays': 40,
}],
},
}
}),
Variable('ReadRoles', [
'Role1',
'Role2',
],
'Tags': [{'Key': 'Foo', 'Value': 'Bar'}]
},
'EfsSg2': {
'GroupDescription': 'EFS SG 2',
'SecurityGroupIngress': [
{'IpProtocol': 'tcp', 'FromPort': 2049, 'ToPort': 2049,
'SourceSecurityGroupId': 'sg-11111111'}
]
}
},
'ExtraSecurityGroups': ['sg-22222222', 'sg-33333333']
}
class TestElasticFileSystem(BlueprintTestCase):
def setUp(self):
self.ctx = Context({'namespace': 'test'})
def test_create_template(self):
blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
variables = EFS_VARIABLES
blueprint.resolve_variables(
[Variable(k, v) for k, v in variables.items()])
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
def test_validate_security_group_count_empty(self):
blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
variables = EFS_VARIABLES.copy()
variables['SecurityGroups'] = {}
variables['ExtraSecurityGroups'] = []
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker_blueprints.sns import Topics
from stacker.blueprints.testutil import BlueprintTestCase
class TestBlueprint(BlueprintTestCase):
def setUp(self):
self.variables = [
Variable('Topics', {
'WithoutSubscription': {
'DisplayName': 'SampleTopicWithoutSub',
},
'Example': {
'DisplayName': 'ExampleTopic',
'Subscription': [
{
'Endpoint': 'arn:aws:sqs:us-east-1:123456788901:example-queue',
'Protocol': 'sqs',
},
{
'Endpoint': 'postmaster@example.com',
'Protocol': 'email',
import unittest
from stacker.context import Context
from stacker.variables import Variable
from stacker_blueprints.sqs import Queues
from stacker.blueprints.testutil import BlueprintTestCase
class TestBlueprint(BlueprintTestCase):
def setUp(self):
self.variables = [
Variable('Queues', {
'Simple': {
'DelaySeconds': 15,
'MaximumMessageSize': 4096,
'ReceiveMessageWaitTimeSeconds': 15,
'VisibilityTimeout': 600,
},
'Fifo': {
'FifoQueue': True,
'QueueName': 'Fifo.fifo',
},
'RedrivePolicy': {
'RedrivePolicy': {
'deadLetterTargetArn': 'arn:aws:sqs:us-east-1:123456789:dlq',
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.kms import Key
from stacker.blueprints.testutil import BlueprintTestCase
class TestKmsKey(BlueprintTestCase):
def setUp(self):
self.ctx = Context(config=Config({'namespace': 'test'}))
def test_kms_key(self):
blueprint = Key('kms_key_a', self.ctx)
blueprint.resolve_variables(
[
Variable("KeyAlias", "alias/a-test-key"),
Variable("Properties", {"Description": "a KMS test-key."}),
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
def test_kms_key_alias_not_in_keyalias(self):
blueprint = Key('kms_key_b', self.ctx)
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("AliasName", "prod"),
Variable("AliasVersion", "1")
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
class TestFunctionScheduler(BlueprintTestCase):
def setUp(self):
self.ctx = Context({'namespace': 'test'})
def test_create_template(self):
blueprint = FunctionScheduler('test_aws_lambda_FunctionScheduler',
self.ctx)
blueprint.resolve_variables(
[
Variable(
"CloudwatchEventsRule",
{
"MyTestFuncSchedule": {
"Description": "The AWS Lambda schedule for "
"my-powerful-test-function",
"ScheduleExpression": "rate(15 minutes)",
"State": "ENABLED",
import unittest
from stacker.blueprints.testutil import BlueprintTestCase
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.cloudwatch_logs import SubscriptionFilters
from troposphere import GetAtt, Ref
class TestSubscriptionFilters(BlueprintTestCase):
def setUp(self):
self.ctx = Context(config=Config({'namespace': 'test'}))
def test_create_template(self):
blueprint = SubscriptionFilters(
'test_cloudwatch_logs_subscription_filters',
self.ctx
)
blueprint.resolve_variables(
[
Variable(
"SubscriptionFilters",
{
"Filter1": {
"DestinationArn": GetAtt("KinesisStream1", "Arn"),