public void Should_Skip_Processig() { var requestDelegate = Substitute.For <RequestDelegate>(); var middleware = new TokenProviderMiddleware(requestDelegate, Options.Create(new TokenProviderOptions())); var context = new DefaultHttpContext(); middleware.Invoke(context, null); var calls = requestDelegate.ReceivedWithAnyArgs(1); }
public async Task Deve_Gerar_Token_Tipo_Password_Ok() { var paramsForm = new Dictionary <String, StringValues>(); paramsForm.Add("grant_type", "password"); paramsForm.Add("username", "12345678900"); paramsForm.Add("password", "123@321"); var formCollection = new FormCollection(paramsForm); var context = new DefaultHttpContext(); context.Request.Method = "POST"; context.Request.Headers["Authorization"] = $"Basic {Configuration.TokenKey}"; context.Request.Path = new PathString("/token"); context.Request.Form = formCollection; await _tokenProviderMiddleware.Invoke(context); Assert.True(context.Response.StatusCode == (int)HttpStatusCode.OK); }
public async void Should_Return_Bad_Request_Response() { TokenProviderMiddleware middleware = GetMiddleware(); var context = new DefaultHttpContext(); context.Request.Method = "GET"; context.Request.Path = TokenProviderOptionFactory.PATH; await middleware.Invoke(context, null); Assert.Equal(400, context.Response.StatusCode); }