Beispiel #1
0
 def test_dict_update_for_upd_TypeError(self):
     dest = {'key_1': 'val_1', 'key_2': 'val_2'}
     upd = 'TestValue2'
     try:
         var = pulsar._dict_update(dest, upd, recursive_update=True, merge_lists=False)
     except TypeError:
         pass
Beispiel #2
0
 def test_dict_update_for_classic_dictUpdate(self):
     dest = {'key1': 'val1'}
     upd = {'key_2': 'val_2'}
     test_dict = {'key1': 'val1', 'key_2': 'val_2'}
     var = pulsar._dict_update(dest,
                               upd,
                               recursive_update=False,
                               merge_lists=False)
     assert var == test_dict
Beispiel #3
0
 def test_dict_update_for_upd_TypeError(self):
     dest = {'key_1': 'val_1', 'key_2': 'val_2'}
     upd = 'TestValue2'
     try:
         var = pulsar._dict_update(dest,
                                   upd,
                                   recursive_update=True,
                                   merge_lists=False)
     except TypeError:
         pass
Beispiel #4
0
 def test_dict_update_recurssive(self):
     ret = {}
     dest = {'data':
             {'blacklist': {'talk1': {'data': {'Ubuntu-16.04': [{'/etc/inetd.conf': {'pattern': '^talk', 'tag': 'CIS-5.1.4'}}, {'/etc/inetd.conf': {'pattern': '^ntalk', 'tag': 'CIS-5.1.4'}}]}, 'description': 'Ensure talk server is not enabled'}},
              'whitelist': {'ssh_ignore_rhosts': {'data': {'Ubuntu-16.04': [{'/etc/ssh/sshd_config': {'pattern': 'IgnoreRhosts', 'tag': 'CIS-9.3.6', 'match_output': 'yes'}}]}, 'description': 'Set SSH IgnoreRhosts to Yes'}}}}
     upd = {'data':
            {'blacklist': {'talk2': {'data': {'Ubuntu-16.04': [{'/etc/inetd.conf': {'pattern': '^talk', 'tag': 'CIS-5.1.4'}}, {'/etc/inetd.conf': {'pattern': '^ntalk', 'tag': 'CIS-5.1.4'}}]}, 'description': 'Ensure talk server is not enabled'}}}}
     data_list = [dest, upd]
     for data in data_list:
         val = pulsar._dict_update(dest, data, recursive_update=True, merge_lists=True)
     assert (len(val['data']['blacklist'])) == 2
Beispiel #5
0
 def test_dict_update_recurssive(self):
     ret = {}
     dest = {
         'data': {
             'blacklist': {
                 'talk1': {
                     'data': {
                         'Ubuntu-16.04': [{
                             '/etc/inetd.conf': {
                                 'pattern': '^talk',
                                 'tag': 'CIS-5.1.4'
                             }
                         }, {
                             '/etc/inetd.conf': {
                                 'pattern': '^ntalk',
                                 'tag': 'CIS-5.1.4'
                             }
                         }]
                     },
                     'description': 'Ensure talk server is not enabled'
                 }
             },
             'whitelist': {
                 'ssh_ignore_rhosts': {
                     'data': {
                         'Ubuntu-16.04': [{
                             '/etc/ssh/sshd_config': {
                                 'pattern': 'IgnoreRhosts',
                                 'tag': 'CIS-9.3.6',
                                 'match_output': 'yes'
                             }
                         }]
                     },
                     'description': 'Set SSH IgnoreRhosts to Yes'
                 }
             }
         }
     }
     upd = {
         'data': {
             'blacklist': {
                 'talk2': {
                     'data': {
                         'Ubuntu-16.04': [{
                             '/etc/inetd.conf': {
                                 'pattern': '^talk',
                                 'tag': 'CIS-5.1.4'
                             }
                         }, {
                             '/etc/inetd.conf': {
                                 'pattern': '^ntalk',
                                 'tag': 'CIS-5.1.4'
                             }
                         }]
                     },
                     'description': 'Ensure talk server is not enabled'
                 }
             }
         }
     }
     data_list = [dest, upd]
     for data in data_list:
         val = pulsar._dict_update(dest,
                                   data,
                                   recursive_update=True,
                                   merge_lists=True)
     assert (len(val['data']['blacklist'])) == 2
Beispiel #6
0
 def test_dict_update_for_classic_dictUpdate(self):
     dest = {'key1': 'val1'}
     upd = {'key_2': 'val_2'}
     test_dict = {'key1': 'val1', 'key_2': 'val_2'}
     var = pulsar._dict_update(dest, upd, recursive_update=False, merge_lists=False)
     assert var == test_dict