1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

[EC-315] Record user IP and device type for OrgUser and ProviderUser events (#2119)

This commit is contained in:
Thomas Rittson
2022-07-18 10:24:46 +10:00
committed by GitHub
parent 6e19bfeb22
commit 6628dc3336
3 changed files with 93 additions and 2 deletions

View File

@ -64,6 +64,28 @@ namespace Bit.Test.Common.Helpers
public static Expression<Predicate<T>> AssertPropertyEqual<T>(T expected, params string[] excludedPropertyStrings) =>
(T actual) => AssertPropertyEqualPredicate(expected, excludedPropertyStrings)(actual);
private static Predicate<IEnumerable<T>> AssertPropertyEqualPredicate<T>(IEnumerable<T> expected, params string[] excludedPropertyStrings) => (actual) =>
{
// IEnumerable.Zip doesn't account for different lengths, we need to check this ourselves
if (actual.Count() != expected.Count())
{
throw new Exception(string.Concat($"Actual IEnumerable does not have the expected length.\n",
$"Expected: {expected.Count()}\n",
$"Actual: {actual.Count()}"));
}
var elements = expected.Zip(actual);
foreach (var (expectedEl, actualEl) in elements)
{
AssertPropertyEqual(expectedEl, actualEl, excludedPropertyStrings);
}
return true;
};
public static Expression<Predicate<IEnumerable<T>>> AssertPropertyEqual<T>(IEnumerable<T> expected, params string[] excludedPropertyStrings) =>
(actual) => AssertPropertyEqualPredicate(expected, excludedPropertyStrings)(actual);
private static Predicate<T> AssertEqualExpectedPredicate<T>(T expected) => (actual) =>
{
Assert.Equal(expected, actual);