public OnActionExecuting ( System.Web.Mvc.ActionExecutingContext filterContext ) : void | ||
filterContext | System.Web.Mvc.ActionExecutingContext | |
return | void |
public void UsesApiKeyColumnToFindUserIfNoRecordInCredentialTable() { ApiKeyAuthorizeAttribute attribute = CreateAttribute(); var apiKey = Guid.NewGuid(); var mockFilterContext = CreateActionFilterContext(apiKey.ToString()); GetMock <IUserService>() .Setup(us => us.FindByApiKey(apiKey)) .Returns(Fakes.Owner); // Act attribute.OnActionExecuting(mockFilterContext.Object); // Assert Assert.Null(mockFilterContext.Object.Result); }
public void UsesCredentialTableToFindUser() { ApiKeyAuthorizeAttribute attribute = CreateAttribute(); var apiKey = Guid.NewGuid(); var mockFilterContext = CreateActionFilterContext(apiKey.ToString()); GetMock <IUserService>() .Setup(us => us.AuthenticateCredential( CredentialTypes.ApiKeyV1, apiKey.ToString().ToLowerInvariant())) .Returns(new Credential() { User = Fakes.Owner }); // Act attribute.OnActionExecuting(mockFilterContext.Object); // Assert Assert.Null(mockFilterContext.Object.Result); }