mock_get_applocker_rules

in itchef/cookbooks/cpe_applocker/spec/default_spec.rb [31:107]


def mock_get_applocker_rules(enabled)
  mock_rules = {
    'Appx' => {
      'mode' => enabled ? 'AuditOnly' : 'NotConfigured',
      'rules' => [],
    },
    'Dll' => {
      'mode' => enabled ? 'Enforce' : 'NotConfigured',
      'rules' => [],
    },
    'Exe' => {
      'mode' => enabled ? 'Enforce' : 'NotConfigured',
      'rules' => enabled ? [
        
        {
          'type' => 'path',
          'name' => 'test_filepath',
          'id' => 'fd686d83-a829',
          'description' => 'Test file path rule set',
          'action' => 'Allow',
          'user_or_group_sid' => 'S-1-5-32-544',
          'conditions' => [
            {
              'path' => '%OSDRIVE%\\tools\\*',
            },
          ],
        },
        
        {
          'type' => 'hash',
          'name' => 'test_filehash',
          'id' => 'f8b0f25b-776f',
          'description' => 'Test file hash rule set',
          'action' => 'Deny',
          'user_or_group_sid' => 'S-1-1-0',
          'conditions' => [
            {
              'type' => 'SHA256',
              'data' => '0x267FEDEDD79AAAF7CFA62ECAA29BC0D' +
                        '8F5553FBD007A48BEC76C177BB7242CBC',
              'file_name' => 'calc.exe',
              'file_length' => '27648',
            },
          ],
        },
        
        {
          'type' => 'certificate',
          'name' => 'test_filepublisher',
          'id' => 'acd2e5a8-6b8f',
          'description' => 'Test file publisher rule set',
          'action' => 'Deny',
          'user_or_group_sid' => 'S-1-1-0',
          'conditions' => [
            {
              'publisher' => 'O=TEAMVIEWER GMBH, L=GOPPINGEN, ' +
                             'S=BADEN-WURTTEMBERG, C=DE',
              'product_name' => '*',
              'binary_name' => '*',
              'binary_version' => { 'low' => '*', 'high' => '*' },
            },
          ],
        },
      ] : [],
    },
    'Script' => {
      'mode' => enabled ? 'AuditOnly' : 'NotConfigured',
      'rules' => [],
    },
    'Msi' => {
      'mode' => enabled ? 'AuditOnly' : 'NotConfigured',
      'rules' => [],
    },
  }
  allow(applocker).to receive(:get_applocker_rules).and_return(mock_rules)
end