diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-07-18 11:46:16 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-07-18 11:46:16 +0000 |
| commit | 28e4da0438e22cc5169bf987385305fa6ecbcf99 (patch) | |
| tree | 6475d6e0e59ada35b699900c6cc67d97d1e7e1da /server/StrictControllerTest.cpp | |
| parent | 7ea6e390b28c131e27bdedfe568819c846f5d63e (diff) | |
| parent | a18b29b86a080f5f0bb1973925170de3a46bda55 (diff) | |
Merge "Add a test for setUidCleartextPolicy."
Diffstat (limited to 'server/StrictControllerTest.cpp')
| -rw-r--r-- | server/StrictControllerTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/StrictControllerTest.cpp b/server/StrictControllerTest.cpp index c0c8839a..3783c303 100644 --- a/server/StrictControllerTest.cpp +++ b/server/StrictControllerTest.cpp @@ -122,3 +122,31 @@ TEST_F(StrictControllerTest, TestDisableStrict) { "COMMIT\n"; expectIptablesRestoreCommands({ expected }); } + +TEST_F(StrictControllerTest, TestSetUidCleartextPenalty) { + std::vector<std::string> acceptCommands = { + "-D st_OUTPUT -m owner --uid-owner 12345 -j st_clear_detect", + "-D st_clear_caught -m owner --uid-owner 12345 -j st_penalty_log", + "-D st_clear_caught -m owner --uid-owner 12345 -j st_penalty_reject", + }; + std::vector<std::string> logCommands = { + "-I st_OUTPUT -m owner --uid-owner 12345 -j st_clear_detect", + "-I st_clear_caught -m owner --uid-owner 12345 -j st_penalty_log", + }; + std::vector<std::string> rejectCommands = { + "-I st_OUTPUT -m owner --uid-owner 12345 -j st_clear_detect", + "-I st_clear_caught -m owner --uid-owner 12345 -j st_penalty_reject", + }; + + mStrictCtrl.setUidCleartextPenalty(12345, LOG); + expectIptablesCommands(logCommands); + + mStrictCtrl.setUidCleartextPenalty(12345, ACCEPT); + expectIptablesCommands(acceptCommands); + + mStrictCtrl.setUidCleartextPenalty(12345, REJECT); + expectIptablesCommands(rejectCommands); + + mStrictCtrl.setUidCleartextPenalty(12345, ACCEPT); + expectIptablesCommands(acceptCommands); +} |
