Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
corbin-phipps committed Jan 30, 2024
1 parent dab12a6 commit 86f4980
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/unit/TestNetRemoteServiceClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <microsoft/net/remote/NetRemoteServer.hxx>
#include <microsoft/net/remote/protocol/NetRemoteService.grpc.pb.h>
#include <microsoft/net/wifi/AccessPointManager.hxx>
#include <microsoft/net/wifi/test/AccessPointManagerTest.hxx>
#include <microsoft/net/wifi/test/AccessPointTest.hxx>

#include "TestNetRemoteCommon.hxx"
Expand Down Expand Up @@ -114,3 +115,72 @@ TEST_CASE("WifiAccessPointEnable API", "[basic][rpc][client][remote]")
REQUIRE(result.status().has_details() == false);
}
}

TEST_CASE("WifiAccessPointSetPhyType API", "[basic][rpc][client][remote]")
{
using namespace Microsoft::Net::Remote;
using namespace Microsoft::Net::Remote::Service;
using namespace Microsoft::Net::Remote::Wifi;
using namespace Microsoft::Net::Wifi;
using namespace Microsoft::Net::Wifi::Test;

constexpr auto SsidName{ "TestWifiAccessPointSetPhyType" };
constexpr auto InterfaceName{ "TestWifiAccessPointSetPhyType" };

auto apManagerTest = std::make_shared<AccessPointManagerTest>();
auto apFactoryTest = std::make_unique<AccessPointFactoryTest>();
auto apTest = apFactoryTest->Create(InterfaceName);
apManagerTest->AddAccessPoint(apTest);

NetRemoteServerConfiguration Configuration{
.ServerAddress = RemoteServiceAddressHttp,
.AccessPointManager = apManagerTest,
};

NetRemoteServer server{ Configuration };
server.Run();

auto channel = grpc::CreateChannel(RemoteServiceAddressHttp, grpc::InsecureChannelCredentials());
auto client = NetRemote::NewStub(channel);

Dot11AccessPointConfiguration apConfiguration{};
apConfiguration.mutable_ssid()->set_name(SsidName);
apConfiguration.set_phytype(Dot11PhyType::Dot11PhyTypeA);
apConfiguration.set_authenticationalgorithm(Dot11AuthenticationAlgorithm::Dot11AuthenticationAlgorithmSharedKey);
apConfiguration.set_ciphersuite(Dot11CipherSuite::Dot11CipherSuiteCcmp256);
apConfiguration.mutable_bands()->Add(Dot11FrequencyBand::Dot11FrequencyBand2_4GHz);
apConfiguration.mutable_bands()->Add(Dot11FrequencyBand::Dot11FrequencyBand5_0GHz);

WifiAccessPointEnableRequest request{};
request.set_accesspointid(InterfaceName);
*request.mutable_configuration() = std::move(apConfiguration);

WifiAccessPointEnableResult result{};
grpc::ClientContext clientContext{};

auto status = client->WifiAccessPointEnable(&clientContext, request, &result);
REQUIRE(status.ok());
REQUIRE(result.accesspointid() == request.accesspointid());
REQUIRE(result.has_status());
REQUIRE(result.status().code() == WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
REQUIRE(result.status().message().empty());
REQUIRE(result.status().has_details() == false);

SECTION("Can be called")
{
WifiAccessPointSetPhyTypeRequest setPhyTypeRequest{};
setPhyTypeRequest.set_accesspointid(InterfaceName);
setPhyTypeRequest.set_phytype(Dot11PhyType::Dot11PhyTypeB);

WifiAccessPointSetPhyTypeResult setPhyTypeResult{};
grpc::ClientContext setPhyTypeClientContext{};

auto setPhyTypeStatus = client->WifiAccessPointSetPhyType(&setPhyTypeClientContext, setPhyTypeRequest, &setPhyTypeResult);
REQUIRE(setPhyTypeStatus.ok());
REQUIRE(setPhyTypeResult.accesspointid() == setPhyTypeRequest.accesspointid());
REQUIRE(setPhyTypeResult.has_status());
REQUIRE(setPhyTypeResult.status().code() == WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
REQUIRE(setPhyTypeResult.status().message().empty());
REQUIRE(setPhyTypeResult.status().has_details() == false);
}
}

0 comments on commit 86f4980

Please sign in to comment.