1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/installer/util/legacy_firewall_manager_win.h"
7 #include "base/path_service.h"
8 #include "base/process/process_info.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 class LegacyFirewallManagerTest
: public ::testing::Test
{
15 LegacyFirewallManagerTest() : skip_test_(true) {}
18 // Sets up the test fixture.
19 void SetUp() override
{
20 if (base::GetCurrentProcessIntegrityLevel() != base::HIGH_INTEGRITY
) {
21 LOG(WARNING
) << "Not elevated. Skipping the test.";
25 base::FilePath exe_path
;
26 PathService::Get(base::FILE_EXE
, &exe_path
);
27 EXPECT_TRUE(manager_
.Init(L
"LegacyFirewallManagerTest", exe_path
));
28 manager_
.DeleteRule();
31 // Tears down the test fixture.
32 void TearDown() override
{
34 manager_
.DeleteRule();
38 LegacyFirewallManager manager_
;
41 DISALLOW_COPY_AND_ASSIGN(LegacyFirewallManagerTest
);
44 TEST_F(LegacyFirewallManagerTest
, NoRule
) {
47 EXPECT_FALSE(manager_
.GetAllowIncomingConnection(NULL
));
50 TEST_F(LegacyFirewallManagerTest
, AllowRule
) {
53 EXPECT_TRUE(manager_
.SetAllowIncomingConnection(true));
55 EXPECT_TRUE(manager_
.GetAllowIncomingConnection(&allowed
));
57 manager_
.DeleteRule();
58 EXPECT_FALSE(manager_
.GetAllowIncomingConnection(NULL
));
61 TEST_F(LegacyFirewallManagerTest
, BlockRule
) {
64 EXPECT_TRUE(manager_
.SetAllowIncomingConnection(false));
66 EXPECT_TRUE(manager_
.GetAllowIncomingConnection(&allowed
));
67 EXPECT_FALSE(allowed
);
68 manager_
.DeleteRule();
69 EXPECT_FALSE(manager_
.GetAllowIncomingConnection(NULL
));
72 } // namespace installer