Skip to content

Commit

Permalink
wsd: test: reinitialize the anonymizer
Browse files Browse the repository at this point in the history
Test that re-initialization does change
the salt and counter prefix as expected.

Change-Id: Iac6c032dce202ac71abc33a19e8dcb9e0a5a3cec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
  • Loading branch information
Ashod committed Dec 19, 2024
1 parent 651cac8 commit 790f54e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/WhiteBoxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,30 +740,32 @@ void WhiteBoxTests::testAnonymization()
Anonymizer::anonymizeUrl(fileUrl));

anonymizationSalt = 0;
Anonymizer::initialize(true, anonymizationSalt);

LOK_ASSERT_EQUAL(std::string("#0#5e45aef91248a8aa#"), Anonymizer::anonymizeUrl(name));
LOK_ASSERT_EQUAL(std::string("#0#42027f9b6df09510#"), Anonymizer::anonymizeUrl(name));
Anonymizer::mapAnonymized(name, name);
LOK_ASSERT_EQUAL(name, Anonymizer::anonymizeUrl(name));

LOK_ASSERT_EQUAL(std::string("#2#5c872b2d82ecc8a0#.ext"), Anonymizer::anonymizeUrl(filename));
LOK_ASSERT_EQUAL(std::string("#1#366ab9ebe19ea09e#.ext"), Anonymizer::anonymizeUrl(filename));
Anonymizer::mapAnonymized("filename",
"filename"); // Identity map of the filename without extension.
LOK_ASSERT_EQUAL(filename, Anonymizer::anonymizeUrl(filename));

LOK_ASSERT_EQUAL(std::string("#1#8f8d95bd2a202d00#.odt"),
LOK_ASSERT_EQUAL(std::string("#2#eac31ed57854de54#.odt"),
Anonymizer::anonymizeUrl(filenameTestx));
Anonymizer::mapAnonymized("testx (6)",
"testx (6)"); // Identity map of the filename without extension.
LOK_ASSERT_EQUAL(filenameTestx, Anonymizer::anonymizeUrl(filenameTestx));

LOK_ASSERT_EQUAL(path, Anonymizer::anonymizeUrl(path));

const std::string urlAnonymized = Util::replace(plainUrl, "736_ocgdpzbkm39u", "#3#22c6f0caad277666#");
const std::string urlAnonymized =
Util::replace(plainUrl, "736_ocgdpzbkm39u", "#3#f64fbe55134cd5f0#");
LOK_ASSERT_EQUAL(urlAnonymized, Anonymizer::anonymizeUrl(plainUrl));
Anonymizer::mapAnonymized("736_ocgdpzbkm39u", "736_ocgdpzbkm39u");
LOK_ASSERT_EQUAL(plainUrl, Anonymizer::anonymizeUrl(plainUrl));

const std::string urlAnonymized2 = Util::replace(fileUrl, "secret", "#4#294f0dfb18f6a80b#");
const std::string urlAnonymized2 = Util::replace(fileUrl, "secret", "#4#dcac6c9cae1b3b95#");
LOK_ASSERT_EQUAL(urlAnonymized2, Anonymizer::anonymizeUrl(fileUrl));
Anonymizer::mapAnonymized("secret", "736_ocgdpzbkm39u");
const std::string urlAnonymized3 = Util::replace(fileUrl, "secret", "736_ocgdpzbkm39u");
Expand Down

0 comments on commit 790f54e

Please sign in to comment.