Browse Source

Merge branch 'master' of https://github.com/dotnet/eShopOnContainers

pull/82/head
Javier Suárez Ruiz 8 years ago
parent
commit
9181946438
17 changed files with 81 additions and 236 deletions
  1. +0
    -28
      _docker/redis/Dockerfile.nanowin
  2. +0
    -18
      docker-compose-windows.dcproj
  3. +0
    -69
      docker-compose-windows.override.yml
  4. +0
    -71
      docker-compose-windows.yml
  5. +0
    -6
      src/Services/Basket/Basket.API/Dockerfile.nanowin
  6. +0
    -6
      src/Services/Catalog/Catalog.API/Dockerfile.nanowin
  7. +0
    -6
      src/Services/Identity/Identity.API/Dockerfile.nanowin
  8. +0
    -6
      src/Services/Ordering/Ordering.API/Dockerfile.nanowin
  9. +12
    -9
      src/Services/Ordering/Ordering.API/Startup.cs
  10. +0
    -6
      src/Web/WebMVC/Dockerfile.nanowin
  11. +0
    -6
      src/Web/WebSPA/Dockerfile.nanowin
  12. +6
    -0
      test/Services/FunctionalTests/FunctionalTests.csproj
  13. +26
    -0
      test/Services/FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs
  14. +2
    -2
      test/Services/FunctionalTests/Services/Ordering/OrderingScenarioBase.cs
  15. +29
    -0
      test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs
  16. +3
    -1
      test/Services/FunctionalTests/settings.json
  17. +3
    -2
      test/Services/UnitTest/Account/AccountControllerTest.cs

+ 0
- 28
_docker/redis/Dockerfile.nanowin View File

@ -1,28 +0,0 @@
# The MSI installs a service which is hard to override, so let's use a zip file.
FROM microsoft/windowsservercore
MAINTAINER alexellis2@gmail.com
SHELL ["powershell"]
RUN $ErrorActionPreference = 'Stop'; \
wget https://github.com/MSOpenTech/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip -OutFile Redis-x64-3.2.100.zip ; \
Expand-Archive Redis-x64-3.2.100.zip -dest 'C:\\Program Files\\Redis\\' ; \
Remove-Item Redis-x64-3.2.100.zip -Force
RUN setx PATH '%PATH%;C:\\Program Files\\Redis\\'
WORKDIR 'C:\\Program Files\\Redis\\'
RUN Get-Content redis.windows.conf | Where { $_ -notmatch 'bind 127.0.0.1' } | Set-Content redis.openport.conf ; \
Get-Content redis.openport.conf | Where { $_ -notmatch 'protected-mode yes' } | Set-Content redis.unprotected.conf ; \
Add-Content redis.unprotected.conf 'protected-mode no' ; \
Add-Content redis.unprotected.conf 'bind 0.0.0.0' ; \
Get-Content redis.unprotected.conf
EXPOSE 6379
# Define our command to be run when launching the container
CMD .\\redis-server.exe .\\redis.unprotected.conf --port 6379 ; \
Write-Host Redis Started... ; \
while ($true) { Start-Sleep -Seconds 3600 }

+ 0
- 18
docker-compose-windows.dcproj View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>2ede831a-98f5-4f23-b2db-7e9dc935766a</ProjectGuid>
<DockerLaunchBrowser>True</DockerLaunchBrowser>
<DockerServiceUrl>http://localhost:5100</DockerServiceUrl>
<DockerServiceName>webmvc</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose-windows.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose-windows.vs.debug.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose-windows.yml" />
</ItemGroup>
</Project>

+ 0
- 69
docker-compose-windows.override.yml View File

@ -1,69 +0,0 @@
version: '2.1'
services:
basket.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionString=basket.data
#- identityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105.
- identityUrl=http://identity.api:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
ports:
- "5103:5103"
catalog.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word
#- ExternalCatalogBaseUrl=http://13.88.8.119:5101 #Remote: VM Needs to have public access at 5105.
- ExternalCatalogBaseUrl=http://localhost:5101 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
ports:
- "5101:5101"
identity.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- SpaClient=http://localhost:5104
- ConnectionStrings__DefaultConnection=Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word
#- MvcClient=http://13.88.8.119:5100 #Remote: VM Needs to have public access at 5105.
- MvcClient=http://localhost:5100 #Local: You need to open your local dev-machine firewall at range 5100-5105.
ports:
- "5105:5105"
ordering.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
#- identityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105.
- identityUrl=http://identity.api:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
ports:
- "5102:5102"
webspa:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- CatalogUrl=http://localhost:5101
- OrderingUrl=http://localhost:5102
#- IdentityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105.
- IdentityUrl=http://localhost:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
- BasketUrl=http://localhost:5103
ports:
- "5104:5104"
webmvc:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- CatalogUrl=http://catalog.api:5101
- OrderingUrl=http://ordering.api:5102
#- IdentityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105.
- IdentityUrl=http://10.0.75.1:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
- BasketUrl=http://basket.api:5103
ports:
- "5100:5100"
sql.data:
environment:
- SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
ports:
- "5433:1433"

+ 0
- 71
docker-compose-windows.yml View File

@ -1,71 +0,0 @@
version: '2.1'
services:
basket.api:
image: eshop/basket.api
build:
context: ./src/Services/Basket/Basket.API
dockerfile: Dockerfile.nanowin
depends_on:
- basket.data
- identity.api
catalog.api:
image: eshop/catalog.api
build:
context: ./src/Services/Catalog/Catalog.API
dockerfile: Dockerfile.nanowin
depends_on:
- sql.data
identity.api:
image: eshop/identity.api
build:
context: ./src/Services/Identity/Identity.API
dockerfile: Dockerfile.nanowin
depends_on:
- sql.data
ordering.api:
image: eshop/ordering.api
build:
context: ./src/Services/Ordering/Ordering.API
dockerfile: Dockerfile.nanowin
depends_on:
- sql.data
webspa:
image: eshop/webspa
build:
context: ./src/Web/WebSPA
dockerfile: Dockerfile.nanowin
depends_on:
- identity.api
- basket.api
webmvc:
image: eshop/webmvc
build:
context: ./src/Web/WebMVC
dockerfile: Dockerfile.nanowin
depends_on:
- catalog.api
- ordering.api
- identity.api
- basket.api
sql.data:
image: microsoft/mssql-server-windows
basket.data:
image: eshop/redis
build:
context: ./_docker/redis
dockerfile: Dockerfile.nanowin
ports:
- "6379:6379"
networks:
default:
external:
name: nat

+ 0
- 6
src/Services/Basket/Basket.API/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Basket.API.dll"]

+ 0
- 6
src/Services/Catalog/Catalog.API/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Catalog.API.dll"]

+ 0
- 6
src/Services/Identity/Identity.API/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Identity.API.dll"]

+ 0
- 6
src/Services/Ordering/Ordering.API/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Ordering.API.dll"]

+ 12
- 9
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -109,15 +109,7 @@
app.UseCors("CorsPolicy");
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = identityUrl.ToString(),
ScopeName = "orders",
RequireHttpsMetadata = false
});
ConfigureAuth(app);
app.UseMvcWithDefaultRoute();
@ -126,5 +118,16 @@
OrderingContextSeed.SeedAsync(app).Wait();
}
protected virtual void ConfigureAuth(IApplicationBuilder app)
{
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = identityUrl.ToString(),
ScopeName = "orders",
RequireHttpsMetadata = false
});
}
}
}

+ 0
- 6
src/Web/WebMVC/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "WebMVC.dll"]

+ 0
- 6
src/Web/WebSPA/Dockerfile.nanowin View File

@ -1,6 +0,0 @@
FROM microsoft/dotnet:1.1-runtime-nanoserver
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "WebSPA.dll"]

+ 6
- 0
test/Services/FunctionalTests/FunctionalTests.csproj View File

@ -32,4 +32,10 @@
<PackageReference Include="xunit" Version="2.2.0-beta5-build3474" />
</ItemGroup>
<ItemGroup>
<Content Update="settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

+ 26
- 0
test/Services/FunctionalTests/Middleware/AutoAuthorizeMiddleware.cs View File

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
namespace FunctionalTests.Middleware
{
class AutoAuthorizeMiddleware
{
private readonly RequestDelegate _next;
public AutoAuthorizeMiddleware(RequestDelegate rd)
{
_next = rd;
}
public async Task Invoke(HttpContext httpContext)
{
var identity = new ClaimsIdentity();
identity.AddClaim(new Claim("sub", "1234"));
httpContext.User.AddIdentity(identity);
await _next.Invoke(httpContext);
}
}
}

+ 2
- 2
test/Services/FunctionalTests/Services/Ordering/OrderingScenarioBase.cs View File

@ -9,9 +9,9 @@
{
public TestServer CreateServer()
{
var webHostBuilder = new WebHostBuilder();
var webHostBuilder = new WebHostBuilder();
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory());
webHostBuilder.UseStartup<Startup>();
webHostBuilder.UseStartup<OrderingTestsStartup>();
return new TestServer(webHostBuilder);
}


+ 29
- 0
test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs View File

@ -0,0 +1,29 @@
using Microsoft.eShopOnContainers.Services.Ordering.API;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using FunctionalTests.Middleware;
namespace FunctionalTests.Services.Ordering
{
public class OrderingTestsStartup : Startup
{
public OrderingTestsStartup(IHostingEnvironment env) : base(env)
{
}
protected override void ConfigureAuth(IApplicationBuilder app)
{
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
{
app.UseMiddleware<AutoAuthorizeMiddleware>();
}
else
{
base.ConfigureAuth(app);
}
}
}
}

+ 3
- 1
test/Services/FunctionalTests/settings.json View File

@ -1,3 +1,5 @@
{
"ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;"
"ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;",
"IdentityUrl": "http://localhost:5105",
"isTest": "true"
}

+ 3
- 2
test/Services/UnitTest/Account/AccountControllerTest.cs View File

@ -39,8 +39,9 @@ namespace UnitTest.Account
var actionResult = accountController.SignIn("");
//Assert
var redirectResult = Assert.IsType<RedirectResult>(actionResult);
Assert.Equal(redirectResult.Url, "/");
var redirectResult = Assert.IsType<RedirectToActionResult>(actionResult);
Assert.Equal(redirectResult.ActionName, "Index");
Assert.Equal(redirectResult.ControllerName, "Catalog");
Assert.Equal(accountController.ViewData["access_token"], "fakeToken");
}


Loading…
Cancel
Save