| Index: sandbox/src/policy_low_level_unittest.cc
|
| ===================================================================
|
| --- sandbox/src/policy_low_level_unittest.cc (revision 16307)
|
| +++ sandbox/src/policy_low_level_unittest.cc (working copy)
|
| @@ -13,8 +13,11 @@
|
|
|
| namespace sandbox {
|
|
|
| +bool SetupNtdllImports();
|
| +
|
| // Testing that we allow opcode generation on valid string patterns.
|
| TEST(PolicyEngineTest, StringPatternsOK) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"c:\\adobe\\ver??\\", CASE_SENSITIVE));
|
| EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"*.tmp", CASE_SENSITIVE));
|
| @@ -26,6 +29,7 @@
|
|
|
| // Testing that we signal invalid string patterns.
|
| TEST(PolicyEngineTest, StringPatternsBAD) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_FALSE(pr.AddStringMatch(IF, 0, L"one**two", CASE_SENSITIVE));
|
| EXPECT_FALSE(pr.AddStringMatch(IF, 0, L"**three", CASE_SENSITIVE));
|
| @@ -46,6 +50,7 @@
|
| // The simplest test using LowLevelPolicy it should test a single opcode which
|
| // does a exact string comparison.
|
| TEST(PolicyEngineTest, SimpleStrMatch) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"z:\\Directory\\domo.txt",
|
| CASE_INSENSITIVE));
|
| @@ -78,6 +83,7 @@
|
| }
|
|
|
| TEST(PolicyEngineTest, SimpleIfNotStrMatch) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\",
|
| CASE_SENSITIVE));
|
| @@ -115,6 +121,7 @@
|
| }
|
|
|
| TEST(PolicyEngineTest, SimpleIfNotStrMatchWild1) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*",
|
| CASE_SENSITIVE));
|
| @@ -147,6 +154,7 @@
|
| }
|
|
|
| TEST(PolicyEngineTest, SimpleIfNotStrMatchWild2) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*.txt",
|
| CASE_SENSITIVE));
|
| @@ -184,6 +192,7 @@
|
| }
|
|
|
| TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild1) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*",
|
| CASE_SENSITIVE));
|
| @@ -231,6 +240,7 @@
|
| }
|
|
|
| TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild2) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddNumberMatch(IF, 1, 24, EQUAL));
|
| EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\GoogleV?\\*.txt",
|
| @@ -303,6 +313,7 @@
|
| // Testing one single rule in one single service. The service is made to
|
| // resemble NtCreateFile.
|
| TEST(PolicyEngineTest, OneRuleTest) {
|
| + SetupNtdllImports();
|
| PolicyRule pr(ASK_BROKER);
|
| EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"c:\\*Microsoft*\\*.txt",
|
| CASE_SENSITIVE));
|
| @@ -373,6 +384,7 @@
|
|
|
| // Testing 3 rules in 3 services. Two of the services resemble File services.
|
| TEST(PolicyEngineTest, ThreeRulesTest) {
|
| + SetupNtdllImports();
|
| PolicyRule pr_pipe(FAKE_SUCCESS);
|
| EXPECT_TRUE(pr_pipe.AddStringMatch(IF, 0, L"\\\\/?/?\\Pipe\\Chrome.*",
|
| CASE_INSENSITIVE));
|
|
|