public void Post_With_Invalid_Grant_Type_Should_Return_404() { A.CallTo(() => _tokenEndpointService.ValidateRequest(A <TokenRequest> .That.Matches(x => x.GrantType == "bad_grant"), A <NancyContext> .Ignored)) .Returns(ErrorType.InvalidGrant); var response = _browser.Post("/oauth/token", with => { with.HttpRequest(); with.FormValue("grant_type", "bad_grant"); }); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public void ValidateRequest_ShouldThrow_NotImplementedException() { var request = new TokenRequest(); var context = new NancyContext(); Assert.Throws <NotImplementedException>(() => _service.ValidateRequest(request, context)); }
private dynamic CreateToken() { var request = this.Bind <TokenRequest>(); var result = _service.ValidateRequest(request, Context); if (!result.IsValid) { return(Response.AsErrorResponse(BuildErrorResponse(result.ErrorType), request.RedirectUri)); } var response = _service.CreateTokenResponse(request, Context); return(Response.AsJson(response)); }