summaryrefslogtreecommitdiff
path: root/server/StrictControllerTest.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-07-18 18:28:36 +0900
committerLorenzo Colitti <lorenzo@google.com>2017-07-18 18:54:51 +0900
commita18b29b86a080f5f0bb1973925170de3a46bda55 (patch)
tree6475d6e0e59ada35b699900c6cc67d97d1e7e1da /server/StrictControllerTest.cpp
parent1411d45669a31c2fad5c3bd1f67bad7c1808c173 (diff)
Add a test for setUidCleartextPolicy.
Bug: 28362720 Test: netd_{unit,integration}_test pass Change-Id: Ie4577b29230282e0e6c9ae0ae6727af78e8b0849
Diffstat (limited to 'server/StrictControllerTest.cpp')
-rw-r--r--server/StrictControllerTest.cpp28
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);
+}