mirror of
https://github.com/bitwarden/server
synced 2026-01-02 00:23:40 +00:00
test(auth-validator): [PM-22975] Client Version Validator - Added stubs and updated test for encryption parsing tests.
This commit is contained in:
@@ -5,6 +5,15 @@ public static class TestEncryptionConstants
|
||||
// Intended for use as a V1 encrypted string, accepted by validators
|
||||
public const string AES256_CBC_HMAC_Encstring = "2.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==|QmFzZTY0UGFydA==";
|
||||
|
||||
// Simple stubs for other encstring versions used by parsing tests
|
||||
public const string AES256_CBC_B64_Encstring = "0.stub";
|
||||
public const string AES128_CBC_HMACSHA256_B64_Encstring = "1.stub";
|
||||
public const string AES256_CBC_HMAC_EmptySuffix = "2.";
|
||||
public const string RSA2048_OAEPSHA256_B64_Encstring = "3.stub";
|
||||
public const string RSA2048_OAEPSHA1_B64_Encstring = "4.stub";
|
||||
public const string RSA2048_OAEPSHA256_HMACSHA256_B64_Encstring = "5.stub";
|
||||
public const string RSA2048_OAEPSHA1_HMACSHA256_B64_Encstring = "6.stub";
|
||||
|
||||
// Public key test placeholder
|
||||
public const string PublicKey = "pk_test";
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.KeyManagement.Utilities;
|
||||
using Bit.Test.Common.Constants;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.KeyManagement.Utilities;
|
||||
@@ -23,15 +24,16 @@ public class EncryptionParsingTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0.foo", EncryptionType.AesCbc256_B64)]
|
||||
[InlineData("1.bar", EncryptionType.AesCbc128_HmacSha256_B64)]
|
||||
[InlineData("2.qux", EncryptionType.AesCbc256_HmacSha256_B64)]
|
||||
[InlineData("3.any", EncryptionType.Rsa2048_OaepSha256_B64)]
|
||||
[InlineData("4.any", EncryptionType.Rsa2048_OaepSha1_B64)]
|
||||
[InlineData("5.any", EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64)]
|
||||
[InlineData("6.any", EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64)]
|
||||
[InlineData("7.any", EncryptionType.XChaCha20Poly1305_B64)]
|
||||
[InlineData("2.", EncryptionType.AesCbc256_HmacSha256_B64)] // empty suffix still valid
|
||||
[InlineData(TestEncryptionConstants.AES256_CBC_B64_Encstring, EncryptionType.AesCbc256_B64)]
|
||||
[InlineData(TestEncryptionConstants.AES128_CBC_HMACSHA256_B64_Encstring, EncryptionType.AesCbc128_HmacSha256_B64)]
|
||||
[InlineData(TestEncryptionConstants.AES256_CBC_HMAC_Encstring, EncryptionType.AesCbc256_HmacSha256_B64)]
|
||||
[InlineData(TestEncryptionConstants.RSA2048_OAEPSHA256_B64_Encstring, EncryptionType.Rsa2048_OaepSha256_B64)]
|
||||
[InlineData(TestEncryptionConstants.RSA2048_OAEPSHA1_B64_Encstring, EncryptionType.Rsa2048_OaepSha1_B64)]
|
||||
[InlineData(TestEncryptionConstants.RSA2048_OAEPSHA256_HMACSHA256_B64_Encstring, EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64)]
|
||||
[InlineData(TestEncryptionConstants.RSA2048_OAEPSHA1_HMACSHA256_B64_Encstring, EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64)]
|
||||
[InlineData(TestEncryptionConstants.V2PrivateKey, EncryptionType.XChaCha20Poly1305_B64)]
|
||||
[InlineData(TestEncryptionConstants.V2WrappedSigningKey, EncryptionType.XChaCha20Poly1305_B64)]
|
||||
[InlineData(TestEncryptionConstants.AES256_CBC_HMAC_EmptySuffix, EncryptionType.AesCbc256_HmacSha256_B64)] // empty suffix still valid
|
||||
public void GetEncryptionType_WithValidString_ReturnsExpected(string input, EncryptionType expected)
|
||||
{
|
||||
var result = EncryptionParsing.GetEncryptionType(input);
|
||||
|
||||
Reference in New Issue
Block a user