1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00

Merge branch 'main' into jmccannon/ac/pm-16811-scim-invite-optimization

This commit is contained in:
Jared McCannon 2025-03-17 15:19:36 -05:00 committed by GitHub
commit 7f87922684
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View File

@ -250,21 +250,26 @@ public class DeviceValidator(
var customResponse = new Dictionary<string, object>(); var customResponse = new Dictionary<string, object>();
switch (errorType) switch (errorType)
{ {
/*
* The ErrorMessage is brittle and is used to control the flow in the clients. Do not change them without updating the client as well.
* There is a backwards compatibility issue as well: if you make a change on the clients then ensure that they are backwards
* compatible.
*/
case DeviceValidationResultType.InvalidUser: case DeviceValidationResultType.InvalidUser:
result.ErrorDescription = "Invalid user"; result.ErrorDescription = "Invalid user";
customResponse.Add("ErrorModel", new ErrorResponseModel("Invalid user.")); customResponse.Add("ErrorModel", new ErrorResponseModel("invalid user"));
break; break;
case DeviceValidationResultType.InvalidNewDeviceOtp: case DeviceValidationResultType.InvalidNewDeviceOtp:
result.ErrorDescription = "Invalid New Device OTP"; result.ErrorDescription = "Invalid New Device OTP";
customResponse.Add("ErrorModel", new ErrorResponseModel("Invalid new device OTP. Try again.")); customResponse.Add("ErrorModel", new ErrorResponseModel("invalid new device otp"));
break; break;
case DeviceValidationResultType.NewDeviceVerificationRequired: case DeviceValidationResultType.NewDeviceVerificationRequired:
result.ErrorDescription = "New device verification required"; result.ErrorDescription = "New device verification required";
customResponse.Add("ErrorModel", new ErrorResponseModel("New device verification required.")); customResponse.Add("ErrorModel", new ErrorResponseModel("new device verification required"));
break; break;
case DeviceValidationResultType.NoDeviceInformationProvided: case DeviceValidationResultType.NoDeviceInformationProvided:
result.ErrorDescription = "No device information provided"; result.ErrorDescription = "No device information provided";
customResponse.Add("ErrorModel", new ErrorResponseModel("No device information provided.")); customResponse.Add("ErrorModel", new ErrorResponseModel("no device information provided"));
break; break;
} }
return (result, customResponse); return (result, customResponse);

View File

@ -172,7 +172,7 @@ public class DeviceValidatorTests
Assert.False(result); Assert.False(result);
Assert.NotNull(context.CustomResponse["ErrorModel"]); Assert.NotNull(context.CustomResponse["ErrorModel"]);
var expectedErrorModel = new ErrorResponseModel("No device information provided."); var expectedErrorModel = new ErrorResponseModel("no device information provided");
var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"]; var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"];
Assert.Equal(expectedErrorModel.Message, actualResponse.Message); Assert.Equal(expectedErrorModel.Message, actualResponse.Message);
} }
@ -418,7 +418,7 @@ public class DeviceValidatorTests
Assert.False(result); Assert.False(result);
Assert.NotNull(context.CustomResponse["ErrorModel"]); Assert.NotNull(context.CustomResponse["ErrorModel"]);
// PM-13340: The error message should be "invalid user" instead of "no device information provided" // PM-13340: The error message should be "invalid user" instead of "no device information provided"
var expectedErrorMessage = "No device information provided."; var expectedErrorMessage = "no device information provided";
var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"]; var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"];
Assert.Equal(expectedErrorMessage, actualResponse.Message); Assert.Equal(expectedErrorMessage, actualResponse.Message);
} }
@ -552,7 +552,7 @@ public class DeviceValidatorTests
Assert.False(result); Assert.False(result);
Assert.NotNull(context.CustomResponse["ErrorModel"]); Assert.NotNull(context.CustomResponse["ErrorModel"]);
var expectedErrorMessage = "Invalid new device OTP. Try again."; var expectedErrorMessage = "invalid new device otp";
var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"]; var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"];
Assert.Equal(expectedErrorMessage, actualResponse.Message); Assert.Equal(expectedErrorMessage, actualResponse.Message);
} }
@ -604,7 +604,7 @@ public class DeviceValidatorTests
Assert.False(result); Assert.False(result);
Assert.NotNull(context.CustomResponse["ErrorModel"]); Assert.NotNull(context.CustomResponse["ErrorModel"]);
var expectedErrorMessage = "New device verification required."; var expectedErrorMessage = "new device verification required";
var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"]; var actualResponse = (ErrorResponseModel)context.CustomResponse["ErrorModel"];
Assert.Equal(expectedErrorMessage, actualResponse.Message); Assert.Equal(expectedErrorMessage, actualResponse.Message);
} }