From 43c6f31a65afdf0db221c85f12604d3bf12225d8 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 6 Jun 2021 20:32:39 +0100 Subject: [PATCH] refacts --- .gitlab-ci.yml | 13 +--- src/Yavsc/Models/ApplicationDbContext.cs | 2 +- src/sampleWebAsWebApiClient/Makefile | 15 ++--- test/yavscTests/BaseTestContext.cs | 4 +- test/yavscTests/Makefile | 22 ++++--- test/yavscTests/Mandatory/BatchTests.cs | 62 ++++++++++++++----- test/yavscTests/Mandatory/RegisterApi.cs | 7 +-- test/yavscTests/Mandatory/Remoting.cs | 43 +++++-------- test/yavscTests/Mandatory/Resources.cs | 2 +- .../yavscTests/Mandatory/ServerSideFixture.cs | 57 +++++++++++------ .../yavscTests/NonRegression/AbstractTests.cs | 2 +- test/yavscTests/NonRegression/Database.cs | 8 +-- test/yavscTests/NonRegression/EMailling.cs | 2 +- test/yavscTests/NonRegression/NodeTests.cs | 2 +- .../Settings/DbConnectionSettings.cs | 2 +- test/yavscTests/Settings/Testing.cs | 9 +-- test/yavscTests/Startup.cs | 20 +++--- test/yavscTests/TestHelpers.cs | 2 +- test/yavscTests/WIP/NotWorking.cs | 2 +- test/yavscTests/appsettings.json | 39 ++++++------ 20 files changed, 175 insertions(+), 140 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0fedf95c..7b46762f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,3 @@ -# using the official mono docker image to build a visual studio project. -# -# MyProject.sln -# MyProject\ -# MyProject\ -# MyProject.csproj (console application) -# MyProject.Test\ -# MyProject.Test.csproj (test library using nuget packages "NUnit" and "NUnit.ConsoleRunner") -# # Please find the full example project here: # https://gitlab.com/tobiaskoch/gitlab-ci-example-mono @@ -34,9 +25,9 @@ before_script: debug: stage: test script: - - cd src/test + - cd test/yavscTests - dnu build - - dnx test -maxthreads 1 -trait regression=non + - ASPNET_ENV=Testing dnx test -maxthreads 1 release: stage: deploy diff --git a/src/Yavsc/Models/ApplicationDbContext.cs b/src/Yavsc/Models/ApplicationDbContext.cs index 445fcace..20498690 100644 --- a/src/Yavsc/Models/ApplicationDbContext.cs +++ b/src/Yavsc/Models/ApplicationDbContext.cs @@ -279,7 +279,7 @@ namespace Yavsc.Models public DbSet GitRepositoryReference { get; set; } - public DbSet Project { get; set; } + public DbSet Project { get; set; } public DbSet BlogTrad { get; set; } diff --git a/src/sampleWebAsWebApiClient/Makefile b/src/sampleWebAsWebApiClient/Makefile index 1df2199f..118c9bf8 100644 --- a/src/sampleWebAsWebApiClient/Makefile +++ b/src/sampleWebAsWebApiClient/Makefile @@ -3,17 +3,18 @@ BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll SOURCE_DIR=../.. MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make MSBUILD=msbuild +YAVSCSRC=../../src 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) diff --git a/test/yavscTests/BaseTestContext.cs b/test/yavscTests/BaseTestContext.cs index 2254ac22..734738e1 100644 --- a/test/yavscTests/BaseTestContext.cs +++ b/test/yavscTests/BaseTestContext.cs @@ -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; } } -} \ No newline at end of file +} diff --git a/test/yavscTests/Makefile b/test/yavscTests/Makefile index e7e147b3..f034fdbf 100644 --- a/test/yavscTests/Makefile +++ b/test/yavscTests/Makefile @@ -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 +all-tests: $(BINTARGET) + ASPNET_ENV=Testing dnx test -maxthreads 1 + regression: $(BINTARGET) - ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=oui + ASPNET_ENV=Testing dnx test -maxthreads 1 -trait regression=oui -test: non-regression +test: all-tests testdev: $(BINTARGET) ASPNET_ENV=Development dnx test -maxthreads 1 -trait dev=wip diff --git a/test/yavscTests/Mandatory/BatchTests.cs b/test/yavscTests/Mandatory/BatchTests.cs index da3027dc..0341717d 100644 --- a/test/yavscTests/Mandatory/BatchTests.cs +++ b/test/yavscTests/Mandatory/BatchTests.cs @@ -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, 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( - 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( 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( @@ -189,6 +212,17 @@ namespace test var rtd = app.Build(); IOptions localOptions = ActivatorUtilities.GetServiceOrCreateInstance>(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(); } } } diff --git a/test/yavscTests/Mandatory/RegisterApi.cs b/test/yavscTests/Mandatory/RegisterApi.cs index f228b2bf..3ded4a56 100644 --- a/test/yavscTests/Mandatory/RegisterApi.cs +++ b/test/yavscTests/Mandatory/RegisterApi.cs @@ -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() - .Build().Start(); } } diff --git a/test/yavscTests/Mandatory/Remoting.cs b/test/yavscTests/Mandatory/Remoting.cs index 608f6f0e..1329463d 100644 --- a/test/yavscTests/Mandatory/Remoting.cs +++ b/test/yavscTests/Mandatory/Remoting.cs @@ -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 { - [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(); - 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[] { 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[] { "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, 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);; } - } } diff --git a/test/yavscTests/Mandatory/Resources.cs b/test/yavscTests/Mandatory/Resources.cs index 641f267a..8d3bdbf2 100644 --- a/test/yavscTests/Mandatory/Resources.cs +++ b/test/yavscTests/Mandatory/Resources.cs @@ -1,5 +1,5 @@ -namespace test { +namespace yavscTests { public class ResxResources { const string resPath = "Resources/Test.TestResources.resx"; public void HaveAResxLoader() diff --git a/test/yavscTests/Mandatory/ServerSideFixture.cs b/test/yavscTests/Mandatory/ServerSideFixture.cs index 97c3c38f..9e710fbd 100644 --- a/test/yavscTests/Mandatory/ServerSideFixture.cs +++ b/test/yavscTests/Mandatory/ServerSideFixture.cs @@ -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 /// /// - 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() + hostengnine = Host + .UseEnvironment("Testing") + .UseServer("yavscTests") + .UseStartup() .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)) as IOptions; AssertNotNull(siteSetup, nameof(siteSetup)); - var testingSetup = App.Services.GetService(typeof(IOptions)) as IOptions; + + var testingSetup = App.Services.GetService(typeof(IOptions)) as IOptions; + 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(); + 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; } } } } diff --git a/test/yavscTests/NonRegression/AbstractTests.cs b/test/yavscTests/NonRegression/AbstractTests.cs index ce288f4b..51b05bb2 100644 --- a/test/yavscTests/NonRegression/AbstractTests.cs +++ b/test/yavscTests/NonRegression/AbstractTests.cs @@ -3,7 +3,7 @@ using Xunit; using Xunit.Abstractions; using Yavsc.Helpers; -namespace test +namespace yavscTests { [Collection("Yavsc Abstract tests")] [Trait("regression", "II")] diff --git a/test/yavscTests/NonRegression/Database.cs b/test/yavscTests/NonRegression/Database.cs index b8557237..e8345bf3 100644 --- a/test/yavscTests/NonRegression/Database.cs +++ b/test/yavscTests/NonRegression/Database.cs @@ -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}"); } /// @@ -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() diff --git a/test/yavscTests/NonRegression/EMailling.cs b/test/yavscTests/NonRegression/EMailling.cs index 851fac47..754c834a 100644 --- a/test/yavscTests/NonRegression/EMailling.cs +++ b/test/yavscTests/NonRegression/EMailling.cs @@ -3,7 +3,7 @@ using Xunit; using Xunit.Abstractions; using Yavsc.Abstract.Manage; -namespace test +namespace yavscTests { [Collection("EMaillingTeststCollection")] diff --git a/test/yavscTests/NonRegression/NodeTests.cs b/test/yavscTests/NonRegression/NodeTests.cs index adb7bfd5..57c9f85b 100755 --- a/test/yavscTests/NonRegression/NodeTests.cs +++ b/test/yavscTests/NonRegression/NodeTests.cs @@ -3,7 +3,7 @@ using Xunit; using System.IO; using System.Diagnostics; -namespace test +namespace yavscTests { /// diff --git a/test/yavscTests/Settings/DbConnectionSettings.cs b/test/yavscTests/Settings/DbConnectionSettings.cs index 2be40163..1c11ebf3 100644 --- a/test/yavscTests/Settings/DbConnectionSettings.cs +++ b/test/yavscTests/Settings/DbConnectionSettings.cs @@ -1,4 +1,4 @@ -namespace test.Settings +namespace yavscTests.Settings { public class DbConnectionSettings { diff --git a/test/yavscTests/Settings/Testing.cs b/test/yavscTests/Settings/Testing.cs index 8e607839..96fe3516 100644 --- a/test/yavscTests/Settings/Testing.cs +++ b/test/yavscTests/Settings/Testing.cs @@ -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; } } } diff --git a/test/yavscTests/Startup.cs b/test/yavscTests/Startup.cs index 3237af55..5b442803 100644 --- a/test/yavscTests/Startup.cs +++ b/test/yavscTests/Startup.cs @@ -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(dbSettingsconf); var testingconf = Configuration.GetSection("Testing"); - services.Configure(testingconf); + services.Configure(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 testingSettings, + IOptions testingSettings, UserManager usermanager, ILoggerFactory loggerFactory ) @@ -418,17 +420,15 @@ namespace test logger = loggerFactory.CreateLogger(); 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"); diff --git a/test/yavscTests/TestHelpers.cs b/test/yavscTests/TestHelpers.cs index 3898ff95..c591a9a2 100644 --- a/test/yavscTests/TestHelpers.cs +++ b/test/yavscTests/TestHelpers.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; -namespace test { +namespace yavscTests { public static class AssertAsync { diff --git a/test/yavscTests/WIP/NotWorking.cs b/test/yavscTests/WIP/NotWorking.cs index 003897a1..cd245d16 100644 --- a/test/yavscTests/WIP/NotWorking.cs +++ b/test/yavscTests/WIP/NotWorking.cs @@ -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")] diff --git a/test/yavscTests/appsettings.json b/test/yavscTests/appsettings.json index ad3116a6..c99f8b36 100644 --- a/test/yavscTests/appsettings.json +++ b/test/yavscTests/appsettings.json @@ -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"} } }