Skip to content

Commit a964749

Browse files
authored
usng new proxy nuget with backend url fixes (#2853)
using new proxy nuget with backend url fixes
1 parent 64fe2bb commit a964749

File tree

12 files changed

+107
-23
lines changed

12 files changed

+107
-23
lines changed

src/WebJobs.Script.NuGet/WebJobs.Script.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<dependency id="FSharp.Core" version="4.0.0.1" />
2020
<dependency id="Microsoft.Azure.WebJobs" version="2.3.0-beta1-11288" />
2121
<dependency id="Microsoft.ApplicationInsights.WindowsServer" version="2.4.1" />
22-
<dependency id="Microsoft.Azure.AppService.Proxy" version="1.0.0.1" />
22+
<dependency id="Microsoft.Azure.AppService.Proxy" version="1.0.0.3" />
2323
<dependency id="Microsoft.Azure.ServiceBus.EventProcessorHost" version="2.2.10" />
2424
<dependency id="Microsoft.Azure.WebJobs.Extensions.ApiHub" version="1.0.0-beta8" />
2525
<dependency id="Microsoft.Azure.WebJobs.Extensions.BotFramework" version="1.0.15-beta" />

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<HintPath>..\..\packages\Microsoft.ApplicationInsights.2.4.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
8080
</Reference>
8181
<Reference Include="Microsoft.AspNet.Razor, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
82-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
82+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
8383
</Reference>
8484
<Reference Include="Microsoft.AspNet.WebHooks.Common, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8585
<HintPath>..\..\packages\Microsoft.AspNet.WebHooks.Common.1.2.0\lib\net45\Microsoft.AspNet.WebHooks.Common.dll</HintPath>
@@ -157,13 +157,13 @@
157157
<HintPath>..\..\packages\Microsoft.Azure.ApiHub.Sdk.0.7.2-alpha\lib\net45\Microsoft.Azure.ApiHub.Sdk.dll</HintPath>
158158
</Reference>
159159
<Reference Include="Microsoft.Azure.AppService.Proxy.Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
160-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
160+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
161161
</Reference>
162162
<Reference Include="Microsoft.Azure.AppService.Proxy.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
163-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
163+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
164164
</Reference>
165165
<Reference Include="Microsoft.Azure.AppService.Proxy.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
166-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
166+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
167167
</Reference>
168168
<Reference Include="Microsoft.Azure.Documents.ChangeFeedProcessor, Version=1.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
169169
<HintPath>..\..\packages\Microsoft.Azure.DocumentDB.ChangeFeedProcessor.1.1.1\lib\net45\Microsoft.Azure.Documents.ChangeFeedProcessor.dll</HintPath>

src/WebJobs.Script.WebHost/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<package id="Microsoft.AspNetCore.Http.Features" version="1.0.2" targetFramework="net471" />
3939
<package id="Microsoft.AspNetCore.WebUtilities" version="1.0.0" targetFramework="net471" />
4040
<package id="Microsoft.Azure.ApiHub.Sdk" version="0.7.2-alpha" targetFramework="net471" />
41-
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.1" targetFramework="net471" />
41+
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.3" targetFramework="net471" />
4242
<package id="Microsoft.Azure.DocumentDB" version="1.13.2" targetFramework="net471" />
4343
<package id="Microsoft.Azure.DocumentDB.ChangeFeedProcessor" version="1.1.1" targetFramework="net471" />
4444
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net471" />

src/WebJobs.Script/WebJobs.Script.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@
8484
<HintPath>..\..\packages\Microsoft.ApplicationInsights.2.4.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
8585
</Reference>
8686
<Reference Include="Microsoft.AspNet.Razor, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
87-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
87+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
8888
</Reference>
8989
<Reference Include="Microsoft.Azure.ApiHub.Sdk, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
9090
<HintPath>..\..\packages\Microsoft.Azure.ApiHub.Sdk.0.7.2-alpha\lib\net45\Microsoft.Azure.ApiHub.Sdk.dll</HintPath>
9191
</Reference>
9292
<Reference Include="Microsoft.Azure.AppService.Proxy.Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
93-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
93+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
9494
</Reference>
9595
<Reference Include="Microsoft.Azure.AppService.Proxy.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
96-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
96+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
9797
</Reference>
9898
<Reference Include="Microsoft.Azure.AppService.Proxy.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
99-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
99+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
100100
</Reference>
101101
<Reference Include="Microsoft.Azure.Documents.ChangeFeedProcessor, Version=1.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
102102
<HintPath>..\..\packages\Microsoft.Azure.DocumentDB.ChangeFeedProcessor.1.1.1\lib\net45\Microsoft.Azure.Documents.ChangeFeedProcessor.dll</HintPath>

src/WebJobs.Script/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net471" />
1515
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net471" />
1616
<package id="Microsoft.Azure.ApiHub.Sdk" version="0.7.2-alpha" targetFramework="net471" />
17-
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.1" targetFramework="net471" />
17+
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.3" targetFramework="net471" />
1818
<package id="Microsoft.Azure.DocumentDB" version="1.13.2" targetFramework="net471" />
1919
<package id="Microsoft.Azure.DocumentDB.ChangeFeedProcessor" version="1.1.1" targetFramework="net471" />
2020
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net471" />

test/WebJobs.Script.Tests.Integration/ProxyEndToEndTests.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,50 @@ public async Task CatchAllApis()
123123
Assert.Equal("Pong", content);
124124
}
125125

126+
[Fact]
127+
public async Task TrailingSlashRemoved()
128+
{
129+
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"staticBackendUrlTest/blahblah/");
130+
req.Headers.Add("return_incoming_url", "1");
131+
HttpResponseMessage response = await _fixture.HttpClient.SendAsync(req);
132+
string content = await response.Content.ReadAsStringAsync();
133+
Assert.Equal("200", response.StatusCode.ToString("D"));
134+
Assert.Equal(@"http://localhost/api/myroute/mysubroute?a=1", content);
135+
}
136+
137+
[Fact]
138+
public async Task TrailingSlashRemoved2()
139+
{
140+
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"simpleParamBackendUrlTest/myroute/mysubroute/");
141+
req.Headers.Add("return_incoming_url", "1");
142+
HttpResponseMessage response = await _fixture.HttpClient.SendAsync(req);
143+
string content = await response.Content.ReadAsStringAsync();
144+
Assert.Equal("200", response.StatusCode.ToString("D"));
145+
Assert.Equal(@"http://localhost/api/myroute/mysubroute?a=1", content);
146+
}
147+
148+
[Fact]
149+
public async Task TrailingSlashKept()
150+
{
151+
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"wildcardBackendUrlTest/myroute/mysubroute/");
152+
req.Headers.Add("return_incoming_url", "1");
153+
HttpResponseMessage response = await _fixture.HttpClient.SendAsync(req);
154+
string content = await response.Content.ReadAsStringAsync();
155+
Assert.Equal("200", response.StatusCode.ToString("D"));
156+
Assert.Equal(@"http://localhost/api/myroute%2Fmysubroute/?a=1", content);
157+
}
158+
159+
[Fact]
160+
public async Task TrailingSlashKept2()
161+
{
162+
var req = new HttpRequestMessage(HttpMethod.Get, $"wildcardBackendUrlTest/myroute/mysubroute");
163+
req.Headers.Add("return_incoming_url", "1");
164+
var response = await _fixture.HttpClient.SendAsync(req);
165+
var content = await response.Content.ReadAsStringAsync();
166+
Assert.Equal("200", response.StatusCode.ToString("D"));
167+
Assert.Equal(@"http://localhost/api/myroute%2Fmysubroute?a=1", content);
168+
}
169+
126170
[Fact]
127171
public async Task CatchAllWithCustomRoutes()
128172
{
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
public static string Run(HttpRequestMessage req) => "Pong";
1+
public static string Run(HttpRequestMessage req)
2+
{
3+
if (req.Headers.Contains("return_incoming_url"))
4+
{
5+
return req.RequestUri.OriginalString;
6+
}
7+
else
8+
{
9+
return "Pong";
10+
}
11+
}

test/WebJobs.Script.Tests.Integration/TestScripts/Proxies/proxies.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,33 @@
111111
"route": "/api/{*path}"
112112
},
113113
"backendUri": "https://localhost/api/{path}"
114+
},
115+
"staticBackendUrlTest": {
116+
"matchCondition": {
117+
"route": "staticBackendUrlTest/{*path}"
118+
},
119+
"backendUri": "http://localhost/api/myroute/mysubroute?a=1",
120+
"requestOverrides": {
121+
"backend.request.headers.accept": "text/plain"
122+
}
123+
},
124+
"wildcardBackendUrlTest": {
125+
"matchCondition": {
126+
"route": "wildcardBackendUrlTest/{*path}"
127+
},
128+
"backendUri": "http://localhost/api/{path}?a=1",
129+
"requestOverrides": {
130+
"backend.request.headers.accept": "text/plain"
131+
}
132+
},
133+
"simpleParamBackendUrlTest": {
134+
"matchCondition": {
135+
"route": "simpleParamBackendUrlTest/myroute/{path}"
136+
},
137+
"backendUri": "http://localhost/api/myroute/{path}?a=1",
138+
"requestOverrides": {
139+
"backend.request.headers.accept": "text/plain"
140+
}
114141
}
115142
}
116143
}

test/WebJobs.Script.Tests.Integration/WebJobs.Script.Tests.Integration.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<HintPath>..\..\packages\Microsoft.ApplicationInsights.2.4.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Microsoft.AspNet.Razor, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
76-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
76+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.AspNet.Razor.dll</HintPath>
7777
</Reference>
7878
<Reference Include="Microsoft.AspNet.WebHooks.Common, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7979
<HintPath>..\..\packages\Microsoft.AspNet.WebHooks.Common.1.2.0\lib\net45\Microsoft.AspNet.WebHooks.Common.dll</HintPath>
@@ -106,13 +106,13 @@
106106
<HintPath>..\..\packages\Microsoft.Azure.ApiHub.Sdk.0.7.2-alpha\lib\net45\Microsoft.Azure.ApiHub.Sdk.dll</HintPath>
107107
</Reference>
108108
<Reference Include="Microsoft.Azure.AppService.Proxy.Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
109-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
109+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Client.dll</HintPath>
110110
</Reference>
111111
<Reference Include="Microsoft.Azure.AppService.Proxy.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
112-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
112+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Common.dll</HintPath>
113113
</Reference>
114114
<Reference Include="Microsoft.Azure.AppService.Proxy.Runtime, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
115-
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.1\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
115+
<HintPath>..\..\packages\Microsoft.Azure.AppService.Proxy.1.0.0.3\lib\net461\Microsoft.Azure.AppService.Proxy.Runtime.dll</HintPath>
116116
</Reference>
117117
<Reference Include="Microsoft.Azure.Documents.ChangeFeedProcessor, Version=1.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118118
<HintPath>..\..\packages\Microsoft.Azure.DocumentDB.ChangeFeedProcessor.1.1.1\lib\net45\Microsoft.Azure.Documents.ChangeFeedProcessor.dll</HintPath>
@@ -673,7 +673,9 @@
673673
<AdditionalFiles Include="..\..\stylecop.json">
674674
<Link>stylecop.json</Link>
675675
</AdditionalFiles>
676-
<None Include="packages.config" />
676+
<None Include="packages.config">
677+
<SubType>Designer</SubType>
678+
</None>
677679
<None Include="TestScripts\CSharp\CosmosDBTrigger\function.json">
678680
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
679681
</None>

test/WebJobs.Script.Tests.Integration/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<package id="Microsoft.AspNetCore.Http.Abstractions" version="1.0.2" targetFramework="net471" />
2323
<package id="Microsoft.AspNetCore.Http.Features" version="1.0.2" targetFramework="net471" />
2424
<package id="Microsoft.Azure.ApiHub.Sdk" version="0.7.2-alpha" targetFramework="net471" />
25-
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.1" targetFramework="net471" />
25+
<package id="Microsoft.Azure.AppService.Proxy" version="1.0.0.3" targetFramework="net471" />
2626
<package id="Microsoft.Azure.DocumentDB" version="1.13.2" targetFramework="net471" />
2727
<package id="Microsoft.Azure.DocumentDB.ChangeFeedProcessor" version="1.1.1" targetFramework="net471" />
2828
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net471" />

0 commit comments

Comments
 (0)