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 24, 2024
1 parent 50dae68 commit 78fd3e6
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions tests/unit/TestNetRemoteServiceClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,89 @@ TEST_CASE("WifiAccessPointSetPhyType API", "[basic][rpc][client][remote]")
REQUIRE(setPhyTypeResult.status().has_details() == false);
}
}

TEST_CASE("WifiAccessPointSetAuthenticationConfiguration 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;

constexpr auto SsidName{ "TestWifiAccessPointSetAuthenticationConfiguration" };

NetRemoteServerConfiguration Configuration{
.ServerAddress = RemoteServiceAddressHttp,
.AccessPointManager = AccessPointManager::Create(),
};

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("TestWifiAccessPointSetAuthenticationConfiguration");
*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")
{
Dot11AccessPointAuthenticationConfiguration apAuthConfiguration{};

// Add the first AKM suite.
auto* akmSuiteConfiguration1 = apAuthConfiguration.mutable_akmsuites()->Add();
akmSuiteConfiguration1->set_authenticationalgorithm(Dot11AuthenticationAlgorithm::Dot11AuthenticationAlgorithmSae);
akmSuiteConfiguration1->set_akmsuite(Dot11AkmSuite::Dot11AkmSuiteSae);

Dot11SharedKey sharedKey1{};
sharedKey1.set_passphrase("passphrase1");
Dot11AkmSuiteConfigurationSharedKey akmSuiteConfigurationSharedKey1{};
*akmSuiteConfigurationSharedKey1.mutable_sharedkey() = std::move(sharedKey1);
*akmSuiteConfiguration1->mutable_configurationsharedkey() = std::move(akmSuiteConfigurationSharedKey1);

// Add the second AKM suite.
auto* akmSuiteConfiguration2 = apAuthConfiguration.mutable_akmsuites()->Add();
akmSuiteConfiguration2->set_authenticationalgorithm(Dot11AuthenticationAlgorithm::Dot11AuthenticationAlgorithmSae);
akmSuiteConfiguration2->set_akmsuite(Dot11AkmSuite::Dot11AkmSuiteFtSae);

Dot11SharedKey sharedKey2{};
sharedKey2.set_passphrase("passphrase2");
Dot11AkmSuiteConfigurationSharedKey akmSuiteConfigurationSharedKey2{};
*akmSuiteConfigurationSharedKey2.mutable_sharedkey() = std::move(sharedKey2);
*akmSuiteConfiguration2->mutable_configurationsharedkey() = std::move(akmSuiteConfigurationSharedKey2);

WifiAccessPointSetAuthenticationConfigurationRequest setAuthConfigurationRequest{};
setAuthConfigurationRequest.set_accesspointid("TestWifiAccessPointSetAuthenticationConfiguration");
*setAuthConfigurationRequest.mutable_authenticationconfiguration() = std::move(apAuthConfiguration);

WifiAccessPointSetAuthenticationConfigurationResult setAuthConfigurationResult{};
grpc::ClientContext setAuthConfigurationClientContext{};

auto setAuthConfigurationStatus = client->WifiAccessPointSetAuthenticationConfiguration(&setAuthConfigurationClientContext, setAuthConfigurationRequest, &setAuthConfigurationResult);
REQUIRE(setAuthConfigurationStatus.ok());
REQUIRE(setAuthConfigurationResult.accesspointid() == setAuthConfigurationRequest.accesspointid());
REQUIRE(setAuthConfigurationResult.has_status());
REQUIRE(setAuthConfigurationResult.status().code() == WifiAccessPointOperationStatusCode::WifiAccessPointOperationStatusCodeSucceeded);
REQUIRE(setAuthConfigurationResult.status().message().empty());
REQUIRE(setAuthConfigurationResult.status().has_details() == false);
}
}

0 comments on commit 78fd3e6

Please sign in to comment.