Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Dec 1, 2022
1 parent e1adf10 commit 865d603
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg)
{
ChipLogError(SecureChannel, "CASE failed to match destination ID with local fabrics");
ChipLogByteSpan(SecureChannel, destinationIdentifier);
ExitNow();
}
SuccessOrExit(err);

// ParseSigma1 ensures that:
// mRemotePubKey.Length() == initiatorPubKey.size() == kP256_PublicKey_Length.
Expand Down
9 changes: 6 additions & 3 deletions src/protocols/secure_channel/tests/TestCASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,9 @@ namespace {
class ExpectErrorExchangeDelegate : public ExchangeDelegate
{
public:
ExpectErrorExchangeDelegate(nlTestSuite * suite) : mSuite(suite) {}
ExpectErrorExchangeDelegate(nlTestSuite * suite, uint16_t expectedProtocolCode) :
mSuite(suite), mExpectedProtocolCode(expectedProtocolCode)
{}

private:
CHIP_ERROR OnMessageReceived(ExchangeContext * ec, const PayloadHeader & payloadHeader,
Expand All @@ -1026,7 +1028,7 @@ class ExpectErrorExchangeDelegate : public ExchangeDelegate

NL_TEST_ASSERT(mSuite, statusReport.GetProtocolId() == SecureChannel::Id);
NL_TEST_ASSERT(mSuite, statusReport.GetGeneralCode() == GeneralStatusCode::kFailure);
NL_TEST_ASSERT(mSuite, statusReport.GetProtocolCode() == kProtocolCodeNoSharedRoot);
NL_TEST_ASSERT(mSuite, statusReport.GetProtocolCode() == mExpectedProtocolCode);
return CHIP_NO_ERROR;
}

Expand All @@ -1035,6 +1037,7 @@ class ExpectErrorExchangeDelegate : public ExchangeDelegate
Messaging::ExchangeMessageDispatch & GetMessageDispatch() override { return SessionEstablishmentExchangeDispatch::Instance(); }

nlTestSuite * mSuite;
uint16_t mExpectedProtocolCode;
};
} // anonymous namespace

Expand Down Expand Up @@ -1069,7 +1072,7 @@ void TestCASESession::Sigma1BadDestinationIdTest(nlTestSuite * inSuite, void * i
err = ctx.GetExchangeManager().RegisterUnsolicitedMessageHandlerForType(MsgType::CASE_Sigma1, &caseSession);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

ExpectErrorExchangeDelegate delegate(inSuite);
ExpectErrorExchangeDelegate delegate(inSuite, SecureChannel::kProtocolCodeNoSharedRoot);
ExchangeContext * exchange = ctx.GetExchangeManager().NewContext(session.Value(), &delegate);
NL_TEST_ASSERT(inSuite, exchange != nullptr);

Expand Down

0 comments on commit 865d603

Please sign in to comment.