mirror of
https://github.com/bitwarden/server
synced 2026-01-08 03:23:20 +00:00
fix(auth-validator): [PM-22975] Client Version Validator - Fixed tests
This commit is contained in:
@@ -66,10 +66,10 @@ public class ApiApplicationFactory : WebApplicationFactoryBase<Startup>
|
|||||||
KdfIterations = AuthConstants.PBKDF2_ITERATIONS.Default,
|
KdfIterations = AuthConstants.PBKDF2_ITERATIONS.Default,
|
||||||
UserAsymmetricKeys = new KeysRequestModel()
|
UserAsymmetricKeys = new KeysRequestModel()
|
||||||
{
|
{
|
||||||
PublicKey = "public_key",
|
PublicKey = "pk_test",
|
||||||
EncryptedPrivateKey = "private_key"
|
EncryptedPrivateKey = "2.iv|ct|mac" // v1-format so parsing succeeds and user is treated as v1
|
||||||
},
|
},
|
||||||
UserSymmetricKey = "sym_key",
|
UserSymmetricKey = "2.iv|ct|mac",
|
||||||
});
|
});
|
||||||
|
|
||||||
return await _identityApplicationFactory.TokenFromPasswordAsync(email, masterPasswordHash);
|
return await _identityApplicationFactory.TokenFromPasswordAsync(email, masterPasswordHash);
|
||||||
|
|||||||
@@ -225,37 +225,7 @@ public static class AssertHelper
|
|||||||
|
|
||||||
public async static Task<T> AssertResponseTypeIs<T>(HttpContext context)
|
public async static Task<T> AssertResponseTypeIs<T>(HttpContext context)
|
||||||
{
|
{
|
||||||
try
|
return await JsonSerializer.DeserializeAsync<T>(context.Response.Body);
|
||||||
{
|
|
||||||
if (context.Response.Body.CanSeek)
|
|
||||||
{
|
|
||||||
context.Response.Body.Position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await JsonSerializer.DeserializeAsync<T>(context.Response.Body);
|
|
||||||
}
|
|
||||||
catch (JsonException ex)
|
|
||||||
{
|
|
||||||
string bodyText = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (context.Response.Body.CanSeek)
|
|
||||||
{
|
|
||||||
context.Response.Body.Position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var sr = new StreamReader(context.Response.Body, leaveOpen: true);
|
|
||||||
bodyText = await sr.ReadToEndAsync();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignore read errors
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Xunit.Sdk.XunitException(
|
|
||||||
$"Failed to deserialize response to {typeof(T).Name}. " +
|
|
||||||
$"StatusCode: {context.Response.StatusCode}. Body:\n{bodyText}\nException: {ex}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TimeSpan AssertRecent(DateTime dateTime, int skewSeconds = 2)
|
public static TimeSpan AssertRecent(DateTime dateTime, int skewSeconds = 2)
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ public static class WebApplicationFactoryExtensions
|
|||||||
httpContext.Request.Body = content.ReadAsStream();
|
httpContext.Request.Body = content.ReadAsStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
httpContext.Request.Headers.Append("Bitwarden-Client-Version", "2025.11.0");
|
|
||||||
|
|
||||||
extraConfiguration?.Invoke(httpContext);
|
extraConfiguration?.Invoke(httpContext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user