mirror of
https://github.com/bitwarden/server.git
synced 2024-11-29 13:25:17 +01:00
a349f28840
* Add new logic for validating encrypted strings
* Add benchmarks
* Formatting & Comments
* Move Debug assertion to just be a test
* Address PR feedback pt.1
* Address more PR feedback
* Formatting
* merge branch 'master' into 'encrypted-string-perf'
* Revert "merge branch 'master' into 'encrypted-string-perf'"
This reverts commit a20e127c9c
.
24 lines
6.1 KiB
C#
24 lines
6.1 KiB
C#
using BenchmarkDotNet.Attributes;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.MicroBenchmarks.Core;
|
|
|
|
[MemoryDiagnoser]
|
|
public class EncryptedStringAttributeTests
|
|
{
|
|
private readonly EncryptedStringAttribute _encryptedStringAttribute;
|
|
public EncryptedStringAttributeTests()
|
|
{
|
|
_encryptedStringAttribute = new EncryptedStringAttribute();
|
|
}
|
|
|
|
public const string Short = @"2.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==|QmFzZTY0UGFydA==";
|
|
public const string Long = @"2.KllcSp3E124kblnMlCNQuQ==|G0jvyocNBOEzCyJ/f951Pz348MPi2RLzmsbfOAOtszi5L9WAkWe4L5T2gJukRMgDSvdE76MVUqREsgQZME52t8JFpVzsQU7Ee56szoJu\u002BAHHQkBNd5J2WirgprDRmIGiSdbvv2GoCszr1b2Ox/Pc\u002B9wjjzMjR6ZA3xhvy1UPyFdT5edQvIFVRSOEG7ivtV7RmGxiq7buP/g\u002BL/epeuiljkjU7KU8JbZRKaxhGLSiofEMlBtaTZtTGh3VKAHslUgPnRIRlHpjPDaT1Yw3la4YHbEOs4Y/XJ5sI4q5xXlK60gMgAlvlyH0mspezaBy367WBLu\u002BWC/4GqGBudhftSOED/aIS4PoCUvMdftwHunXjE2s5zDUwT66w30lvEvJbs7m/36fKAj9ujqOv9vEm1Ukjxhzk\u002BHHkLUcjrD57Zfn0P\u002BzK6wbneYBORObF70gUhcINv64GqgLFlEUecmKjK0ZgcmTXp8XuG2ZfplXAN1y8gySM3UAREhFj4oQtZq/Q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edfrsQpYXdQkOxhL9aE6r1\u002Bj8eHenC6ezxMc6LnsLog2wDMAXlzmq9KkladqyltzL2sgTyg7R57agFrjJtGQfLb0IY0O8vhkwqq2KYhWJ7jOJA\u002BR0k62HZEeNMsreNBNO5l0QCQ0\u002BUGKpEtvX/F5DNj07Swz\u002BoiHWq2933yQ4pzXnYnIfNgb8Ni5Js/GMn5HNJFvsNgYQ/xV1iKnIH43qDoyw55t22Sg4kcHhQBSBSWEZ7u/iVHCSN3hW7ma5Eabbk15/Jg4TurDpthtufZqZ2ZAiOWBaiOUC/OHUI8PjquycGpOGrTauVh\u002BCiS47S5nMPrF6ROVTT\u002BjrfaC9cw0\u002BIf0wEMG/W/p57n5YE7JnLr5kwKEDHCk3mMdxqhYzIoRBiKndblcM1\u002B7Glm5dN78R4mgt2QUGERnVkP\u002BoDxszTshjeZ0EX1l9zuF3V2zt1WzzDH8BiY/zVrhuJsRGSwLsVCpBKZArSfa1cLIufuF9cj5QtYu9NyKi2aVDILdN1fsFqaZ9i5Zsg8ohsLHzYQtY1RZVhNrmI=|MiBu248yFOf9eakCDaO\u002BK7aU2gu/T9R8YSbf7kkHuXg=";
|
|
|
|
[Params(Short, Long)]
|
|
public string EncryptedString { get; set; } = null!;
|
|
|
|
[Benchmark]
|
|
public bool IsValid() => _encryptedStringAttribute.IsValid(EncryptedString);
|
|
}
|