예제 #1
0
 def test_ingress_rule_loading(self):
     with patch("domino_cdk.config.util.log.warning") as warn:
         rules = [{
             "name": "some_rule",
             "from_port": 22,
             "to_port": 22,
             "protocol": "TCP",
             "ip_cidrs": ["10.0.0.0/16"]
         }]
         loaded_rules = IngressRule.load_rules("some_name", rules)
         self.assertEqual(
             loaded_rules,
             [IngressRule("some_rule", 22, 22, "TCP", ["10.0.0.0/16"])])
         warn.assert_not_called()
예제 #2
0
 def test_ingress_rule_loading_extra_args(self):
     with patch("domino_cdk.config.util.log.warning") as warn:
         rules = [{
             "name": "some_rule",
             "from_port": 22,
             "to_port": 22,
             "protocol": "TCP",
             "ip_cidrs": ["10.0.0.0/16"],
             "extra": "boing",
         }]
         loaded_rules = IngressRule.load_rules("some_name", rules)
         self.assertEqual(
             loaded_rules,
             [IngressRule("some_rule", 22, 22, "TCP", ["10.0.0.0/16"])])
         warn.assert_called_with(
             "Warning: Unused/unsupported ingress rules in some_name: [{'extra': 'boing'}]"
         )
예제 #3
0
 def test_ingress_rule_loading_extra_args(self):
     with patch("domino_cdk.config.util.log.warning") as warn:
         rules = deepcopy(ingress_rules)
         rules[0]["extra"] = "boing"
         loaded_rules = IngressRule.load_rules("some_name", rules)
         self.assertEqual(loaded_rules, [ingress_rule_object])
         warn.assert_called_with(
             "Warning: Unused/unsupported ingress rules in some_name: [{'extra': 'boing'}]"
         )
예제 #4
0
    create=True,
    id=None,
    cidr="10.0.0.0/24",
    availability_zones=[],
    max_azs=3,
    bastion=VPC.Bastion(enabled=False,
                        key_name=None,
                        instance_type=None,
                        ingress_ports=None,
                        machine_image=None),
)
bastion_object = VPC.Bastion(
    enabled=True,
    key_name=None,
    instance_type="t2.micro",
    ingress_ports=[IngressRule("ssh", 22, 22, "TCP", ["0.0.0.0/0"])],
    machine_image=MachineImage("ami-1234abcd", "some-user-data"),
)


class TestConfigVPC(unittest.TestCase):
    def test_from_0_0_0(self):
        with patch("domino_cdk.config.util.log.warning") as warn:
            vpc = VPC.from_0_0_0(deepcopy(vpc_0_0_0_cfg))
            warn.assert_not_called()
            self.assertEqual(vpc, vpc_object)

    def test_from_0_0_1(self):
        with patch("domino_cdk.config.util.log.warning") as warn:
            vpc = VPC.from_0_0_1(deepcopy(vpc_0_0_1_cfg))
            warn.assert_not_called()
예제 #5
0
 def test_ingress_rule_loading_none(self):
     loaded_rules = IngressRule.load_rules("some_name", None)
     self.assertEqual(loaded_rules, None)
예제 #6
0
 tags={'domino-infrastructure': 'true'},
 install={},
 vpc=VPC(
     id=None,
     create=True,
     cidr='10.0.0.0/16',
     availability_zones=[],
     max_azs=3,
     bastion=VPC.Bastion(
         enabled=False,
         key_name=None,
         instance_type='t2.micro',
         ingress_ports=[
             IngressRule(name='ssh',
                         from_port=22,
                         to_port=22,
                         protocol='TCP',
                         ip_cidrs=['0.0.0.0/0'])
         ],
         machine_image=None,
     ),
 ),
 efs=EFS(
     backup=EFS.Backup(
         enable=True,
         schedule='0 12 * * ? *',
         move_to_cold_storage_after=35,
         delete_after=125,
         removal_policy=False,
     ),
     removal_policy_destroy=False,
예제 #7
0
 def test_ingress_rule_loading(self):
     with patch("domino_cdk.config.util.log.warning") as warn:
         loaded_rules = IngressRule.load_rules("some_name",
                                               deepcopy(ingress_rules))
         self.assertEqual(loaded_rules, [ingress_rule_object])
         warn.assert_not_called()
예제 #8
0
import unittest
from copy import deepcopy
from unittest.mock import patch

from domino_cdk.config import IngressRule
from domino_cdk.config.util import check_leavins, from_loader

ingress_rules = [{
    "name": "some_rule",
    "from_port": 22,
    "to_port": 22,
    "protocol": "TCP",
    "ip_cidrs": ["10.0.0.0/16"]
}]

ingress_rule_object = IngressRule("some_rule", 22, 22, "TCP", ["10.0.0.0/16"])


class TestConfigUtil(unittest.TestCase):
    def test_from_loader(self):
        with patch("domino_cdk.config.util.log.warning") as warn:
            test_thing = "arbitrary_variable"
            x = from_loader("myname", test_thing, {})
            warn.assert_not_called()
            self.assertEqual(x, test_thing)

    def test_from_loader_warning(self):
        with patch("domino_cdk.config.util.log.warning") as warn:
            test_thing = "arbitrary_variable"
            x = from_loader("myname", test_thing, {'boing': 'peng'})
            warn.assert_called_with(