'Test for checking we don\'t allow queries by default.'

def testNtpDoesntAllowOpenQueries(self):

    parser = config_file.NtpdParser()
    check_id = 'TIME-NTP-NO-OPEN-QUERIES'
    artifact_id = 'NtpConfFile'
    good_config = {'/etc/ntp.conf': '\n                                restrict    default    nomodify    noquery    nopeer\n                                '}
    bad_config = {'/etc/ntp.conf': '\n                                restrict    default    nomodify    nopeer\n                                '}
    bad_default_config = {'/etc/ntp.conf': '\n                                '}
    results = self.RunChecks(self.GenFileData('NtpConfFile', good_config, parser))
    self.assertCheckUndetected(check_id, results)
    found = ['Expected    state    was    not    found']
    sym = 'Missing    attribute:    ntpd.conf    is    configured    or    defaults    to    open    queries.    Can    allow    DDoS.    This    configuration    is    an    on-going    recommendation    following    the    Ntp    December    2014    Vulnerability    notice.    (http://support.ntp.org/bin/view/Main/SecurityNotice)'
    results = self.RunChecks(self.GenFileData(artifact_id, bad_config, parser))
    self.assertCheckDetectedAnom(check_id, results, sym, found)
    results = self.RunChecks(self.GenFileData(artifact_id, bad_default_config, parser))
    self.assertCheckDetectedAnom(check_id, results, sym, found)
