|
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
| 2 | +// Licensed under the MIT License. See License.txt in the project root for license information. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Globalization; |
| 7 | +using System.Net.Http; |
| 8 | +using System.Net.Http.Headers; |
| 9 | +using System.Text; |
| 10 | +using System.Threading.Tasks; |
| 11 | +using Microsoft.ApplicationInsights; |
| 12 | +using Microsoft.ApplicationInsights.DataContracts; |
| 13 | +using Microsoft.ServiceBus; |
| 14 | +using Microsoft.ServiceBus.Messaging; |
| 15 | +using Newtonsoft.Json.Linq; |
| 16 | +using Xunit; |
| 17 | + |
| 18 | +namespace WebJobs.Script.EndToEndTests |
| 19 | +{ |
| 20 | + [Collection(Constants.FunctionAppCollectionName)] |
| 21 | + public class ProxyEndToEndTests |
| 22 | + { |
| 23 | + private readonly FunctionAppFixture _fixture; |
| 24 | + |
| 25 | + public ProxyEndToEndTests(FunctionAppFixture fixture) |
| 26 | + { |
| 27 | + _fixture = fixture; |
| 28 | + } |
| 29 | + |
| 30 | + [Fact] |
| 31 | + [TestTrace] |
| 32 | + public async Task FileExtension() |
| 33 | + { |
| 34 | + using (var client = CreateClient()) |
| 35 | + { |
| 36 | + HttpResponseMessage response = await client.GetAsync($"test.txt"); |
| 37 | + |
| 38 | + string content = await response.Content.ReadAsStringAsync(); |
| 39 | + _fixture.Assert.Equals("200", response.StatusCode.ToString("D")); |
| 40 | + _fixture.Assert.Equals("test", content); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + [Fact] |
| 45 | + [TestTrace] |
| 46 | + public async Task RootCheck() |
| 47 | + { |
| 48 | + using (var client = CreateClient()) |
| 49 | + { |
| 50 | + HttpResponseMessage response = await client.GetAsync("/"); |
| 51 | + |
| 52 | + string content = await response.Content.ReadAsStringAsync(); |
| 53 | + _fixture.Assert.Equals("200", response.StatusCode.ToString("D")); |
| 54 | + _fixture.Assert.Equals("Root", content); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + [Fact] |
| 59 | + [TestTrace] |
| 60 | + public async Task LocalFunctionCall() |
| 61 | + { |
| 62 | + using (var client = CreateClient()) |
| 63 | + { |
| 64 | + HttpResponseMessage response = await client.GetAsync($"myhttptrigger?code={_fixture.FunctionDefaultKey}"); |
| 65 | + |
| 66 | + string content = await response.Content.ReadAsStringAsync(); |
| 67 | + _fixture.Assert.Equals("200", response.StatusCode.ToString("D")); |
| 68 | + _fixture.Assert.Equals("Pong", content); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + [Fact] |
| 73 | + [TestTrace] |
| 74 | + public async Task LongRoute() |
| 75 | + { |
| 76 | + var longRoute = "test123412341234123412341234123412341234123412341234123412341234123412341234123421341234123423141234123412341234123412341234123412341234123412341234123412341234123412341234123412341234213423141234123412341234123412341234123412341234123412341234123412341234123412341234123412341234"; |
| 77 | + using (var client = CreateClient()) |
| 78 | + { |
| 79 | + HttpResponseMessage response = await client.GetAsync(longRoute); |
| 80 | + |
| 81 | + string content = await response.Content.ReadAsStringAsync(); |
| 82 | + |
| 83 | + // This is to make sure the url is greater than the default asp.net 260 characters. |
| 84 | + _fixture.Assert.True(longRoute.Length > 260); |
| 85 | + _fixture.Assert.Equals("200", response.StatusCode.ToString("D")); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + public HttpClient CreateClient() |
| 90 | + { |
| 91 | + return new HttpClient |
| 92 | + { |
| 93 | + Timeout = TimeSpan.FromSeconds(60), |
| 94 | + BaseAddress = Settings.SiteBaseAddress |
| 95 | + }; |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments