def assertUfwRuleEqual(self, expected, actual): ''' Assert that the specified rule contains the specified property values. expected Expected properties. actual Actual properties. ''' return self.assertEqual( ufw.complete_rule(expected), ufw.complete_rule(actual))
def assertUfwRulesetEqual(self, expected, actual): ''' Assert that all roles in the specified ruleset are equal. expected Expected rules. actual Actual rules. ''' expected = [ufw.complete_rule(x) for x in expected] actual = [ufw.complete_rule(x) for x in actual] return self.assertEqual(expected, actual)
def test_delta_ruleset_add(self): current_rules = { 1: { 'policy': 'allow', 'direction': 'incoming', 'port': 22, }, } new_rules = { 1: { 'policy': 'allow', 'direction': 'incoming', 'port': 22, }, 2: { 'policy': 'allow', 'direction': 'incoming', 'port': 80, }, } expected = { 2: { 'old': None, 'new': ufwmod.complete_rule({ 'policy': 'allow', 'direction': 'incoming', 'port': 80, }), }, } ufw.__salt__['ufw.complete_rule'] = ufwmod.complete_rule delta = ufw._delta_ruleset(current_rules, new_rules) self.assertEqual(expected, delta)