refacts
This commit is contained in:
@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
public class BaseTestContext {
|
||||
|
||||
@ -23,4 +23,4 @@ namespace test
|
||||
this._serverFixture = serverFixture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,34 @@ BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll
|
||||
SOURCE_DIR=../..
|
||||
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
|
||||
MSBUILD=msbuild
|
||||
YAVSCSRC=../../src
|
||||
|
||||
all: test
|
||||
|
||||
include $(MAKEFILE_DIR)/dnx.mk
|
||||
|
||||
../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll:
|
||||
make -C ../Yavsc
|
||||
$(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll:
|
||||
make -C $(YAVSCSRC)/Yavsc
|
||||
|
||||
../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll:
|
||||
make -C ../Yavsc.Abstract
|
||||
$(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll:
|
||||
make -C $(YAVSCSRC)/Yavsc.Abstract
|
||||
|
||||
../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll:
|
||||
make -C ../Yavsc.Server
|
||||
$(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll:
|
||||
make -C $(YAVSCSRC)/Yavsc.Server
|
||||
|
||||
$(BINTARGET): project.lock.json ../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll ../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll ../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll
|
||||
$(BINTARGET): project.lock.json $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll
|
||||
dnu build --configuration $(CONFIGURATION)
|
||||
|
||||
non-regression: $(BINTARGET)
|
||||
ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=non
|
||||
|
||||
regression: $(BINTARGET)
|
||||
ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=oui
|
||||
all-tests: $(BINTARGET)
|
||||
ASPNET_ENV=Testing dnx test -maxthreads 1
|
||||
|
||||
test: non-regression
|
||||
regression: $(BINTARGET)
|
||||
ASPNET_ENV=Testing dnx test -maxthreads 1 -trait regression=oui
|
||||
|
||||
test: all-tests
|
||||
|
||||
testdev: $(BINTARGET)
|
||||
ASPNET_ENV=Development dnx test -maxthreads 1 -trait dev=wip
|
||||
|
@ -22,26 +22,27 @@ using Xunit.Abstractions;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Yavsc.Server.Models.IT.SourceCode;
|
||||
using yavscTests.Settings;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc mandatory success story")]
|
||||
[Trait("regression", "oui")]
|
||||
public class BatchTests: BaseTestContext, IClassFixture<ServerSideFixture>, IDisposable
|
||||
{
|
||||
ServerSideFixture _fixture;
|
||||
private TestingSetup _testingOptions;
|
||||
|
||||
public BatchTests(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
_testingOptions = fixture.TestingSetup;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GitClone()
|
||||
{
|
||||
Assert.True(_serverFixture.EnsureTestDb());
|
||||
Assert.NotNull (_fixture.DbContext.Project);
|
||||
var firstProject = _fixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault();
|
||||
Assert.NotNull (_serverFixture.DbContext.Project);
|
||||
var firstProject = _serverFixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault();
|
||||
Assert.NotNull (firstProject);
|
||||
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);
|
||||
if (!di.Exists) di.Create();
|
||||
@ -94,19 +95,32 @@ namespace test
|
||||
configurationRoot = builder.Build();
|
||||
}
|
||||
|
||||
internal static BeforeCompileContext CreateYavscCompilationContext()
|
||||
internal BeforeCompileContext CreateYavscCompilationContext()
|
||||
{
|
||||
BeforeCompileContext newBeforeCompileContext = null;
|
||||
Assert.NotNull(_testingOptions);
|
||||
try
|
||||
{
|
||||
var projectContext = new ProjectContext
|
||||
{
|
||||
Name = "Yavsc",
|
||||
ProjectDirectory = "../Yavsc",
|
||||
ProjectFilePath = "../Yavsc/project.json",
|
||||
ProjectDirectory = _testingOptions.YavscWebPath,
|
||||
ProjectFilePath = Path.Combine(_testingOptions.YavscWebPath, "project.json"),
|
||||
TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1)),
|
||||
Configuration = Environment.GetEnvironmentVariable("ASPNET_ENV")
|
||||
};
|
||||
|
||||
return new BeforeCompileContext(
|
||||
newBeforeCompileContext = new BeforeCompileContext(
|
||||
null, projectContext, () => null, () => null, () => null);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_output.WriteLine(ex.Message);
|
||||
_output.WriteLine(ex.StackTrace);
|
||||
}
|
||||
|
||||
return newBeforeCompileContext;
|
||||
}
|
||||
|
||||
internal static IConfigurationRoot CreateConfiguration(string prjDir)
|
||||
@ -144,19 +158,21 @@ namespace test
|
||||
{
|
||||
options.ResourcesPath = "Resources";
|
||||
});
|
||||
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Startup.Testing.ConnectionStrings.Default);
|
||||
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Startup.TestingSetup.ConnectionStrings.Default);
|
||||
serviceCollection.AddEntityFramework()
|
||||
.AddNpgsql()
|
||||
.AddDbContext<ApplicationDbContext>(
|
||||
db => db.UseNpgsql(Startup.Testing.ConnectionStrings.Default)
|
||||
db => db.UseNpgsql(Startup.TestingSetup.ConnectionStrings.Default)
|
||||
);
|
||||
provider = serviceCollection.BuildServiceProvider();
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
[Fact]
|
||||
public void ARequestAppDelegate()
|
||||
public void ARequestDelegate()
|
||||
{
|
||||
try {
|
||||
var services = new ServiceCollection();
|
||||
services.AddTransient<IRuntimeEnvironment>(
|
||||
svs => PlatformServices.Default.Runtime
|
||||
@ -168,13 +184,20 @@ namespace test
|
||||
|
||||
IApplicationBuilder app = new ApplicationBuilder(serviceProvider);
|
||||
var rtd = app.Build();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_output.WriteLine(ex.Message);
|
||||
_output.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void InitApplicationBuilder()
|
||||
{
|
||||
try {
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddTransient<IRuntimeEnvironment>(
|
||||
@ -189,6 +212,17 @@ namespace test
|
||||
var rtd = app.Build();
|
||||
IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_output.WriteLine(ex.Message);
|
||||
_output.WriteLine(ex.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -197,7 +231,7 @@ namespace test
|
||||
{
|
||||
Directory.Delete(Path.Combine(gitRepo,"yavsc"), true);
|
||||
}
|
||||
_fixture.DropTestDb();
|
||||
_serverFixture.DropTestDb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc Work In Progress")]
|
||||
[Trait("regression", "oui")]
|
||||
@ -35,11 +35,6 @@ namespace test
|
||||
[Fact]
|
||||
public void EnsureWeb()
|
||||
{
|
||||
var host = new WebHostBuilder();
|
||||
host.UseEnvironment("Development")
|
||||
.UseServer("Microsoft.AspNet.Server.Kestrel")
|
||||
.UseStartup<test.Startup>()
|
||||
.Build().Start();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,13 +10,14 @@ using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Yavsc.Authentication;
|
||||
using static OAuth.AspNet.AuthServer.Constants;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc Work In Progress")]
|
||||
[Trait("regression", "oui")]
|
||||
@ -39,9 +40,7 @@ namespace test
|
||||
string scope,
|
||||
string authorizeUrl,
|
||||
string redirectUrl,
|
||||
string accessTokenUrl,
|
||||
string login,
|
||||
string pass
|
||||
string accessTokenUrl
|
||||
)
|
||||
{
|
||||
try
|
||||
@ -52,8 +51,8 @@ namespace test
|
||||
new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl));
|
||||
var query = new Dictionary<string, string>
|
||||
{
|
||||
[Parameters.Username] = Startup.Testing.ValidCreds[0].UserName,
|
||||
[Parameters.Password] = Startup.Testing.ValidCreds[0].Password,
|
||||
[Parameters.Username] = Startup.TestingSetup.ValidCreds.UserName,
|
||||
[Parameters.Password] = Startup.TestingSetup.ValidCreds.Password,
|
||||
[Parameters.GrantType] = GrantTypes.Password
|
||||
};
|
||||
|
||||
@ -70,7 +69,7 @@ namespace test
|
||||
var webex = ex as WebException;
|
||||
if (webex != null && webex.Status == (WebExceptionStatus)400)
|
||||
{
|
||||
if (login == "joe")
|
||||
if (Startup.TestingSetup.ValidCreds.UserName == "lame-user")
|
||||
{
|
||||
Console.WriteLine("Bad pass joe!");
|
||||
return;
|
||||
@ -85,30 +84,20 @@ namespace test
|
||||
|
||||
var allData = new List<object[]>();
|
||||
|
||||
for (int iTest=0; iTest < numTests && iTest < Startup.Testing.ValidCreds.Length; iTest++)
|
||||
{
|
||||
|
||||
var login = Startup.Testing.ValidCreds[iTest].UserName;
|
||||
var pass = Startup.Testing.ValidCreds[iTest].Password;
|
||||
allData.Add(new object[] { "blouh", "profile",
|
||||
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
||||
"http://localhost:5000/token", "http://localhost:5000/authorize"});
|
||||
|
||||
|
||||
|
||||
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
|
||||
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
||||
"http://localhost:5000/token",login, pass});
|
||||
}
|
||||
var valid = allData.Count;
|
||||
for (int iTest=0; iTest + valid < numTests && iTest < Startup.Testing.InvalidCreds.Length; iTest++)
|
||||
{
|
||||
var login = Startup.Testing.InvalidCreds[iTest].UserName;
|
||||
var pass = Startup.Testing.InvalidCreds[iTest].Password;
|
||||
|
||||
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
|
||||
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
||||
"http://localhost:5000/token",login, 0 });
|
||||
}
|
||||
return allData.Take(numTests);
|
||||
allData.Add(new object[] { "blouh", "profile",
|
||||
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
||||
"http://localhost:5000/token", "http://localhost:5000/authorize"});
|
||||
|
||||
return allData.Take(numTests);;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
namespace test {
|
||||
namespace yavscTests {
|
||||
public class ResxResources {
|
||||
const string resPath = "Resources/Test.TestResources.resx";
|
||||
public void HaveAResxLoader()
|
||||
|
@ -10,11 +10,11 @@ using Yavsc;
|
||||
using Yavsc.Models;
|
||||
using Xunit;
|
||||
using Npgsql;
|
||||
using test.Settings;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Metadata.Conventions;
|
||||
using yavscTests.Settings;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Trait("regression", "II")]
|
||||
public class ServerSideFixture : IDisposable
|
||||
@ -26,7 +26,7 @@ namespace test
|
||||
readonly ILoggerFactory _loggerFactory;
|
||||
IEmailSender _mailSender;
|
||||
|
||||
public static string ApiKey => "53f4d5da-93a9-4584-82f9-b8fdf243b002";
|
||||
public string ApiKey { get; private set; }
|
||||
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
public SiteSettings SiteSetup
|
||||
@ -46,7 +46,7 @@ namespace test
|
||||
/// initialized by Init
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static object TestingSetup { get; private set; }
|
||||
public TestingSetup TestingSetup { get; private set; }
|
||||
|
||||
public IEmailSender MailSender
|
||||
{
|
||||
@ -76,9 +76,9 @@ namespace test
|
||||
|
||||
|
||||
|
||||
internal void UpgradeDb()
|
||||
internal int UpgradeDb()
|
||||
{
|
||||
Microsoft.Data.Entity.Commands.Program.Main(
|
||||
return Microsoft.Data.Entity.Commands.Program.Main(
|
||||
new string[] { "database", "update" });
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace test
|
||||
}
|
||||
}
|
||||
bool dbCreated;
|
||||
private readonly WebHostBuilder host;
|
||||
public WebHostBuilder Host { get; private set; }
|
||||
private readonly IHostingEngine hostengnine;
|
||||
|
||||
|
||||
@ -108,13 +108,13 @@ namespace test
|
||||
//
|
||||
public ServerSideFixture()
|
||||
{
|
||||
host = new WebHostBuilder();
|
||||
AssertNotNull(host, nameof(host));
|
||||
Host = new WebHostBuilder();
|
||||
AssertNotNull(Host, nameof(Host));
|
||||
|
||||
hostengnine = host
|
||||
.UseEnvironment("Development")
|
||||
.UseServer("test")
|
||||
.UseStartup<test.Startup>()
|
||||
hostengnine = Host
|
||||
.UseEnvironment("Testing")
|
||||
.UseServer("yavscTests")
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
AssertNotNull(hostengnine, nameof(hostengnine));
|
||||
@ -132,20 +132,27 @@ namespace test
|
||||
|
||||
_loggerFactory = App.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
|
||||
AssertNotNull(_loggerFactory, nameof(_loggerFactory));
|
||||
|
||||
var siteSetup = App.Services.GetService(typeof(IOptions<SiteSettings>)) as IOptions<SiteSettings>;
|
||||
AssertNotNull(siteSetup, nameof(siteSetup));
|
||||
var testingSetup = App.Services.GetService(typeof(IOptions<Testing>)) as IOptions<Testing>;
|
||||
|
||||
var testingSetup = App.Services.GetService(typeof(IOptions<TestingSetup>)) as IOptions<TestingSetup>;
|
||||
AssertNotNull(testingSetup, nameof(testingSetup));
|
||||
|
||||
DbContext = App.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
|
||||
|
||||
SiteSetup = siteSetup.Value;
|
||||
TestingSetup = testingSetup.Value;
|
||||
AssertNotNull(SiteSetup, nameof(SiteSetup));
|
||||
|
||||
TestingSetup = testingSetup.Value;
|
||||
AssertNotNull(TestingSetup, nameof(TestingSetup));
|
||||
|
||||
Logger = _loggerFactory.CreateLogger<ServerSideFixture>();
|
||||
AssertNotNull(Logger, nameof(Logger));
|
||||
|
||||
var builder = new DbConnectionStringBuilder
|
||||
{
|
||||
ConnectionString = Startup.Testing.ConnectionStrings.Default
|
||||
ConnectionString = Startup.TestingSetup.ConnectionStrings.Default
|
||||
};
|
||||
ConventionSet conventions = new ConventionSet();
|
||||
|
||||
@ -155,6 +162,7 @@ namespace test
|
||||
|
||||
|
||||
TestingDatabase = (string)builder["Database"];
|
||||
AssertNotNull(TestingDatabase, nameof(TestingDatabase));
|
||||
|
||||
Logger.LogInformation("ServerSideFixture created.");
|
||||
}
|
||||
@ -167,7 +175,7 @@ namespace test
|
||||
public void CheckDbExistence()
|
||||
{
|
||||
using (
|
||||
NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor))
|
||||
NpgsqlConnection cx = new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.Default))
|
||||
{
|
||||
cx.Open();
|
||||
_logger.LogInformation($"check db for TestingDatabase:{TestingDatabase}");
|
||||
@ -183,16 +191,19 @@ namespace test
|
||||
{
|
||||
if (!DbCreated)
|
||||
{
|
||||
using (NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor))
|
||||
using (NpgsqlConnection cx =
|
||||
new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.DatabaseCtor))
|
||||
{
|
||||
_logger.LogInformation($"create database for TestingDatabase : {TestingDatabase}");
|
||||
|
||||
cx.Open();
|
||||
var command = cx.CreateCommand();
|
||||
using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.Default))
|
||||
using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.Default))
|
||||
command.CommandText = $"create database \"{TestingDatabase}\" OWNER \"{ownercx.UserName}\";";
|
||||
|
||||
_logger.LogInformation(command.CommandText);
|
||||
command.ExecuteNonQuery();
|
||||
cx.Close();
|
||||
}
|
||||
dbCreated = true;
|
||||
|
||||
@ -213,7 +224,15 @@ namespace test
|
||||
}
|
||||
|
||||
public bool DbCreated { get {
|
||||
try {
|
||||
CheckDbExistence();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
_logger.LogError(ex.StackTrace);
|
||||
}
|
||||
return dbCreated; } }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc Abstract tests")]
|
||||
[Trait("regression", "II")]
|
||||
|
@ -2,7 +2,7 @@ using System;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace test.Mandatory
|
||||
namespace yavscTests.Mandatory
|
||||
{
|
||||
[Collection("Database")]
|
||||
[Trait("regression", "II")]
|
||||
@ -25,7 +25,7 @@ namespace test.Mandatory
|
||||
{
|
||||
output.WriteLine("db not dropped");
|
||||
}
|
||||
output.WriteLine($"Startup.Testing.ConnectionStrings.DatabaseCtor is {Startup.Testing.ConnectionStrings.DatabaseCtor}");
|
||||
output.WriteLine($"Startup.Testing.ConnectionStrings.Default is {Startup.TestingSetup.ConnectionStrings.Default}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -35,8 +35,8 @@ namespace test.Mandatory
|
||||
[Fact]
|
||||
public void InstallFromScratchUsingPoweredNpgsqlUser()
|
||||
{
|
||||
_serverFixture.EnsureTestDb();
|
||||
_serverFixture.UpgradeDb();
|
||||
Assert.True(_serverFixture.EnsureTestDb());
|
||||
Assert.True(_serverFixture.UpgradeDb()==0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -3,7 +3,7 @@ using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Yavsc.Abstract.Manage;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
|
||||
[Collection("EMaillingTeststCollection")]
|
||||
|
@ -3,7 +3,7 @@ using Xunit;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace test.Settings
|
||||
namespace yavscTests.Settings
|
||||
{
|
||||
public class DbConnectionSettings
|
||||
{
|
||||
|
@ -1,22 +1,23 @@
|
||||
namespace test.Settings
|
||||
namespace yavscTests.Settings
|
||||
{
|
||||
public class PasswordCreds
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
public class Testing
|
||||
public class TestingSetup
|
||||
{
|
||||
public DbConnectionSettings ConnectionStrings { get; set; }
|
||||
|
||||
public PasswordCreds[] ValidCreds
|
||||
public PasswordCreds ValidCreds
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public PasswordCreds[] InvalidCreds
|
||||
public PasswordCreds InvalidCreds
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string YavscWebPath {get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using test.Settings;
|
||||
using yavscTests.Settings;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using System.Net;
|
||||
using Yavsc.Extensions;
|
||||
@ -49,7 +49,7 @@ using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Yavsc.Auth;
|
||||
using Yavsc.Lib;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
@ -60,7 +60,7 @@ namespace test
|
||||
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
|
||||
public static Testing Testing { get; private set; }
|
||||
public static TestingSetup TestingSetup { get; private set; }
|
||||
|
||||
public static IConfigurationRoot GoogleWebClientConfiguration { get; set; }
|
||||
|
||||
@ -70,6 +70,8 @@ namespace test
|
||||
public Yavsc.Auth.YavscGoogleOptions YavscGoogleAppOptions { get; private set; }
|
||||
private static ILogger logger;
|
||||
|
||||
public static string ApiKey { get; private set; }
|
||||
|
||||
|
||||
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
||||
{
|
||||
@ -108,7 +110,7 @@ namespace test
|
||||
var dbSettingsconf = Configuration.GetSection("ConnectionStrings");
|
||||
services.Configure<DbConnectionSettings>(dbSettingsconf);
|
||||
var testingconf = Configuration.GetSection("Testing");
|
||||
services.Configure<Testing>(testingconf);
|
||||
services.Configure<TestingSetup>(testingconf);
|
||||
|
||||
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
||||
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
||||
@ -408,7 +410,7 @@ namespace test
|
||||
IApplicationBuilder app,
|
||||
IHostingEnvironment env,
|
||||
ApplicationDbContext dbContext,
|
||||
IOptions<Testing> testingSettings,
|
||||
IOptions<TestingSetup> testingSettings,
|
||||
UserManager<ApplicationUser> usermanager,
|
||||
ILoggerFactory loggerFactory
|
||||
)
|
||||
@ -418,17 +420,15 @@ namespace test
|
||||
logger = loggerFactory.CreateLogger<Startup>();
|
||||
logger.LogInformation(env.EnvironmentName);
|
||||
this.DbContext = dbContext;
|
||||
Testing = testingSettings.Value;
|
||||
TestingSetup = testingSettings.Value;
|
||||
|
||||
_usermanager = usermanager;
|
||||
#if USERMANAGER
|
||||
#endif
|
||||
|
||||
if (Testing.ConnectionStrings == null)
|
||||
if (TestingSetup.ConnectionStrings == null)
|
||||
logger.LogInformation($" Testing.ConnectionStrings is null : ");
|
||||
else
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Testing.ConnectionStrings.Default);
|
||||
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", TestingSetup.ConnectionStrings.Default);
|
||||
}
|
||||
|
||||
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace test {
|
||||
namespace yavscTests {
|
||||
|
||||
public static class AssertAsync {
|
||||
|
||||
|
@ -11,7 +11,7 @@ using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Dnx.TestHost.TestAdapter;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace test
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc dropped intents")]
|
||||
[Trait("regres", "yes")]
|
||||
|
@ -31,36 +31,37 @@
|
||||
"EnableSSL": false
|
||||
},
|
||||
"Logging": {
|
||||
"IncludeScopes": true,
|
||||
"IncludeScopes": {
|
||||
|
||||
},
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Warning",
|
||||
"Microsoft": "Warning"
|
||||
}
|
||||
},
|
||||
"Testing": {
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-DataBase;Username=lame-Username;Password=lame-dbPassword;",
|
||||
"DatabaseCtor": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-ctor-DataBase;Username=lame-ctor-Username;Password=lame-ctordbPassword;"
|
||||
},
|
||||
"ValidCreds": [
|
||||
{
|
||||
"UserName": "lame-user",
|
||||
"Password": "lame-password"
|
||||
}
|
||||
],
|
||||
"InvalidCreds": [
|
||||
{
|
||||
"UserName": "lame-fakeuser",
|
||||
"Password": "lame-fakepassword"
|
||||
}
|
||||
]
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-DataBase;Username=lame-Username;Password=lame-dbPassword;",
|
||||
"DatabaseCtor": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-ctor-DataBase;Username=lame-ctor-Username;Password=lame-ctordbPassword;"
|
||||
},
|
||||
"ValidCreds": {
|
||||
"UserName": "lame-user",
|
||||
"Password": "lame-password"
|
||||
},
|
||||
"InvalidCreds": {
|
||||
"UserName": "fakeuser",
|
||||
"Password": "f/\\kePassw0rd"
|
||||
},
|
||||
"YavscWebPath": "../../src/Yavsc",
|
||||
"DataProtection": {
|
||||
"Keys": {
|
||||
"Dir": "DataProtection-Keys"
|
||||
},
|
||||
"RSAParamFile": "ls ",
|
||||
"RSAParamFile": "RSAParamFile",
|
||||
"ExpiresInHours": 168
|
||||
},
|
||||
"ApiKey": "lame-key",
|
||||
"Testing": {
|
||||
"ConnectionStrings": {"Default": "none"}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user