-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-13763 Move ResetPasswordEnrolled to response model (#4983)
to adhere to Liskov Substitution Principle. Ensures request models inherit only relevant properties.
- Loading branch information
1 parent
e06d0f6
commit 87d2cb1
Showing
3 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/Api.Test/AdminConsole/Public/Models/Response/MemberResponseModelTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Bit.Api.AdminConsole.Public.Models.Response; | ||
using Bit.Core.Entities; | ||
using Bit.Core.Models.Data; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Bit.Api.Test.AdminConsole.Public.Models.Response; | ||
|
||
|
||
public class MemberResponseModelTests | ||
{ | ||
[Fact] | ||
public void ResetPasswordEnrolled_ShouldBeTrue_WhenUserHasResetPasswordKey() | ||
{ | ||
// Arrange | ||
var user = Substitute.For<OrganizationUser>(); | ||
var collections = Substitute.For<IEnumerable<CollectionAccessSelection>>(); | ||
user.ResetPasswordKey = "none-empty"; | ||
|
||
|
||
// Act | ||
var sut = new MemberResponseModel(user, collections); | ||
|
||
// Assert | ||
Assert.True(sut.ResetPasswordEnrolled); | ||
} | ||
|
||
[Fact] | ||
public void ResetPasswordEnrolled_ShouldBeFalse_WhenUserDoesNotHaveResetPasswordKey() | ||
{ | ||
// Arrange | ||
var user = Substitute.For<OrganizationUser>(); | ||
var collections = Substitute.For<IEnumerable<CollectionAccessSelection>>(); | ||
|
||
// Act | ||
var sut = new MemberResponseModel(user, collections); | ||
|
||
// Assert | ||
Assert.False(sut.ResetPasswordEnrolled); | ||
} | ||
} |