private async Task <HttpResponseMessage> TestRequestAsync(IVerifyCaptcha verifyCaptcha, string header, string endpoint, int expectedStatusCode, bool isReCaptchaEnabled = true)
        {
            using var client = this.GetHttpClient(verifyCaptcha, isReCaptchaEnabled);
            if (header != null)
            {
                client.DefaultRequestHeaders.Add(header, "test");
            }

            var response = await client.GetAsync(endpoint);

            Assert.Equal(expectedStatusCode, (int)response.StatusCode);
            return(response);
        }
Beispiel #2
0
 public TestWebApplicationFactory(IVerifyCaptcha verifyCaptcha, bool isReCaptchaEnabled)
 {
     this.verifyCaptcha      = verifyCaptcha ?? throw new System.ArgumentNullException(nameof(verifyCaptcha));
     this.isReCaptchaEnabled = isReCaptchaEnabled;
 }
Beispiel #3
0
 public ReCaptchaVerificationActionFilter(IVerifyCaptcha verifyCaptcha, bool isEnabled = true)
 {
     this.verifyCaptcha = verifyCaptcha;
     this.IsEnabled     = isEnabled;
 }
        private HttpClient GetHttpClient(IVerifyCaptcha verifyCaptcha, bool isReCaptchaEnabled)
        {
            var factory = new TestWebApplicationFactory(verifyCaptcha, isReCaptchaEnabled);

            return(factory.CreateDefaultClient());
        }