openstack-ansible-tests/ansible-lint/test/TestNoLogPasswordsRule.py
Jean-Philippe Evrard c00ecb858d Add a rule to prevent passwords to be logged
Lint rule to make sure no module argument looking like "password"
will get logged.

Change-Id: I180b77faf7aaab57d1c48fc993e43f08c4fb16f6
Closes-Bug: #1760878
2018-04-11 14:48:19 +00:00

23 lines
734 B
Python

import unittest
from ansiblelint import RulesCollection, Runner
from NoLogPasswordsRule import NoLogPasswordsRule
class TestNoLogPasswordsRule(unittest.TestCase):
collection = RulesCollection()
def setUp(self):
self.collection.register(NoLogPasswordsRule())
def test_file_positive(self):
success = 'ansible-lint/test/no-log-passwords-success.yml'
good_runner = Runner(self.collection, success, [], [], [])
self.assertEqual([], good_runner.run())
def test_file_negative(self):
failure = 'ansible-lint/test/no-log-passwords-failure.yml'
bad_runner = Runner(self.collection, failure, [], [], [])
errs = bad_runner.run()
self.assertEqual(3, len(errs))