Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Add missing return cause after AddStatus #15186

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::Connec
if (req.networkID.size() > DeviceLayer::NetworkCommissioning::kMaxNetworkIDLen)
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidValue);
return;
}

mConnectingNetworkIDLen = static_cast<uint8_t>(req.networkID.size());
Expand Down
18 changes: 18 additions & 0 deletions src/controller/python/test/test_scripts/network_commissioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ async def readLastNetworkingStateAttributes(self, endpointId):
logger.info(f"Got values: {values}")
return values

async def test_negative(self, endpointId):
logger.info(
f"Running negative test cases for NetworkCommissioning cluster on endpoint {endpointId}")

try:
logger.info(
f"1. Send ConnectNetwork command with a illegal network id")
req = Clusters.NetworkCommissioning.Commands.ConnectNetwork(
networkID=b'0' * 254, breadcrumb=0)
res = await self._devCtrl.SendCommand(nodeid=self._nodeid, endpoint=endpointId, payload=req)
raise AssertionError(f"Failure expected but got response {res}")
except chip.interaction_model.InteractionModelError as ex:
logger.info(f"Recevied {ex} from server.")
woody-apple marked this conversation as resolved.
Show resolved Hide resolved

logger.info(f"Finished negative test cases.")

async def test_wifi(self, endpointId):
logger.info(f"Get basic information of the endpoint")
res = await self._devCtrl.ReadAttribute(nodeid=self._nodeid, attributes=[
Expand Down Expand Up @@ -290,10 +306,12 @@ async def run(self):
if clus.featureMap == WIFI_NETWORK_FEATURE_MAP:
logger.info(
f"Endpoint {endpoint} is configured as WiFi network, run WiFi commissioning test.")
await self.test_negative(endpoint)
await self.test_wifi(endpoint)
elif clus.featureMap == THREAD_NETWORK_FEATURE_MAP:
logger.info(
f"Endpoint {endpoint} is configured as Thread network, run Thread commissioning test.")
await self.test_negative(endpoint)
await self.test_thread(endpoint)
else:
logger.info(
Expand Down