Skip to content

Commit

Permalink
sort filters on get
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperlarson committed Sep 2, 2024
1 parent 78ffaa2 commit 9d5f4c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/forti_api/dns_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ class DNSFilter {
}

static std::vector<DNSProfile> get() {
return FortiAPI::get<DNSProfilesResponse>(api_endpoint).results;
auto results = FortiAPI::get<DNSProfilesResponse>(api_endpoint).results;
for (auto& profile : results) profile.ftgd_dns.sort_filters();
return results;
}

static DNSProfile get(const std::string& feed) {
return FortiAPI::get<DNSProfilesResponse>(std::format("{}/{}", api_endpoint, feed)).results[0];
auto result = FortiAPI::get<DNSProfilesResponse>(std::format("{}/{}", api_endpoint, feed)).results[0];
result.ftgd_dns.sort_filters();
return result;
}

static void global_allow_category(unsigned int category) {
Expand Down
4 changes: 4 additions & 0 deletions tests/test_dns_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ TEST(TestDNSFilter, TestToggleFilters) {
DNSFilter::del(profile.name);
ASSERT_FALSE(DNSFilter::contains(profile.name));
}

TEST(TestDNSFilter, TestContains192) {
ASSERT_TRUE(DNSFilter::get("advanced").ftgd_dns.contains(193));
}

0 comments on commit 9d5f4c6

Please sign in to comment.