parent
b0c989ce90
commit
39fc5ebdc4
|
|
@ -1,16 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Authentication;
|
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using Microsoft.AspNet.Authorization;
|
|
||||||
|
|
||||||
namespace MusicStore
|
namespace MusicStore
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Authentication;
|
|
||||||
using Microsoft.AspNet.Server.WebListener;
|
using Microsoft.AspNet.Server.WebListener;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using Microsoft.Net.Http.Server;
|
using Microsoft.Net.Http.Server;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using Microsoft.AspNet.Authorization;
|
|
||||||
|
|
||||||
namespace MusicStore
|
namespace MusicStore
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Authentication;
|
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using Microsoft.AspNet.Authorization;
|
|
||||||
|
|
||||||
namespace MusicStore
|
namespace MusicStore
|
||||||
{
|
{
|
||||||
|
|
@ -64,6 +62,12 @@ namespace MusicStore
|
||||||
.AddEntityFrameworkStores<MusicStoreContext>()
|
.AddEntityFrameworkStores<MusicStoreContext>()
|
||||||
.AddDefaultTokenProviders();
|
.AddDefaultTokenProviders();
|
||||||
|
|
||||||
|
services.ConfigureOpenIdConnectAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
|
||||||
|
options.ClientId = "[ClientId]";
|
||||||
|
});
|
||||||
|
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
|
|
||||||
|
|
@ -114,12 +118,7 @@ namespace MusicStore
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
|
|
||||||
// Create an Azure Active directory application and copy paste the following
|
// Create an Azure Active directory application and copy paste the following
|
||||||
// https://github.com/aspnet/Security/issues/113
|
app.UseOpenIdConnectAuthentication();
|
||||||
app.UseOpenIdConnectAuthentication(options =>
|
|
||||||
{
|
|
||||||
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
|
|
||||||
options.ClientId = "[ClientId]";
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add MVC to the request pipeline
|
// Add MVC to the request pipeline
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
|
|
|
||||||
|
|
@ -302,9 +302,9 @@ namespace E2ETests
|
||||||
|
|
||||||
private static string SwitchPathToRuntimeFlavor(RuntimeFlavor runtimeFlavor, RuntimeArchitecture runtimeArchitecture, ILogger logger)
|
private static string SwitchPathToRuntimeFlavor(RuntimeFlavor runtimeFlavor, RuntimeArchitecture runtimeArchitecture, ILogger logger)
|
||||||
{
|
{
|
||||||
var currentRuntime = Environment.GetCommandLineArgs().First();
|
var runtimePath = Environment.GetCommandLineArgs().First();
|
||||||
logger.LogInformation(string.Empty);
|
logger.LogInformation(string.Empty);
|
||||||
logger.LogInformation("Current runtime is : {0}", currentRuntime);
|
logger.LogInformation("Current runtime path is : {0}", runtimePath);
|
||||||
|
|
||||||
var replaceStr = new StringBuilder().
|
var replaceStr = new StringBuilder().
|
||||||
Append("dnx").
|
Append("dnx").
|
||||||
|
|
@ -313,13 +313,21 @@ namespace E2ETests
|
||||||
Append((runtimeArchitecture == RuntimeArchitecture.x86) ? "-x86" : "-x64").
|
Append((runtimeArchitecture == RuntimeArchitecture.x86) ? "-x86" : "-x64").
|
||||||
ToString();
|
ToString();
|
||||||
|
|
||||||
currentRuntime = Regex.Replace(currentRuntime, "dnx-(clr|coreclr)-win-(x86|x64)", replaceStr, RegexOptions.IgnoreCase);
|
runtimePath = Regex.Replace(runtimePath, "dnx-(clr|coreclr)-win-(x86|x64)", replaceStr, RegexOptions.IgnoreCase);
|
||||||
currentRuntime = Path.GetDirectoryName(currentRuntime);
|
runtimePath = Path.GetDirectoryName(runtimePath);
|
||||||
|
|
||||||
// Tweak the %PATH% to the point to the right RUNTIMEFLAVOR.
|
// Tweak the %PATH% to the point to the right RUNTIMEFLAVOR.
|
||||||
Environment.SetEnvironmentVariable("PATH", currentRuntime + ";" + Environment.GetEnvironmentVariable("PATH"));
|
Environment.SetEnvironmentVariable("PATH", runtimePath + ";" + Environment.GetEnvironmentVariable("PATH"));
|
||||||
|
|
||||||
var runtimeName = new DirectoryInfo(currentRuntime).Parent.Name;
|
var runtimeDirectoryInfo = new DirectoryInfo(runtimePath);
|
||||||
|
if (!runtimeDirectoryInfo.Exists)
|
||||||
|
{
|
||||||
|
throw new Exception(
|
||||||
|
string.Format("Requested runtime at location '{0}' does not exist. Please make sure it is installed before running test.",
|
||||||
|
runtimeDirectoryInfo.FullName));
|
||||||
|
}
|
||||||
|
|
||||||
|
var runtimeName = runtimeDirectoryInfo.Parent.Name;
|
||||||
logger.LogInformation(string.Empty);
|
logger.LogInformation(string.Empty);
|
||||||
logger.LogInformation("Changing to use runtime : {runtimeName}", runtimeName);
|
logger.LogInformation("Changing to use runtime : {runtimeName}", runtimeName);
|
||||||
return runtimeName;
|
return runtimeName;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace E2ETests
|
||||||
SiteName = "MusicStoreNtlmAuthentication" //This is configured in the NtlmAuthentication.config
|
SiteName = "MusicStoreNtlmAuthentication" //This is configured in the NtlmAuthentication.config
|
||||||
};
|
};
|
||||||
|
|
||||||
var testStartTime = DateTime.Now;
|
var stopwatch = Stopwatch.StartNew();
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
@ -53,19 +53,15 @@ namespace E2ETests
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
var initializationCompleteTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
Helpers.Retry(() =>
|
Helpers.Retry(() =>
|
||||||
{
|
{
|
||||||
response = _httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
}, logger: _logger);
|
}, logger: _logger);
|
||||||
|
|
||||||
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds",
|
|
||||||
(initializationCompleteTime - testStartTime).TotalSeconds);
|
|
||||||
|
|
||||||
VerifyHomePage(response, responseContent, true);
|
VerifyHomePage(response, responseContent, true);
|
||||||
|
|
||||||
//Check if the user name appears in the page
|
//Check if the user name appears in the page
|
||||||
|
|
@ -76,9 +72,8 @@ namespace E2ETests
|
||||||
//Should be able to access the store as the Startup adds necessary permissions for the current user
|
//Should be able to access the store as the Startup adds necessary permissions for the current user
|
||||||
AccessStoreWithPermissions();
|
AccessStoreWithPermissions();
|
||||||
|
|
||||||
var testCompletionTime = DateTime.Now;
|
stopwatch.Stop();
|
||||||
_logger.LogInformation("[Time]: All tests completed in '{t}' seconds", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", (testCompletionTime - testStartTime).TotalSeconds);
|
|
||||||
testSuccessful = true;
|
testSuccessful = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace E2ETests
|
||||||
EnvironmentName = "OpenIdConnectTesting"
|
EnvironmentName = "OpenIdConnectTesting"
|
||||||
};
|
};
|
||||||
|
|
||||||
var testStartTime = DateTime.Now;
|
var stopwatch = Stopwatch.StartNew();
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
@ -68,27 +68,22 @@ namespace E2ETests
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
var initializationCompleteTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
Helpers.Retry(() =>
|
Helpers.Retry(() =>
|
||||||
{
|
{
|
||||||
response = _httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
}, logger: _logger);
|
}, logger: _logger);
|
||||||
|
|
||||||
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds",
|
|
||||||
(initializationCompleteTime - testStartTime).TotalSeconds);
|
|
||||||
|
|
||||||
VerifyHomePage(response, responseContent);
|
VerifyHomePage(response, responseContent);
|
||||||
|
|
||||||
// OpenIdConnect login.
|
// OpenIdConnect login.
|
||||||
LoginWithOpenIdConnect();
|
LoginWithOpenIdConnect();
|
||||||
|
|
||||||
var testCompletionTime = DateTime.Now;
|
stopwatch.Stop();
|
||||||
_logger.LogInformation("[Time]: All tests completed in '{t}' seconds", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", (testCompletionTime - testStartTime).TotalSeconds);
|
|
||||||
testSuccessful = true;
|
testSuccessful = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -103,4 +98,4 @@ namespace E2ETests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ namespace E2ETests
|
||||||
BundleApplicationBeforeStart = true
|
BundleApplicationBeforeStart = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var testStartTime = DateTime.Now;
|
var stopwatch = Stopwatch.StartNew();
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
@ -72,7 +72,6 @@ namespace E2ETests
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
var initializationCompleteTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
//Add retry logic since tests are flaky on mono due to connection issues
|
//Add retry logic since tests are flaky on mono due to connection issues
|
||||||
|
|
@ -80,12 +79,9 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
response = _httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
}, logger: _logger);
|
}, logger: _logger);
|
||||||
|
|
||||||
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds",
|
|
||||||
(initializationCompleteTime - testStartTime).TotalSeconds);
|
|
||||||
|
|
||||||
VerifyHomePage(response, responseContent, true);
|
VerifyHomePage(response, responseContent, true);
|
||||||
|
|
||||||
//Static files are served?
|
//Static files are served?
|
||||||
|
|
@ -99,9 +95,8 @@ namespace E2ETests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCompletionTime = DateTime.Now;
|
stopwatch.Stop();
|
||||||
_logger.LogInformation("[Time]: All tests completed in '{t}' seconds.", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds.", stopwatch.Elapsed.TotalSeconds);
|
||||||
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds.", (testCompletionTime - testStartTime).TotalSeconds);
|
|
||||||
testSuccessful = true;
|
testSuccessful = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.Diagnostics;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNet.Testing.xunit;
|
using Microsoft.AspNet.Testing.xunit;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace E2ETests
|
namespace E2ETests
|
||||||
|
|
@ -105,7 +104,7 @@ namespace E2ETests
|
||||||
EnvironmentName = "SocialTesting"
|
EnvironmentName = "SocialTesting"
|
||||||
};
|
};
|
||||||
|
|
||||||
var testStartTime = DateTime.Now;
|
var stopwatch = Stopwatch.StartNew();
|
||||||
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
|
||||||
|
|
||||||
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
_logger.LogInformation("Pointing MusicStore DB to '{connString}'", string.Format(CONNECTION_STRING_FORMAT, musicStoreDbName));
|
||||||
|
|
@ -132,19 +131,15 @@ namespace E2ETests
|
||||||
|
|
||||||
HttpResponseMessage response = null;
|
HttpResponseMessage response = null;
|
||||||
string responseContent = null;
|
string responseContent = null;
|
||||||
var initializationCompleteTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
//Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
Helpers.Retry(() =>
|
Helpers.Retry(() =>
|
||||||
{
|
{
|
||||||
response = _httpClient.GetAsync(string.Empty).Result;
|
response = _httpClient.GetAsync(string.Empty).Result;
|
||||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||||
initializationCompleteTime = DateTime.Now;
|
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
}, logger: _logger);
|
}, logger: _logger);
|
||||||
|
|
||||||
_logger.LogInformation("[Time]: Approximate time taken for application initialization : '{t}' seconds",
|
|
||||||
(initializationCompleteTime - testStartTime).TotalSeconds);
|
|
||||||
|
|
||||||
VerifyHomePage(response, responseContent);
|
VerifyHomePage(response, responseContent);
|
||||||
|
|
||||||
//Verify the static file middleware can serve static content
|
//Verify the static file middleware can serve static content
|
||||||
|
|
@ -228,9 +223,8 @@ namespace E2ETests
|
||||||
//MicrosoftAccountLogin
|
//MicrosoftAccountLogin
|
||||||
LoginWithMicrosoftAccount();
|
LoginWithMicrosoftAccount();
|
||||||
|
|
||||||
var testCompletionTime = DateTime.Now;
|
stopwatch.Stop();
|
||||||
_logger.LogInformation("[Time]: All tests completed in '{t}' seconds", (testCompletionTime - initializationCompleteTime).TotalSeconds);
|
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", stopwatch.Elapsed.TotalSeconds);
|
||||||
_logger.LogInformation("[Time]: Total time taken for this test variation '{t}' seconds", (testCompletionTime - testStartTime).TotalSeconds);
|
|
||||||
testSuccessful = true;
|
testSuccessful = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -245,4 +239,4 @@ namespace E2ETests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using Microsoft.AspNet.Http.Authentication;
|
using Microsoft.AspNet.Authentication;
|
||||||
using Microsoft.AspNet.Authentication;
|
using Microsoft.AspNet.Http.Authentication;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.Common
|
namespace MusicStore.Mocks.Common
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Identity;
|
|
||||||
using Microsoft.AspNet.Authentication.Facebook;
|
using Microsoft.AspNet.Authentication.Facebook;
|
||||||
using Microsoft.AspNet.Authentication.OAuth;
|
using Microsoft.AspNet.Authentication.OAuth;
|
||||||
|
using Microsoft.AspNet.Identity;
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.Facebook
|
namespace MusicStore.Mocks.Facebook
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Identity;
|
|
||||||
using Microsoft.AspNet.Authentication.Google;
|
using Microsoft.AspNet.Authentication.Google;
|
||||||
using Microsoft.AspNet.Authentication.OAuth;
|
using Microsoft.AspNet.Authentication.OAuth;
|
||||||
|
using Microsoft.AspNet.Identity;
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.Google
|
namespace MusicStore.Mocks.Google
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Identity;
|
|
||||||
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
||||||
using Microsoft.AspNet.Authentication.OAuth;
|
using Microsoft.AspNet.Authentication.OAuth;
|
||||||
|
using Microsoft.AspNet.Identity;
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.MicrosoftAccount
|
namespace MusicStore.Mocks.MicrosoftAccount
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
using MusicStore.Mocks.OpenIdConnect;
|
using MusicStore.Mocks.OpenIdConnect;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
|
|
@ -53,6 +52,28 @@ namespace MusicStore
|
||||||
.AddEntityFrameworkStores<MusicStoreContext>()
|
.AddEntityFrameworkStores<MusicStoreContext>()
|
||||||
.AddDefaultTokenProviders();
|
.AddDefaultTokenProviders();
|
||||||
|
|
||||||
|
services.ConfigureOpenIdConnectAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
|
||||||
|
options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef";
|
||||||
|
options.BackchannelHttpHandler = new OpenIdConnectBackChannelHttpHandler();
|
||||||
|
options.StringDataFormat = new CustomStringDataFormat();
|
||||||
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
|
options.TokenValidationParameters.ValidateLifetime = false;
|
||||||
|
options.ProtocolValidator.RequireNonce = true;
|
||||||
|
options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500);
|
||||||
|
options.UseTokenLifetime = false;
|
||||||
|
|
||||||
|
options.Notifications = new OpenIdConnectAuthenticationNotifications
|
||||||
|
{
|
||||||
|
MessageReceived = OpenIdConnectNotifications.MessageReceived,
|
||||||
|
AuthorizationCodeReceived = OpenIdConnectNotifications.AuthorizationCodeReceived,
|
||||||
|
RedirectToIdentityProvider = OpenIdConnectNotifications.RedirectToIdentityProvider,
|
||||||
|
SecurityTokenReceived = OpenIdConnectNotifications.SecurityTokenReceived,
|
||||||
|
SecurityTokenValidated = OpenIdConnectNotifications.SecurityTokenValidated
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
|
|
||||||
|
|
@ -103,28 +124,7 @@ namespace MusicStore
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
|
|
||||||
// Create an Azure Active directory application and copy paste the following
|
// Create an Azure Active directory application and copy paste the following
|
||||||
// https://github.com/aspnet/Security/issues/113
|
app.UseOpenIdConnectAuthentication();
|
||||||
app.UseOpenIdConnectAuthentication(options =>
|
|
||||||
{
|
|
||||||
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
|
|
||||||
options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef";
|
|
||||||
options.BackchannelHttpHandler = new OpenIdConnectBackChannelHttpHandler();
|
|
||||||
options.StringDataFormat = new CustomStringDataFormat();
|
|
||||||
options.StateDataFormat = new CustomStateDataFormat();
|
|
||||||
options.TokenValidationParameters.ValidateLifetime = false;
|
|
||||||
options.ProtocolValidator.RequireNonce = true;
|
|
||||||
options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500);
|
|
||||||
options.UseTokenLifetime = false;
|
|
||||||
|
|
||||||
options.Notifications = new OpenIdConnectAuthenticationNotifications
|
|
||||||
{
|
|
||||||
MessageReceived = OpenIdConnectNotifications.MessageReceived,
|
|
||||||
AuthorizationCodeReceived = OpenIdConnectNotifications.AuthorizationCodeReceived,
|
|
||||||
RedirectToIdentityProvider = OpenIdConnectNotifications.RedirectToIdentityProvider,
|
|
||||||
SecurityTokenReceived = OpenIdConnectNotifications.SecurityTokenReceived,
|
|
||||||
SecurityTokenValidated = OpenIdConnectNotifications.SecurityTokenValidated
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add MVC to the request pipeline
|
// Add MVC to the request pipeline
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNet.Authentication.Facebook;
|
using Microsoft.AspNet.Authentication.Facebook;
|
||||||
using Microsoft.AspNet.Authentication.Google;
|
using Microsoft.AspNet.Authentication.Google;
|
||||||
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
using Microsoft.AspNet.Authentication.MicrosoftAccount;
|
||||||
|
|
@ -9,13 +8,11 @@ using Microsoft.AspNet.Authorization;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.Logging.Console;
|
|
||||||
using Microsoft.Framework.Runtime;
|
using Microsoft.Framework.Runtime;
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
using MusicStore.Mocks.Facebook;
|
using MusicStore.Mocks.Facebook;
|
||||||
|
|
@ -89,6 +86,55 @@ namespace MusicStore
|
||||||
options.Scope.Add("user_checkins");
|
options.Scope.Add("user_checkins");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.ConfigureGoogleAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.ClientId = "[ClientId]";
|
||||||
|
options.ClientSecret = "[ClientSecret]";
|
||||||
|
options.AccessType = "offline";
|
||||||
|
options.Notifications = new GoogleAuthenticationNotifications()
|
||||||
|
{
|
||||||
|
OnAuthenticated = GoogleNotifications.OnAuthenticated,
|
||||||
|
OnReturnEndpoint = GoogleNotifications.OnReturnEndpoint,
|
||||||
|
OnApplyRedirect = GoogleNotifications.OnApplyRedirect
|
||||||
|
};
|
||||||
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
|
options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler();
|
||||||
|
});
|
||||||
|
|
||||||
|
services.ConfigureTwitterAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.ConsumerKey = "[ConsumerKey]";
|
||||||
|
options.ConsumerSecret = "[ConsumerSecret]";
|
||||||
|
options.Notifications = new TwitterAuthenticationNotifications()
|
||||||
|
{
|
||||||
|
OnAuthenticated = TwitterNotifications.OnAuthenticated,
|
||||||
|
OnReturnEndpoint = TwitterNotifications.OnReturnEndpoint,
|
||||||
|
OnApplyRedirect = TwitterNotifications.OnApplyRedirect
|
||||||
|
};
|
||||||
|
options.StateDataFormat = new CustomTwitterStateDataFormat();
|
||||||
|
options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler();
|
||||||
|
#if DNX451
|
||||||
|
options.BackchannelCertificateValidator = null;
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
|
services.ConfigureMicrosoftAccountAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.Caption = "MicrosoftAccount - Requires project changes";
|
||||||
|
options.ClientId = "[ClientId]";
|
||||||
|
options.ClientSecret = "[ClientSecret]";
|
||||||
|
options.Notifications = new MicrosoftAccountAuthenticationNotifications()
|
||||||
|
{
|
||||||
|
OnAuthenticated = MicrosoftAccountNotifications.OnAuthenticated,
|
||||||
|
OnReturnEndpoint = MicrosoftAccountNotifications.OnReturnEndpoint,
|
||||||
|
OnApplyRedirect = MicrosoftAccountNotifications.OnApplyRedirect
|
||||||
|
};
|
||||||
|
options.BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler();
|
||||||
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
|
options.Scope.Add("wl.basic");
|
||||||
|
options.Scope.Add("wl.signin");
|
||||||
|
});
|
||||||
|
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
|
|
||||||
|
|
@ -129,26 +175,6 @@ namespace MusicStore
|
||||||
// Configure Session.
|
// Configure Session.
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
|
|
||||||
//To gracefully shutdown the server - Not for production scenarios
|
|
||||||
app.Map("/shutdown", shutdown =>
|
|
||||||
{
|
|
||||||
shutdown.Run(async context =>
|
|
||||||
{
|
|
||||||
var appShutdown = context.ApplicationServices.GetService<IApplicationShutdown>();
|
|
||||||
appShutdown.RequestShutdown();
|
|
||||||
|
|
||||||
await Task.Delay(10 * 1000, appShutdown.ShutdownRequested);
|
|
||||||
if (appShutdown.ShutdownRequested.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
await context.Response.WriteAsync("Shutting down gracefully");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await context.Response.WriteAsync("Shutting down token not fired");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Configure SignalR
|
//Configure SignalR
|
||||||
app.UseSignalR();
|
app.UseSignalR();
|
||||||
|
|
||||||
|
|
@ -160,54 +186,11 @@ namespace MusicStore
|
||||||
|
|
||||||
app.UseFacebookAuthentication();
|
app.UseFacebookAuthentication();
|
||||||
|
|
||||||
app.UseGoogleAuthentication(options =>
|
app.UseGoogleAuthentication();
|
||||||
{
|
|
||||||
options.ClientId = "[ClientId]";
|
|
||||||
options.ClientSecret = "[ClientSecret]";
|
|
||||||
options.AccessType = "offline";
|
|
||||||
options.Notifications = new GoogleAuthenticationNotifications()
|
|
||||||
{
|
|
||||||
OnAuthenticated = GoogleNotifications.OnAuthenticated,
|
|
||||||
OnReturnEndpoint = GoogleNotifications.OnReturnEndpoint,
|
|
||||||
OnApplyRedirect = GoogleNotifications.OnApplyRedirect
|
|
||||||
};
|
|
||||||
options.StateDataFormat = new CustomStateDataFormat();
|
|
||||||
options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseTwitterAuthentication(options =>
|
app.UseTwitterAuthentication();
|
||||||
{
|
|
||||||
options.ConsumerKey = "[ConsumerKey]";
|
|
||||||
options.ConsumerSecret = "[ConsumerSecret]";
|
|
||||||
options.Notifications = new TwitterAuthenticationNotifications()
|
|
||||||
{
|
|
||||||
OnAuthenticated = TwitterNotifications.OnAuthenticated,
|
|
||||||
OnReturnEndpoint = TwitterNotifications.OnReturnEndpoint,
|
|
||||||
OnApplyRedirect = TwitterNotifications.OnApplyRedirect
|
|
||||||
};
|
|
||||||
options.StateDataFormat = new CustomTwitterStateDataFormat();
|
|
||||||
options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler();
|
|
||||||
#if DNX451
|
|
||||||
options.BackchannelCertificateValidator = null;
|
|
||||||
#endif
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseMicrosoftAccountAuthentication(options =>
|
app.UseMicrosoftAccountAuthentication();
|
||||||
{
|
|
||||||
options.Caption = "MicrosoftAccount - Requires project changes";
|
|
||||||
options.ClientId = "[ClientId]";
|
|
||||||
options.ClientSecret = "[ClientSecret]";
|
|
||||||
options.Notifications = new MicrosoftAccountAuthenticationNotifications()
|
|
||||||
{
|
|
||||||
OnAuthenticated = MicrosoftAccountNotifications.OnAuthenticated,
|
|
||||||
OnReturnEndpoint = MicrosoftAccountNotifications.OnReturnEndpoint,
|
|
||||||
OnApplyRedirect = MicrosoftAccountNotifications.OnApplyRedirect
|
|
||||||
};
|
|
||||||
options.BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler();
|
|
||||||
options.StateDataFormat = new CustomStateDataFormat();
|
|
||||||
options.Scope.Add("wl.basic");
|
|
||||||
options.Scope.Add("wl.signin");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add MVC to the request pipeline
|
// Add MVC to the request pipeline
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
|
|
@ -231,4 +214,4 @@ namespace MusicStore
|
||||||
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue