aboutsummaryrefslogtreecommitdiffstats
path: root/configutil/src/tests/host_filter/host_filter_test.cpp
blob: eb44a5453d1161c8fc57b6b56791864196c2ced8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <lib/hostfilter.h>

TEST("empty hostfilter includes any and all hosts") {
    HostFilter filter;
    EXPECT_TRUE(filter.includes("foo.yahoo.com"));
}

TEST("explicit host set limits to provided hosts only") {
    HostFilter::HostSet hosts({"bar.yahoo.com", "zoidberg.yahoo.com"});
    HostFilter filter(std::move(hosts));
    EXPECT_TRUE(filter.includes("bar.yahoo.com"));
    EXPECT_TRUE(filter.includes("zoidberg.yahoo.com"));
    EXPECT_FALSE(filter.includes("foo.yahoo.com"));
}

TEST_MAIN() { TEST_RUN_ALL(); }