Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Add test cases for AzKVNonRecoverableEvent
Browse files Browse the repository at this point in the history
Added test cases for the `AzKVNonRecoverableEvent` event plugin.
  • Loading branch information
mitprasoon committed Mar 8, 2020
1 parent 2789ec1 commit 2969842
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions cloudmarker/test/test_azkvnonrecoverableevent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""Tests for AzKVNonRecoverableEvent plugin."""


import copy
import unittest

from cloudmarker.events import azkvnonrecoverableevent

base_record = {
'com': {
'cloud_type': 'azure',
'record_type': 'key_vault'
},
'ext': {
'record_type': 'key_vault',
'recoverable': False,
}
}


class AzKVNonRecoverableEventTest(unittest.TestCase):
"""Tests for AzKVNonRecoverableEvent plugin."""

def test_com_bucket_missing(self):
record = copy.deepcopy(base_record)
record['com'] = None
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(events, [])

def test_com_bucket_cloud_type_non_azure(self):
record = copy.deepcopy(base_record)
record['com']['cloud_type'] = 'non_azure'
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(events, [])

def test_ext_bucket_missing(self):
record = copy.deepcopy(base_record)
record['ext'] = None
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(events, [])

def test_ext_bucket_record_type_non_key_vault(self):
record = copy.deepcopy(base_record)
record['ext']['record_type'] = 'non_key_vault'
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(events, [])

def test_key_vault_recoverable(self):
record = copy.deepcopy(base_record)
record['ext']['recoverable'] = True
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(events, [])

def test_key_vault_non_recoverable(self):
record = copy.deepcopy(base_record)
plugin = azkvnonrecoverableevent. \
AzKVNonRecoverableEvent()
events = list(plugin.eval(record))
self.assertEqual(len(events), 1)
self.assertEqual(events[0]['ext']['record_type'],
'key_vault_non_recoverable_event')
self.assertEqual(events[0]['com']['record_type'],
'key_vault_non_recoverable_event')

0 comments on commit 2969842

Please sign in to comment.