Skip to content

Commit ae0923b

Browse files
committed
Uri escape, file proxy tests
1 parent 3b33cd4 commit ae0923b

File tree

10 files changed

+53
-16
lines changed

10 files changed

+53
-16
lines changed

src/NetCoreStack.Proxy/Binders/ContentModelBinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected virtual EnsureTemplateResult EnsureTemplate(ContentModelBindingContext
2929
}
3030

3131
var value = bindingContext.ModelContentResolver.ResolveParameter(keyModelMetadata, bindingContext.Args[i], false);
32-
bindingContext.UriBuilder.Path += ($"/{WebUtility.UrlEncode(value)}");
32+
bindingContext.UriBuilder.Path += ($"/{Uri.EscapeUriString(value)}");
3333
parameterOffset++;
3434
}
3535
}

src/NetCoreStack.Proxy/NetCoreStack.Proxy.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.0" />
12-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" />
13-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.1" />
12+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
13+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
1414
<PackageReference Include="NetCoreStack.Contracts" Version="2.0.7" />
1515
<PackageReference Include="NetCoreStack.DispatchProxyAsync" Version="2.0.2" />
1616
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />

test/NetCoreStack.Proxy.Mvc.Hosting/NetCoreStack.Proxy.Mvc.Hosting.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" />
9-
<PackageReference Include="Swashbuckle.AspNetCore" Version="2.4.0" />
8+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
9+
<PackageReference Include="Swashbuckle.AspNetCore" Version="2.5.0" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

test/NetCoreStack.Proxy.Test.Contracts/IFileProxyApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace NetCoreStack.Proxy.Test.Contracts
55
{
6-
[ApiRoute("/", regionKey: "Main")]
6+
[ApiRoute("/", regionKey: "FS")]
77
public interface IFileProxyApi : IApiContract
88
{
99
[HttpGetMarker(Template = "proxy-fs/{id}/{filename}")]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using NetCoreStack.Contracts;
2+
using NetCoreStack.Mvc;
3+
using System.Threading.Tasks;
4+
5+
namespace NetCoreStack.Proxy.Test.Contracts
6+
{
7+
[ApiRoute("api/[controller]", "Integrations")]
8+
public interface ISmsApi : IApiContract
9+
{
10+
Task<ApiResult<SmsResult>> Send(string telephone, string content, bool isOtp = false, int? minutesTimeout = null);
11+
}
12+
13+
public class SmsResult
14+
{
15+
public bool Successfull { get; set; }
16+
public string MessageId { get; set; }
17+
}
18+
}

test/NetCoreStack.Proxy.Test.Contracts/NetCoreStack.Proxy.Test.Contracts.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
8+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
99
<PackageReference Include="NetCoreStack.Contracts" Version="2.0.7" />
10-
<PackageReference Include="NetCoreStack.Mvc" Version="2.1.4" />
10+
<PackageReference Include="NetCoreStack.Mvc" Version="2.1.5" />
1111
</ItemGroup>
1212

1313
</Project>

test/NetCoreStack.Proxy.Tests/NetCoreStack.Proxy.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0" />
12-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
13-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.1" />
12+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
13+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
15-
<PackageReference Include="Moq" Version="4.8.2" />
15+
<PackageReference Include="Moq" Version="4.8.3" />
1616
<PackageReference Include="xunit" Version="2.3.1" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1818
</ItemGroup>

test/NetCoreStack.Proxy.Tests/ProxyCreationTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ public async Task GetSingleFileWithKeyTemplate()
159159
Assert.True(true);
160160
}
161161

162+
[Fact]
163+
public async Task GetFileWithSpaceTest()
164+
{
165+
var guidelineApi = Resolver.GetService<IFileProxyApi>();
166+
byte[] bytes = await guidelineApi.GetFileAsync("5a6ee0791653ff2348f1cd32", Uri.EscapeUriString("Open Source.png"));
167+
Assert.True(true);
168+
}
169+
162170
[Fact]
163171
public async Task GetSingleFileWithKeyTemplateAndUtf8()
164172
{
@@ -370,5 +378,13 @@ await api.PutSubtitleAttachmentList(new SubtitleAttachmentDto {
370378
});
371379
Assert.True(true);
372380
}
381+
382+
[Fact]
383+
public async Task TaskSmsSendTests()
384+
{
385+
var api = Resolver.GetService<ISmsApi>();
386+
var result = await api.Send("000 111 22 33", "Proxy test content", true, 120);
387+
Assert.True(true);
388+
}
373389
}
374390
}

test/NetCoreStack.Proxy.Tests/TestHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static TestHelper()
8383
options.Register<IConsulApi>();
8484
options.Register<ISelfApi>();
8585
options.Register<IAttachmentApi>();
86+
options.Register<ISmsApi>();
8687

8788
options.CultureFactory = () =>
8889
{

test/NetCoreStack.Proxy.Tests/appsettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"ProxySettings": {
33
"RegionKeys": {
44
"Main": "http://localhost:5003/,http://localhost:5004/",
5-
"Consul": "http://localhost:8500/"
5+
"Consul": "http://localhost:8500/",
6+
"Integrations": "http://localhost:5003/",
7+
"FS": "http://localhost:8585/"
68
}
79
}
810
}

0 commit comments

Comments
 (0)