mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed in accordance with the terms specified in
|
|
* the LICENSE file found in the root directory of this source tree.
|
|
*/
|
|
|
|
// Sanity check integration test for crontab
|
|
// Spec file: specs/posix/crontab.table
|
|
|
|
#include <osquery/tests/integration/tables/helper.h>
|
|
|
|
namespace osquery {
|
|
namespace table_tests {
|
|
|
|
class Crontab : public testing::Test {
|
|
protected:
|
|
void SetUp() override {
|
|
setUpEnvironment();
|
|
}
|
|
};
|
|
|
|
TEST_F(Crontab, test_sanity) {
|
|
QueryData data = execute_query("select * from crontab");
|
|
std::unordered_set<std::string> month_list = {"jan",
|
|
"feb",
|
|
"mar",
|
|
"apr",
|
|
"may",
|
|
"jun",
|
|
"jul",
|
|
"aug",
|
|
"sep",
|
|
"oct",
|
|
"nov",
|
|
"dec"};
|
|
std::unordered_set<std::string> days_list = {
|
|
"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
|
|
ValidationMap row_map = {{"event",
|
|
SpecificValuesCheck{"",
|
|
"@reboot",
|
|
"@hourly",
|
|
"@daily",
|
|
"@weekly",
|
|
"@monthly",
|
|
"@annually",
|
|
"@yearly"}},
|
|
{"minute", CronValuesCheck(0, 59)},
|
|
{"hour", CronValuesCheck(0, 23)},
|
|
{"day_of_month", CronValuesCheck(1, 31)},
|
|
{"month", CronValuesCheck(1, 31, month_list)},
|
|
{"day_of_week", CronValuesCheck(0, 7, days_list)},
|
|
{"command", NonEmptyString},
|
|
{"path", FileOnDisk}};
|
|
validate_rows(data, row_map);
|
|
}
|
|
|
|
} // namespace table_tests
|
|
} // namespace osquery
|