+ //metrics invalid policy returns -1;
+ REQUIRE(n_plugin.get_requests(100) == -1);
+ REQUIRE(n_plugin.get_rejects(100) == -1);
+
+ // 1 active policy
+ n_plugin.get_active_policies(active_list);
+ REQUIRE(active_list.size() == 1);
+
+ // verify returned policy
+ REQUIRE(n_plugin.is_active(active_list[0]) == true);
+
+ // add a policy
+ res = n_plugin.add_policy(1, 35, 10, 10, policy_id);
+ REQUIRE(res == true);
+
+ active_list.clear();
+ n_plugin.get_active_policies(active_list);
+ REQUIRE(active_list.size() == 2);
+
+ // query default policy
+ res = n_plugin.query_policy(0, info);
+ REQUIRE(res == true);
+ REQUIRE(info.size() == 4);
+ REQUIRE(info[0] == 1);
+ REQUIRE(info[1] == 20);
+ REQUIRE(info[2] == 0);
+ REQUIRE(info[3] == 100);
+
+ // query new policy
+ info.clear();
+ res = n_plugin.query_policy(policy_id, info);
+ REQUIRE(res == true);
+ REQUIRE(info.size() == 4);
+ REQUIRE(info[0] == 1);
+ REQUIRE(info[1] == 35);
+ REQUIRE(info[2] == 10);
+ REQUIRE(info[3] == 10);
+
+ // try adding same policy
+ res = n_plugin.add_policy(1, 200, 10, 10, policy_id);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("already exists"));
+
+ // delete the policy
+ res = n_plugin.delete_policy(policy_id);
+ REQUIRE(res == true);
+
+ // delete non-existent policy
+ res = n_plugin.delete_policy(policy_id);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("No policy with id"));
+
+ // configure non-existent policy
+ res = n_plugin.configure(1, 20, 0, 100, policy_id);
+ REQUIRE(res == false);
+
+ // invalid window size to configure policy
+ res = n_plugin.configure(0, -1, 0, 100, 0);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal value for window"));
+
+ // invalid trigger in configure policy
+ res = n_plugin.configure(0, 12, -1, 100, 0);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // invalid class in configure policy
+ res = n_plugin.configure(0, 20, 1, 100, -25);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // invalid blocking rate in configure policy
+ res = n_plugin.configure(0, 21, 0, 105, 0);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+
+ // invalid window size in add policy
+ res = n_plugin.add_policy(0, -1, 0, 100, 25);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // invalid trigger in add policy
+ res = n_plugin.add_policy(0, 12, -1, 100, 25);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // invalid class in add policy
+ res = n_plugin.add_policy(0, 20, 1, 100, -25);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // invalid blocking rate in add policy
+ res = n_plugin.add_policy(0, 21, 0, 105, 25);
+ REQUIRE(res == false);
+ REQUIRE_THAT(n_plugin.get_error(), Catch::Matchers::Contains("Illegal"));
+
+ // query a non-existant policy
+ res = n_plugin.query_policy(200, info);
+ REQUIRE(res == false);
+
+
+ }
+
+ SECTION("Test turning enforcement on off "){