Debian Codegraph @

src/test/unittests/net/SecureUtilsTests.cpp

raw
1 /*
2 barrier -- mouse and keyboard sharing utility
3 Copyright (C) 2021 Barrier contributors
4
5 This package is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 found in the file LICENSE that should have accompanied this file.
8
9 This package is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "net/SecureUtils.h"
19
20 #include "test/global/gtest.h"
21 #include "test/global/TestUtils.h"
22
23 namespace barrier {
24
25 TEST(SecureUtilsTest, FormatSslFingerprintHexWithSeparators)
26 {
27 auto fingerprint = generate_pseudo_random_bytes(0, 32);
28 ASSERT_EQ(format_ssl_fingerprint(fingerprint, true),
29 "28:FD:0A:98:8A:0E:A1:6C:D7:E8:6C:A7:EE:58:41:71:"
30 "CA:B2:8E:49:25:94:90:25:26:05:8D:AF:63:ED:2E:30");
31 }
32
33 TEST(SecureUtilsTest, CreateFingerprintRandomArt)
34 {
35 ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(0, 32)),
36 "+-----------------+\n"
37 "|*X+. . |\n"
38 "|*oo + |\n"
39 "| + = |\n"
40 "| B . . |\n"
41 "|.+... o S |\n"
42 "|E+ ++. . |\n"
43 "|B*++.. . |\n"
44 "|+o*o o . |\n"
45 "|+o*Bo . |\n"
46 "+-----------------+");
47 ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(1, 32)),
48 "+-----------------+\n"
49 "| .oo+ . .B=. |\n"
50 "| .o.+ . o o.= |\n"
51 "|o..+.. o . E * |\n"
52 "|oo..+ . * * |\n"
53 "|B o.....S. o . |\n"
54 "|+=o..... |\n"
55 "| + + . |\n"
56 "|o. .. |\n"
57 "|..o.. |\n"
58 "+-----------------+");
59 ASSERT_EQ(create_fingerprint_randomart(generate_pseudo_random_bytes(2, 32)),
60 "+-----------------+\n"
61 "| ... .o.o.|\n"
62 "| o .=.E|\n"
63 "| . + o ...+.|\n"
64 "| * o = o ... |\n"
65 "| * + S & . |\n"
66 "| = + % @ |\n"
67 "| . . = X o |\n"
68 "| . . O . |\n"
69 "| . + |\n"
70 "+-----------------+");
71 }
72
73 } // namespace barrier