mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Decode the action in Base NP advertisements back into a list of Data Elements
PiperOrigin-RevId: 466204445
This commit is contained in:
committed by
Copybara-Service
parent
076b00ed61
commit
6e6ae3ebd7
@@ -30,6 +30,7 @@ namespace presence {
|
||||
namespace {
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::Return;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
using ::testing::status::StatusIs;
|
||||
|
||||
class MockCredentialManager : public CredentialManagerImpl {
|
||||
@@ -83,6 +84,27 @@ TEST(AdvertisementDecoder, DecodeBaseNpPublicAdvertisement) {
|
||||
DataElement(9, absl::HexStringToBytes("EEFF"))));
|
||||
}
|
||||
|
||||
TEST(AdvertisementDecoder, DecodeBaseNpPWithActionField) {
|
||||
std::string salt = "AB";
|
||||
MockCredentialManager credential_manager;
|
||||
AdvertisementDecoder decoder(&credential_manager);
|
||||
|
||||
auto result =
|
||||
decoder.DecodeAdvertisement(absl::HexStringToBytes("002041420326B840"));
|
||||
|
||||
EXPECT_OK(result);
|
||||
EXPECT_THAT(*result,
|
||||
UnorderedElementsAre(
|
||||
DataElement(DataElement::kSaltFieldType, salt),
|
||||
DataElement(DataElement::kPublicIdentityFieldType, ""),
|
||||
DataElement(DataElement::kContextTimestampFieldType,
|
||||
absl::HexStringToBytes("0B")),
|
||||
DataElement(DataElement::kActionFieldType,
|
||||
action::kTapToTransferAction),
|
||||
DataElement(DataElement::kActionFieldType,
|
||||
action::kNearbyShareAction)));
|
||||
}
|
||||
|
||||
TEST(AdvertisementDecoder, InvalidAdvertisementFieldTooShort) {
|
||||
MockCredentialManager credential_manager;
|
||||
AdvertisementDecoder decoder(&credential_manager);
|
||||
|
||||
Reference in New Issue
Block a user