tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

LimitedAccessFeatureTests.cpp (1748B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "gtest/gtest.h"
      7 
      8 #include "Windows11LimitedAccessFeatures.h"
      9 #include "WinUtils.h"
     10 
     11 TEST(LimitedAccessFeature, VerifyGeneratedInfo)
     12 {
     13  // If running on MSIX we have no guarantee that the
     14  // generated LAF info will match the known values.
     15  if (mozilla::widget::WinUtils::HasPackageIdentity()) {
     16    return;
     17  }
     18 
     19  LimitedAccessFeatureInfo knownLafInfo = {
     20      // Win11LimitedAccessFeatureType::Taskbar
     21      "Win11LimitedAccessFeatureType::Taskbar"_ns,      // debugName
     22      u"com.microsoft.windows.taskbar.pin"_ns,          // feature
     23      u"kRFiWpEK5uS6PMJZKmR7MQ=="_ns,                   // token
     24      u"pcsmm0jrprpb2 has registered their use of "_ns  // attestation
     25      u"com.microsoft.windows.taskbar.pin with Microsoft and agrees to the "_ns
     26      u"terms "_ns
     27      u"of use."_ns};
     28 
     29  auto generatedLafInfoResult = GenerateLimitedAccessFeatureInfo(
     30      "Win11LimitedAccessFeatureType::Taskbar"_ns,
     31      u"com.microsoft.windows.taskbar.pin"_ns);
     32  ASSERT_TRUE(generatedLafInfoResult.isOk());
     33  LimitedAccessFeatureInfo generatedLafInfo = generatedLafInfoResult.unwrap();
     34 
     35  // Check for equality between generated values and known good values
     36  ASSERT_TRUE(knownLafInfo.debugName.Equals(generatedLafInfo.debugName));
     37  ASSERT_TRUE(knownLafInfo.feature.Equals(generatedLafInfo.feature));
     38  ASSERT_TRUE(knownLafInfo.token.Equals(generatedLafInfo.token));
     39  ASSERT_TRUE(knownLafInfo.attestation.Equals(generatedLafInfo.attestation));
     40 }