File: standalone_trusted_vault_server_constants_unittest.cc

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (51 lines) | stat: -rw-r--r-- 1,942 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/trusted_vault/standalone_trusted_vault_server_constants.h"

#include <cstdint>
#include <vector>

#include "components/trusted_vault/securebox.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace trusted_vault {

namespace {

using testing::Eq;

TEST(StandaloneTrustedVaultServerConstantsTest,
     ShouldGetGetSecurityDomainMemberURL) {
  const GURL kTestUrl("https://example.com/v1/");

  // Arbitrary key, with an appropriate length.
  const std::vector<uint8_t> kPublicKey{
      0x4,  0xF2, 0x4C, 0x45, 0xBA, 0xF4, 0xF8, 0x6C, 0xF9, 0x73, 0xCE,
      0x75, 0xC,  0xC9, 0xD4, 0xF,  0x4A, 0x53, 0xB7, 0x85, 0x46, 0x41,
      0xFB, 0x31, 0x17, 0xF,  0xEB, 0xB,  0x45, 0xE4, 0x29, 0x69, 0x9B,
      0xB2, 0x7,  0x12, 0xC1, 0x9,  0x3D, 0xEF, 0xBB, 0x57, 0xDC, 0x56,
      0x12, 0x29, 0xF2, 0x73, 0xE1, 0xC5, 0x99, 0x1C, 0x49, 0x3A, 0xA2,
      0x30, 0xF9, 0xBA, 0x3B, 0xB1, 0x83, 0xCF, 0x1B, 0x5D, 0xE8};

  // Guard against future code changes, in case the key length changes.
  ASSERT_THAT(kPublicKey.size(), Eq(SecureBoxKeyPair::GenerateRandom()
                                        ->public_key()
                                        .ExportToBytes()
                                        .size()));

  // Note that production code (TrustedVaultRequest::CreateURLLoader) will
  // append &alt=proto to the URL.
  EXPECT_THAT(GetGetSecurityDomainMemberURL(kTestUrl, kPublicKey).spec(),
              Eq("https://example.com/v1/users/me/members/"
                 "BPJMRbr0-Gz5c851DMnUD0pTt4VGQfsxFw_"
                 "rC0XkKWmbsgcSwQk977tX3FYSKfJz4cWZHEk6ojD5ujuxg88bXeg"
                 "?view=2"
                 "&request_header.force_master_read=true"));
}

}  // namespace

}  // namespace trusted_vault