Exemple #1
0
        public async Task HttpTriggerTestsWithCustomMediaType(string functionName, string body, string mediaType, HttpStatusCode expectedStatusCode)
        {
            HttpResponseMessage response = await HttpHelpers.InvokeHttpTriggerWithBody(functionName, body, expectedStatusCode, mediaType);

            JObject responseBody = JObject.Parse(await response.Content.ReadAsStringAsync());

            Assert.Equal(expectedStatusCode, response.StatusCode);
            VerifyBodyAndRawBody(responseBody, body, mediaType);
        }
Exemple #2
0
        public async Task HttpTriggerWithCookieTests()
        {
            HttpResponseMessage response = await HttpHelpers.InvokeHttpTrigger("HttpTriggerSetsCookie");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            List <string> cookies = response.Headers.SingleOrDefault(header => header.Key == "Set-Cookie").Value.ToList();

            Assert.Equal(5, cookies.Count);
            Assert.Equal("mycookie=myvalue; max-age=200000; path=/", cookies[0]);
            Assert.Equal("mycookie2=myvalue; max-age=200000; path=/", cookies[1]);
            Assert.Equal("mycookie3-expires=myvalue3-expires; max-age=0; path=/", cookies[2]);
            Assert.Equal("mycookie4-samesite-lax=myvalue; path=/; samesite=lax", cookies[3]);
            Assert.Equal("mycookie5-samesite-strict=myvalue; path=/; samesite=strict", cookies[4]);
            // Assert.Equal("mycookie4-samesite-none=myvalue; path=/; samesite=none", cookies[5]);
        }
Exemple #3
0
        public async Task HttpTriggerTests(string functionName, string queryString, HttpStatusCode expectedStatusCode, string expectedMessage)
        {
            // TODO: Verify exception on 500 after https://github.com/Azure/azure-functions-host/issues/3589
            HttpResponseMessage response = await HttpHelpers.InvokeHttpTrigger(functionName, queryString);

            string actualMessage = await response.Content.ReadAsStringAsync();

            Assert.Equal(expectedStatusCode, response.StatusCode);

            if (!string.IsNullOrEmpty(expectedMessage))
            {
                Assert.False(string.IsNullOrEmpty(actualMessage));
                Assert.True(actualMessage.Contains(expectedMessage));
            }
        }