Пример #1
0
TEST_F(PacksTests, test_check_version) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_TRUE(fpack.checkVersion());

  auto zpack = Pack("foobaz", getPackWithFakeVersion());
  EXPECT_FALSE(zpack.checkVersion());
}
Пример #2
0
TEST_F(PacksTests, test_should_pack_execute) {
  auto kpack = Pack("kernel", getUnrestrictedPack());
  EXPECT_TRUE(kpack.shouldPackExecute());

  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_FALSE(fpack.shouldPackExecute());
}
Пример #3
0
TEST_F(PacksTests, test_discovery_zero_state) {
  auto pack = Pack("foobar", getPackWithDiscovery());
  auto stats = pack.getStats();
  EXPECT_EQ(stats.total, 0);
  EXPECT_EQ(stats.hits, 0);
  EXPECT_EQ(stats.misses, 0);
}
Пример #4
0
TEST_F(PacksTests, test_discovery_zero_state) {
  Pack pack("discovery_pack", getPackWithDiscovery());
  auto stats = pack.getStats();
  EXPECT_EQ(stats.total, 0U);
  EXPECT_EQ(stats.hits, 0U);
  EXPECT_EQ(stats.misses, 0U);
}
Пример #5
0
TEST_F(PacksTests, test_should_pack_execute) {
  Pack kpack("unrestricted_pack", getUnrestrictedPack());
  EXPECT_TRUE(kpack.shouldPackExecute());

  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_FALSE(fpack.shouldPackExecute());
}
Пример #6
0
TEST_F(PacksTests, test_check_version) {
  Pack zpack("fake_version_pack", getPackWithFakeVersion());
  EXPECT_FALSE(zpack.checkVersion());

  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_TRUE(fpack.checkVersion());
}
Пример #7
0
TEST_F(PacksTests, test_check_platform) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_TRUE(fpack.checkPlatform());

  // Depending on the current build platform, this check will be true or false.
  fpack.platform_ = kSDKPlatform;
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = (kSDKPlatform == "darwin") ? "linux" : "darwin";
  EXPECT_FALSE(fpack.checkPlatform());

  fpack.platform_ = "null";
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = "";
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = "bad_value";
  EXPECT_FALSE(fpack.checkPlatform());

  fpack.platform_ = "posix";
  if (isPlatform(PlatformType::TYPE_POSIX) ||
      isPlatform(PlatformType::TYPE_LINUX) ||
      isPlatform(PlatformType::TYPE_OSX) ||
      isPlatform(PlatformType::TYPE_FREEBSD)) {
    EXPECT_TRUE(fpack.checkPlatform());
  }

  if (isPlatform(PlatformType::TYPE_WINDOWS)) {
    EXPECT_FALSE(fpack.checkPlatform());
  }
}
Пример #8
0
TEST_F(PacksTests, test_check_platform) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  if (kSDKPlatform == "darwin") {
    EXPECT_TRUE(fpack.checkPlatform());
  } else {
    EXPECT_FALSE(fpack.checkPlatform());
  }
}
Пример #9
0
TEST_F(PacksTests, test_check_platform) {
  auto fpack = Pack("discovery_pack", getPackWithDiscovery());
  // Depending on the current build platform, this check will be true or false.
  if (kSDKPlatform == "darwin") {
    EXPECT_TRUE(fpack.checkPlatform());
  } else {
    EXPECT_FALSE(fpack.checkPlatform());
  }
}
Пример #10
0
TEST_F(PacksTests, test_discovery_cache) {
  auto pack = Pack("foobar", getPackWithDiscovery());
  for (int i = 0; i < 5; i++) {
    pack.checkDiscovery();
  }
  auto stats = pack.getStats();
  EXPECT_EQ(stats.total, 5);
  EXPECT_EQ(stats.hits, 4);
  EXPECT_EQ(stats.misses, 1);
}
Пример #11
0
TEST_F(PacksTests, test_get_discovery_queries) {
  std::vector<std::string> expected;

  auto kpack = Pack("kernel", getUnrestrictedPack());
  EXPECT_EQ(kpack.getDiscoveryQueries(), expected);

  expected = {"select pid from processes where name = 'foobar';"};
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_EQ(fpack.getDiscoveryQueries(), expected);
}
Пример #12
0
TEST_F(PacksTests, test_check_platform) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_TRUE(fpack.checkPlatform());

  // Depending on the current build platform, this check will be true or false.
  fpack.platform_ = kSDKPlatform;
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = (kSDKPlatform == "darwin") ? "linux" : "darwin";
  EXPECT_FALSE(fpack.checkPlatform());

  fpack.platform_ = "null";
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = "";
  EXPECT_TRUE(fpack.checkPlatform());

  fpack.platform_ = "bad_value";
  EXPECT_FALSE(fpack.checkPlatform());
}
Пример #13
0
TEST_F(PacksTests, test_name) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  fpack.setName("foobar");
  EXPECT_EQ(fpack.getName(), "foobar");
}
Пример #14
0
TEST_F(PacksTests, test_platform) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_EQ(fpack.getPlatform(), "darwin");
}
Пример #15
0
TEST_F(PacksTests, test_version) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_EQ(fpack.getVersion(), "1.5.0");
}
Пример #16
0
TEST_F(PacksTests, test_schedule) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  // Expect a single query in the schedule since one query has an explicit
  // invalid/fake platform requirement.
  EXPECT_EQ(fpack.getSchedule().size(), 1U);
}
Пример #17
0
TEST_F(PacksTests, test_platform) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_EQ(fpack.getPlatform(), "all");
}
Пример #18
0
TEST_F(PacksTests, test_version) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  EXPECT_EQ(fpack.getVersion(), "1.5.0");
}
Пример #19
0
TEST_F(PacksTests, test_schedule) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_EQ(fpack.getSchedule().size(), 1U);
}
Пример #20
0
TEST_F(PacksTests, test_name) {
  Pack fpack("discovery_pack", getPackWithDiscovery());
  fpack.setName("also_discovery_pack");
  EXPECT_EQ(fpack.getName(), "also_discovery_pack");
}