public void CheckSchemeAccess_ReturnsTrue_WhenUserHasRequiredClaims() { // Arrange Guid organisationID = Guid.NewGuid(); Guid userId = Guid.NewGuid(); Guid schemeID = new Guid("5F3069F4-EDA3-43A3-BDD8-726028CDABB0"); Domain.Scheme.Scheme scheme = new Domain.Scheme.Scheme(organisationID); typeof(Entity).GetProperty("Id").SetValue(scheme, schemeID); // <- sad but necessary IUserContext userContext = A.Fake <IUserContext>(); WeeeContext weeeContext = MakeFakeWeeeContext( userContext, userId, new List <OrganisationUser> { new OrganisationUser(userId, organisationID, UserStatus.Active) }, new List <Domain.Scheme.Scheme> { scheme }); A.CallTo(() => userContext.UserId).Returns(userId); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckSchemeAccess(schemeID); // Assert Assert.Equal(true, result); }
public void CheckSchemeAccess_ReturnsFalse_WhenUserHasNoClaims() { // Arrange Guid schemeID = new Guid("5F3069F4-EDA3-43A3-BDD8-726028CDABB0"); IUserContext userContext = A.Fake <IUserContext>(); WeeeContext weeeContext = MakeFakeWeeeContext(userContext); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckSchemeAccess(schemeID); // Assert Assert.Equal(false, result); }
public void CheckSchemeAccess_ReturnsTrue_WhenUserHasRequiredClaims() { // Arrange Guid organisationID = Guid.NewGuid(); Guid userId = Guid.NewGuid(); Guid schemeID = new Guid("5F3069F4-EDA3-43A3-BDD8-726028CDABB0"); Domain.Scheme.Scheme scheme = new Domain.Scheme.Scheme(organisationID); typeof(Entity).GetProperty("Id").SetValue(scheme, schemeID); // <- sad but necessary IUserContext userContext = A.Fake<IUserContext>(); WeeeContext weeeContext = MakeFakeWeeeContext( userContext, userId, new List<OrganisationUser> { new OrganisationUser(userId, organisationID, UserStatus.Active) }, new List<Domain.Scheme.Scheme> { scheme }); A.CallTo(() => userContext.UserId).Returns(userId); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckSchemeAccess(schemeID); // Assert Assert.Equal(true, result); }
public void CheckSchemeAccess_ReturnsFalse_WhenUserHasNoClaims() { // Arrange Guid schemeID = new Guid("5F3069F4-EDA3-43A3-BDD8-726028CDABB0"); IUserContext userContext = A.Fake<IUserContext>(); WeeeContext weeeContext = MakeFakeWeeeContext(userContext); WeeeAuthorization authorization = new WeeeAuthorization(weeeContext, userContext); // Act bool result = authorization.CheckSchemeAccess(schemeID); // Assert Assert.Equal(false, result); }