Rename OTM* to CancellationM* test classes 10/309610/5
authorKrzysztof Malysa <k.malysa@samsung.com>
Fri, 12 Apr 2024 11:35:50 +0000 (13:35 +0200)
committerKrzysztof Malysa <k.malysa@samsung.com>
Tue, 16 Apr 2024 13:05:05 +0000 (15:05 +0200)
CancellationM* mock classes are used for testing cancelling from the other
thread.

Change-Id: Id87fc9db2a9b49a5f60d526524f10d9718a6f496

tests/bluetooth_tests.cpp
tests/ctap_message_processor_tests.cpp
tests/encrypted_tunnel_tests.cpp
tests/handshake_tests.cpp
tests/qr_transaction_tests.cpp
tests/state_assisted_transaction_tests.cpp
tests/transaction_test.h

index 52da16fa3718d094479230982222bd9922997f07..3831aaee68ab653390359c4390d0ee7823fb0df8 100644 (file)
@@ -414,7 +414,7 @@ TEST(BtAdvertScanner, cancelling_never_ending_scan)
 
 namespace {
 
-class OTMBluetooth : public BluetoothMock {
+class CancellationMBluetooth : public BluetoothMock {
 public:
     using BluetoothMock::BluetoothMock;
 
@@ -459,10 +459,10 @@ TEST(BtAdvertScanner, cancel_from_the_other_thread)
 
     CryptoBuffer decryptedAdvert;
     auto transactionMaker = [&] {
-        return BtAdvertScanner(
-            std::make_unique<OTMBluetooth>(true,
-                                           BleAdverts{
-                                               {"FFF9", serviceData, IBluetooth::Scanning::STOP}
+        return BtAdvertScanner(std::make_unique<CancellationMBluetooth>(
+            true,
+            BleAdverts{
+                {"FFF9", serviceData, IBluetooth::Scanning::STOP}
         }));
     };
 
index 2b447d32595bccd1e45ccb50587aa22abb22b6e1..6c85591692b1699cc734474f57c7a21517a4e512 100644 (file)
@@ -830,7 +830,7 @@ TEST(CtapMessageProcessor, TooShortReceivedMessageDuringGetAssertionWithUpdate)
 
 namespace {
 
-class OTMEncryptedTunnel : public MEncryptedTunnel {
+class CancellationMEncryptedTunnel : public MEncryptedTunnel {
 public:
     using MEncryptedTunnel::MEncryptedTunnel;
 
@@ -858,10 +858,11 @@ TEST(CtapMessageProcessor, MakeCredential_without_update_message_cancel_from_the
 {
     auto makeCMP = [&] {
         CtapMessageProcessor cmp;
-        cmp.SetEncryptedTunnel(std::make_unique<OTMEncryptedTunnel>(std::vector<CryptoBuffer>{
-            ToBuffer(IPHONE_POST_HANDSHAKE_RESPONSE),
-            ToBuffer(IPHONE_EXAMPLE_MAKE_CREDENTIAL_RAW_RESPONSE),
-        }));
+        cmp.SetEncryptedTunnel(
+            std::make_unique<CancellationMEncryptedTunnel>(std::vector<CryptoBuffer>{
+                ToBuffer(IPHONE_POST_HANDSHAKE_RESPONSE),
+                ToBuffer(IPHONE_EXAMPLE_MAKE_CREDENTIAL_RAW_RESPONSE),
+            }));
         return cmp;
     };
     TestCancelFromTheOtherThread<ICtapMessageProcessor>(
@@ -876,11 +877,12 @@ TEST(CtapMessageProcessor, MakeCredential_with_update_message_cancel_from_the_ot
 {
     auto makeCMP = [&] {
         CtapMessageProcessor cmp;
-        cmp.SetEncryptedTunnel(std::make_unique<OTMEncryptedTunnel>(std::vector<CryptoBuffer>{
-            ToBuffer(ANDROID_POST_HANDSHAKE_RESPONSE),
-            ToBuffer(ANDROID_EXAMPLE_RAW_UPDATE_MSG),
-            ToBuffer(ANDROID_EXAMPLE_MAKE_CREDENTIAL_RAW_RESPONSE),
-        }));
+        cmp.SetEncryptedTunnel(
+            std::make_unique<CancellationMEncryptedTunnel>(std::vector<CryptoBuffer>{
+                ToBuffer(ANDROID_POST_HANDSHAKE_RESPONSE),
+                ToBuffer(ANDROID_EXAMPLE_RAW_UPDATE_MSG),
+                ToBuffer(ANDROID_EXAMPLE_MAKE_CREDENTIAL_RAW_RESPONSE),
+            }));
         return cmp;
     };
     TestCancelFromTheOtherThread<ICtapMessageProcessor>(
@@ -895,10 +897,11 @@ TEST(CtapMessageProcessor, GetAssertion_without_update_message_cancel_from_the_o
 {
     auto makeCMP = [&] {
         CtapMessageProcessor cmp;
-        cmp.SetEncryptedTunnel(std::make_unique<OTMEncryptedTunnel>(std::vector<CryptoBuffer>{
-            ToBuffer(IPHONE_POST_HANDSHAKE_RESPONSE),
-            ToBuffer(IPHONE_EXAMPLE_GET_ASSERTION_RAW_RESPONSE),
-        }));
+        cmp.SetEncryptedTunnel(
+            std::make_unique<CancellationMEncryptedTunnel>(std::vector<CryptoBuffer>{
+                ToBuffer(IPHONE_POST_HANDSHAKE_RESPONSE),
+                ToBuffer(IPHONE_EXAMPLE_GET_ASSERTION_RAW_RESPONSE),
+            }));
         return cmp;
     };
     TestCancelFromTheOtherThread<ICtapMessageProcessor>(
@@ -913,11 +916,12 @@ TEST(CtapMessageProcessor, GetAssertion_with_update_message_cancel_from_the_othe
 {
     auto makeCMP = [&] {
         CtapMessageProcessor cmp;
-        cmp.SetEncryptedTunnel(std::make_unique<OTMEncryptedTunnel>(std::vector<CryptoBuffer>{
-            ToBuffer(ANDROID_POST_HANDSHAKE_RESPONSE),
-            ToBuffer(ANDROID_EXAMPLE_RAW_UPDATE_MSG),
-            ToBuffer(ANDROID_EXAMPLE_GET_ASSERTION_RAW_RESPONSE),
-        }));
+        cmp.SetEncryptedTunnel(
+            std::make_unique<CancellationMEncryptedTunnel>(std::vector<CryptoBuffer>{
+                ToBuffer(ANDROID_POST_HANDSHAKE_RESPONSE),
+                ToBuffer(ANDROID_EXAMPLE_RAW_UPDATE_MSG),
+                ToBuffer(ANDROID_EXAMPLE_GET_ASSERTION_RAW_RESPONSE),
+            }));
         return cmp;
     };
     TestCancelFromTheOtherThread<ICtapMessageProcessor>(
index 0fbb7e9df0af9207fd97a4f82d3721357499d2fe..f75665f588955895d841fedcd6ca4301b31666a9 100644 (file)
@@ -142,7 +142,7 @@ TEST(EncryptedTunnel, invalid_data)
 
 namespace {
 
-class OTMEchoTunnel : public ITunnel {
+class CancellationMEchoTunnel : public ITunnel {
 public:
     void Connect(const std::string &, std::optional<ExtraHttpHeader>) override
     {
@@ -177,7 +177,8 @@ TEST(EncryptedTunnel, cancel_from_the_other_thread)
     auto readerWriter = Crypto::Noise::SymmetricState::CipherState{
         CryptoBuffer(Crypto::Noise::KEY_AND_HASH_LEN, 0x5f)};
     auto makeEncryptedTunnel = [&] {
-        return EncryptedTunnel(std::make_unique<OTMEchoTunnel>(), readerWriter, readerWriter);
+        return EncryptedTunnel(
+            std::make_unique<CancellationMEchoTunnel>(), readerWriter, readerWriter);
     };
     TestCancelFromTheOtherThread<IEncryptedTunnel>(
         400, 40, makeEncryptedTunnel, [&](IEncryptedTunnel &encryptedTunnel) {
index d163e58a513bc0e1026cf10fd30976d00b56f98f..639da7da7c2b8ea33f75e8bc16663a5e10a88b19 100644 (file)
@@ -295,7 +295,7 @@ TEST(Handshake, DoStateAssistedHandshake)
 
 namespace {
 
-class OTConnectMTunnel : public ShouldNotBeUsedMTunnel {
+class CancellationConnectMTunnel : public ShouldNotBeUsedMTunnel {
 public:
     void Connect(const std::string &, std::optional<ExtraHttpHeader> = std::nullopt) override
     {
@@ -312,7 +312,7 @@ private:
 
 TEST(Handshake, qr_initiated_connect)
 {
-    auto makeHandshake = [&] { return Handshake{std::make_unique<OTConnectMTunnel>()}; };
+    auto makeHandshake = [&] { return Handshake{std::make_unique<CancellationConnectMTunnel>()}; };
     TestCancelFromTheOtherThread<IHandshake>(400, 40, makeHandshake, [&](IHandshake &handshake) {
         handshake.QrInitiatedConnect({}, {}, {});
     });
@@ -320,7 +320,7 @@ TEST(Handshake, qr_initiated_connect)
 
 TEST(Handshake, state_assisted_connect)
 {
-    auto makeHandshake = [&] { return Handshake{std::make_unique<OTConnectMTunnel>()}; };
+    auto makeHandshake = [&] { return Handshake{std::make_unique<CancellationConnectMTunnel>()}; };
     TestCancelFromTheOtherThread<IHandshake>(400, 40, makeHandshake, [&](IHandshake &handshake) {
         handshake.StateAssistedConnect({}, {}, {});
     });
@@ -328,12 +328,12 @@ TEST(Handshake, state_assisted_connect)
 
 namespace {
 
-class OTHandshakeMTunnel : public HandshakeMTunnel {
+class CancellationHandshakeMTunnel : public HandshakeMTunnel {
 public:
-    OTHandshakeMTunnel(CryptoBuffer psk,
-                       const Crypto::X9_62_P_256_Key *platformPubKey,
-                       const Crypto::X9_62_P_256_Key *authenticatorPrivKey,
-                       CryptoBuffer getInfoMsg)
+    CancellationHandshakeMTunnel(CryptoBuffer psk,
+                                 const Crypto::X9_62_P_256_Key *platformPubKey,
+                                 const Crypto::X9_62_P_256_Key *authenticatorPrivKey,
+                                 CryptoBuffer getInfoMsg)
     : HandshakeMTunnel{std::move(psk), platformPubKey, authenticatorPrivKey, std::move(getInfoMsg)}
     {
     }
@@ -360,7 +360,7 @@ private:
 
 TEST(Handshake, qr_initiated_handshake_cancel_from_the_other_thread)
 {
-    auto test = QrInitiatedHandshakeTest<OTHandshakeMTunnel>{};
+    auto test = QrInitiatedHandshakeTest<CancellationHandshakeMTunnel>{};
     auto makeHandshake = [&] { return test.MakeHandshake(); };
     TestCancelFromTheOtherThread<IHandshake>(200, 20, makeHandshake, [&](IHandshake &handshake) {
         test.RunAndTestHandshake(handshake);
@@ -369,7 +369,7 @@ TEST(Handshake, qr_initiated_handshake_cancel_from_the_other_thread)
 
 TEST(Handshake, state_assisted_handshake_cancel_from_the_other_thread)
 {
-    auto test = StateAssistedHandshakeTest<OTHandshakeMTunnel>{};
+    auto test = StateAssistedHandshakeTest<CancellationHandshakeMTunnel>{};
     auto makeHandshake = [&] { return test.MakeHandshake(); };
     TestCancelFromTheOtherThread<IHandshake>(200, 20, makeHandshake, [&](IHandshake &handshake) {
         test.RunAndTestHandshake(handshake);
index 686a299e2ee32fcffb27305fe8bdf61d5ed4ded0..d13347923c00494f0d51d917b5070c0b09f29d6b 100644 (file)
@@ -236,7 +236,7 @@ TEST(QrTransaction, Cancel)
 
 namespace {
 
-class OTMQrCodeShower : public IQrCodeShower {
+class CancellationMQrCodeShower : public IQrCodeShower {
 public:
     void ShowQrCode(const CryptoBuffer &,
                     const CryptoBuffer &,
@@ -252,7 +252,7 @@ private:
     CancelFacilitator m_cancelFacilitator;
 };
 
-class OTMHandshake : public IHandshake {
+class CancellationMHandshake : public IHandshake {
 public:
     void QrInitiatedConnect(const std::string &, const BufferView &, const BufferView &) override
     {
@@ -293,10 +293,10 @@ TEST(QrTransaction, cancel_from_the_other_thread)
             nullptr,
             nullptr,
             {},
-            std::make_unique<OTMQrCodeShower>(),
-            std::make_unique<OTMBtAdvertScanner<&GenerateDecryptedBluetoothAdvert>>(),
-            std::make_unique<OTMHandshake>(),
-            std::make_unique<OTMCtapMessageProcessor>());
+            std::make_unique<CancellationMQrCodeShower>(),
+            std::make_unique<CancellationMBtAdvertScanner<&GenerateDecryptedBluetoothAdvert>>(),
+            std::make_unique<CancellationMHandshake>(),
+            std::make_unique<CancellationMCtapMessageProcessor>());
     };
     TestCancelFromTheOtherThread<ITransaction>(
         400, 40, makeTransaction, [](ITransaction &transaction) {
index e7115cd9a38708901ff01aafeb80d99ed8ede00c..9ea9fa73fd976cfb1d3b33b267f495f273cfa459 100644 (file)
@@ -311,7 +311,7 @@ TEST(StateAssistedTransaction, InvalidLinkData)
 
 namespace {
 
-class OTMHandshake : public IHandshake {
+class CancellationMHandshake : public IHandshake {
 public:
     void QrInitiatedConnect(const std::string &, const BufferView &, const BufferView &) override
     {
@@ -351,9 +351,9 @@ TEST(StateAssistedTransaction, cancel_from_the_other_thread)
     auto makeTransaction = [&] {
         return StateAssistedTransaction(
             {},
-            std::make_unique<OTMHandshake>(),
-            std::make_unique<OTMBtAdvertScanner<&DecryptedBluetoothAdvert>>(),
-            std::make_unique<OTMCtapMessageProcessor>());
+            std::make_unique<CancellationMHandshake>(),
+            std::make_unique<CancellationMBtAdvertScanner<&DecryptedBluetoothAdvert>>(),
+            std::make_unique<CancellationMCtapMessageProcessor>());
     };
     TestCancelFromTheOtherThread<ITransaction>(
         400, 40, makeTransaction, [](ITransaction &transaction) {
index 1b50497ba429c2c7fbd71d80c829504f1e6756ad..02f5c7f820c95dc746b4d78910c825060566d64a 100644 (file)
@@ -87,7 +87,7 @@ public:
 };
 
 template <CryptoBuffer (*decryptedAdvertGenerator)()>
-class OTMBtAdvertScanner : public IBtAdvertScanner {
+class CancellationMBtAdvertScanner : public IBtAdvertScanner {
 public:
     void AwaitAdvert(const CryptoBuffer & /*eidKey*/, CryptoBuffer &decryptedAdvert) override
     {
@@ -100,7 +100,7 @@ private:
     CancelFacilitator m_cancelFacilitator;
 };
 
-class OTMCtapMessageProcessor : public ICtapMessageProcessor {
+class CancellationMCtapMessageProcessor : public ICtapMessageProcessor {
 public:
     void SetEncryptedTunnel(std::unique_ptr<IEncryptedTunnel>) override {}