-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_rds_encrypt.py
74 lines (62 loc) · 2.07 KB
/
test_rds_encrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
import unittest
from unittest.mock import Mock
from rds_encrypt import (
check_kms,
check_database,
check_database_encryption,
check_snapshot,
encrypt_snapshot,
produce_snapshot,
rename_instance,
)
mock = Mock()
class TestClass(unittest.TestCase):
"""main test class for rds_auto_encrypt"""
@mock.patch("check_kms.check_key", return_value={"KeyMetadata": {"KeyId": "123"}})
def test_check_kms(self):
expected = "123"
actual = check_kms("valuse")
assert expected == actual
@mock.patch(
"check_database.check_instance",
return_value={"DBInstances": [{"DBInstanceIdentifier": "123"}]},
)
def test_check_database(self):
expected = "123"
actual = check_database("value")
assert expected == actual
@mock.patch(
"check_database_encryption.check_instance",
return_value={"DBInstances": [{"StorageEncrypted": "True"}]},
)
def test_check_database_encryption(self):
expected = "True"
actual = check_database_encryption("value")
assert expected == actual
@mock.patch("check_snapshot.check_rds", return_value={"DBSnapshots": "Ture"})
def test_check_snapshot(self):
expected = "True"
actual = check_snapshot("value")
assert expected == actual
@mock.patch(
"produce_snapshot.check",
return_value={"DBSnapshot": {"DBSnapshotIdentifier": "123"}},
)
def test_produce_snapshot(self):
expected = "123"
actual = produce_snapshot("value")
assert expected == actual
@mock.patch(
"encrypt_snapshot.encrypt",
return_value={"DBSnapshot": {"DBSnapshotIdentifier": "123"}},
)
def test_encrypt_snapshot(self):
expected = "123"
actual = encrypt_snapshot("value")
assert expected == actual
@mock.patch("rename_instance.instance_new", return_value="new-instance")
def test_rename_instance(self):
expected = "new-instance"
actual = rename_instance("value")
assert expected == actual