Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 049ee03

Browse files
authored
1 parent 6922cbb commit 049ee03

10 files changed

+386
-351
lines changed

MusicStore.sln

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

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26206.0
4+
VisualStudioVersion = 15.0.26228.10
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7D749BDA-4638-4517-B66A-D40DEDEEB141}"
77
ProjectSection(SolutionItems) = preProject

build/dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<AspNetCoreVersion>1.2.0-*</AspNetCoreVersion>
4-
<AspNetCoreLabsVersion>0.3.0-*</AspNetCoreLabsVersion>
4+
<AspNetIntegrationTestingVersion>0.4.0-*</AspNetIntegrationTestingVersion>
55
<AspNetCoreModuleVersion>1.0.0-*</AspNetCoreModuleVersion>
66
<DotNetPlatformAbstractionsVersion>1.1.0</DotNetPlatformAbstractionsVersion>
77
<CoreFxVersion>4.3.0</CoreFxVersion>

test/E2ETests/E2ETests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="$(AspNetCoreVersion)" />
2020
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetCoreVersion)" />
2121
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="$(AspNetCoreVersion)" />
22-
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreLabsVersion)" />
22+
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetIntegrationTestingVersion)" />
2323
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="$(AspNetCoreVersion)" />
2424
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(DotNetPlatformAbstractionsVersion)" />
2525
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
@@ -28,6 +28,7 @@
2828
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(AspNetCoreVersion)" />
2929
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
3030
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
31+
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(AspNetCoreVersion)" />
3132
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
3233
<PackageReference Include="System.Data.SqlClient" Version="$(CoreFxVersion)" />
3334
<PackageReference Include="System.Xml.XmlDocument" Version="$(CoreFxVersion)" />

test/E2ETests/Http.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
For schema documentation, see
77
%IIS_BIN%\config\schema\IIS_schema.xml.
8-
8+
99
Please make a backup of this file before making any changes to it.
1010
1111
NOTE: The following environment variables are available to be used
@@ -25,20 +25,20 @@
2525
The <configSections> section controls the registration of sections.
2626
Section is the basic unit of deployment, locking, searching and
2727
containment for configuration settings.
28-
28+
2929
Every section belongs to one section group.
3030
A section group is a container of logically-related sections.
31-
31+
3232
Sections cannot be nested.
3333
Section groups may be nested.
34-
34+
3535
<section
3636
name="" [Required, Collection Key] [XML name of the section]
3737
allowDefinition="Everywhere" [MachineOnly|MachineToApplication|AppHostOnly|Everywhere] [Level where it can be set]
3838
overrideModeDefault="Allow" [Allow|Deny] [Default delegation mode]
3939
allowLocation="true" [true|false] [Allowed in location tags]
4040
/>
41-
41+
4242
The recommended way to unlock sections is by using a location tag:
4343
<location path="Default Web Site" overrideMode="Allow">
4444
<system.webServer>

test/E2ETests/NtlmAuthentation.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
For schema documentation, see
77
%IIS_BIN%\config\schema\IIS_schema.xml.
8-
8+
99
Please make a backup of this file before making any changes to it.
1010
1111
NOTE: The following environment variables are available to be used
@@ -25,20 +25,20 @@
2525
The <configSections> section controls the registration of sections.
2626
Section is the basic unit of deployment, locking, searching and
2727
containment for configuration settings.
28-
28+
2929
Every section belongs to one section group.
3030
A section group is a container of logically-related sections.
31-
31+
3232
Sections cannot be nested.
3333
Section groups may be nested.
34-
34+
3535
<section
3636
name="" [Required, Collection Key] [XML name of the section]
3737
allowDefinition="Everywhere" [MachineOnly|MachineToApplication|AppHostOnly|Everywhere] [Level where it can be set]
3838
overrideModeDefault="Allow" [Allow|Deny] [Default delegation mode]
3939
allowLocation="true" [true|false] [Allowed in location tags]
4040
/>
41-
41+
4242
The recommended way to unlock sections is by using a location tag:
4343
<location path="Default Web Site" overrideMode="Allow">
4444
<system.webServer>
Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Net.Http;
@@ -13,88 +13,96 @@
1313

1414
namespace E2ETests
1515
{
16-
// Uses ports ranging 5050 - 5060.
1716
public class NtlmAuthenticationTests : IDisposable
1817
{
19-
private readonly XunitLogger _logger;
18+
private readonly ILoggerFactory _loggerFactory;
2019

2120
public NtlmAuthenticationTests(ITestOutputHelper output)
2221
{
23-
_logger = new XunitLogger(output, LogLevel.Information);
22+
_loggerFactory = new LoggerFactory()
23+
.AddXunit(output);
2424
}
2525

2626
[ConditionalTheory, Trait("E2Etests", "E2Etests")]
2727
[OSSkipCondition(OperatingSystems.Linux)]
2828
[OSSkipCondition(OperatingSystems.MacOSX)]
29-
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5050/")]
30-
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5051/")]
31-
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5052/")]
32-
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5053/")]
33-
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
29+
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
30+
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
31+
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
32+
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
33+
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
3434
{
35-
using (_logger.BeginScope("NtlmAuthenticationTest"))
35+
try
3636
{
37-
var musicStoreDbName = DbUtils.GetUniqueName();
38-
39-
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
37+
Console.WriteLine("NtlmAuthenticationTest");
38+
var logger = _loggerFactory.CreateLogger($"NtlmAuthentication:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}");
39+
using (logger.BeginScope("NtlmAuthenticationTest"))
4040
{
41-
PublishApplicationBeforeDeployment = true,
42-
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
43-
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
44-
Configuration = Helpers.GetCurrentBuildConfiguration(),
45-
ApplicationType = applicationType,
46-
ApplicationBaseUriHint = applicationBaseUrl,
47-
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
48-
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "NtlmAuthentation.config")) : null,
49-
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
50-
UserAdditionalCleanup = parameters =>
51-
{
52-
DbUtils.DropDatabase(musicStoreDbName, _logger);
53-
}
54-
};
41+
var musicStoreDbName = DbUtils.GetUniqueName();
5542

56-
if (applicationType == ApplicationType.Standalone)
57-
{
58-
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
59-
}
43+
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
44+
{
45+
PublishApplicationBeforeDeployment = true,
46+
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
47+
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
48+
Configuration = Helpers.GetCurrentBuildConfiguration(),
49+
ApplicationType = applicationType,
50+
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
51+
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "NtlmAuthentation.config")) : null,
52+
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
53+
UserAdditionalCleanup = parameters =>
54+
{
55+
DbUtils.DropDatabase(musicStoreDbName, logger);
56+
}
57+
};
6058

61-
// Override the connection strings using environment based configuration
62-
deploymentParameters.EnvironmentVariables
63-
.Add(new KeyValuePair<string, string>(
64-
MusicStoreConfig.ConnectionStringKey,
65-
DbUtils.CreateConnectionString(musicStoreDbName)));
59+
if (applicationType == ApplicationType.Standalone)
60+
{
61+
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
62+
}
6663

67-
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
68-
{
69-
var deploymentResult = deployer.Deploy();
70-
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
71-
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
64+
// Override the connection strings using environment based configuration
65+
deploymentParameters.EnvironmentVariables
66+
.Add(new KeyValuePair<string, string>(
67+
MusicStoreConfig.ConnectionStringKey,
68+
DbUtils.CreateConnectionString(musicStoreDbName)));
7269

73-
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
74-
var response = await RetryHelper.RetryRequest(async () =>
70+
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory))
7571
{
76-
return await httpClient.GetAsync(string.Empty);
77-
}, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);
72+
var deploymentResult = await deployer.DeployAsync();
73+
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
74+
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
75+
76+
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
77+
var response = await RetryHelper.RetryRequest(async () =>
78+
{
79+
return await httpClient.GetAsync(string.Empty);
80+
}, logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
7881

79-
Assert.False(response == null, "Response object is null because the client could not " +
80-
"connect to the server after multiple retries");
82+
Assert.False(response == null, "Response object is null because the client could not " +
83+
"connect to the server after multiple retries");
8184

82-
var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);
85+
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
8386

84-
Console.WriteLine("Verifying home page");
85-
await validator.VerifyNtlmHomePage(response);
87+
Console.WriteLine("Verifying home page");
88+
await validator.VerifyNtlmHomePage(response);
8689

87-
Console.WriteLine("Verifying access to store with permissions");
88-
await validator.AccessStoreWithPermissions();
90+
Console.WriteLine("Verifying access to store with permissions");
91+
await validator.AccessStoreWithPermissions();
8992

90-
_logger.LogInformation("Variation completed successfully.");
93+
logger.LogInformation("Variation completed successfully.");
94+
}
9195
}
9296
}
97+
finally
98+
{
99+
Console.WriteLine("Finished NtlmAuthenticationTest");
100+
}
93101
}
94102

95103
public void Dispose()
96104
{
97-
_logger.Dispose();
105+
_loggerFactory.Dispose();
98106
}
99107
}
100108
}

0 commit comments

Comments
 (0)