Skip to content

Commit

Permalink
[DEV] Add test: "LayerCommands" must be called before "InterfacesComm…
Browse files Browse the repository at this point in the history
…ands"

Related to commit with SHA-1: 4418941
  • Loading branch information
BoubacarDiene committed Jan 1, 2021
1 parent d4b76af commit 6243914
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cmake_minimum_required(VERSION 3.18.2)
# - version = <year>.<month>.<patch>
# - The project's name will be used to name the executable
project(networkservice
VERSION 21.01.00
VERSION 21.01.01
LANGUAGES CXX
DESCRIPTION "A native service to allow performing network\
commands more securely by using related tools\
Expand Down
2 changes: 1 addition & 1 deletion res/example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

"interface1" is ...

Why is provided interfaces ("," separated) required? Why would the service fail
Why are provided interfaces ("," separated) required? Why would the service fail
if they are not available?

-------------------------------------------------------------------------------
Expand Down
27 changes: 27 additions & 0 deletions test/service/NetworkServiceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,33 @@ TEST_F(NetworkServiceTestFixture, setupNetworkBeforeFirewall)
ASSERT_EQ(m_networkService.applyConfig(m_configFile), EXIT_SUCCESS);
}

// NOLINTNEXTLINE(cert-err58-cpp, hicpp-special-member-functions)
TEST_F(NetworkServiceTestFixture, applyLayerBeforeInterfaceCommands)
{
EXPECT_CALL(m_mockConfig, load(m_configFile)).Times(1);

{
Sequence seq1;
Sequence seq2;

EXPECT_CALL(m_mockNetwork, hasInterface)
.InSequence(seq1, seq2)
.WillRepeatedly(Return(true));
EXPECT_CALL(m_mockNetwork, applyLayerCommands).InSequence(seq1);
EXPECT_CALL(m_mockNetwork, applyInterfaceCommands).InSequence(seq1);
EXPECT_CALL(m_mockRuleFactory, createRule)
.InSequence(seq2)
.WillOnce([]([[maybe_unused]] const std::string& name,
[[maybe_unused]] const std::vector<std::string>& commands) {
auto rule = std::make_unique<MockRule>();
EXPECT_CALL(*rule, applyCommands);
return rule;
});
}

ASSERT_EQ(m_networkService.applyConfig(m_configFile), EXIT_SUCCESS);
}

}

int main(int argc, char** argv)
Expand Down

0 comments on commit 6243914

Please sign in to comment.