Fixes the css
This commit is contained in:
parent
348e22f1c9
commit
cba18df870
11 changed files with 124 additions and 77 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -36,3 +36,5 @@ appsettings.Development.json
|
||||||
|
|
||||||
contrib/generated/
|
contrib/generated/
|
||||||
*.tmp
|
*.tmp
|
||||||
|
|
||||||
|
DataDir/
|
||||||
|
|
|
||||||
12
src/Yavsc.Org/wwwroot/lib/bootstrap.quartz.min.css
vendored
Normal file
12
src/Yavsc.Org/wwwroot/lib/bootstrap.quartz.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@ namespace Yavsc.Server.Helpers;
|
||||||
|
|
||||||
public static class ConfigHelpers
|
public static class ConfigHelpers
|
||||||
{
|
{
|
||||||
public static void AddConfiguration(this WebApplicationBuilder builder, string appName )
|
public static IConfigurationBuilder AddConfiguration(this WebApplicationBuilder builder, string appName )
|
||||||
{
|
{
|
||||||
var rootConfig = builder.Configuration
|
var rootConfig = builder.Configuration
|
||||||
.AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false);
|
.AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false);
|
||||||
|
|
@ -13,6 +13,6 @@ public static class ConfigHelpers
|
||||||
if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName))
|
if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName))
|
||||||
rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false);
|
rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false);
|
||||||
;
|
;
|
||||||
rootConfig.AddEnvironmentVariables();
|
return rootConfig.AddEnvironmentVariables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
39
test/yavscTests/DumpHtml.cs
Normal file
39
test/yavscTests/DumpHtml.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Yavsc.Tests
|
||||||
|
{
|
||||||
|
[Collection("Yavsc Server")]
|
||||||
|
public class DumpHtml : IClassFixture<WebServerFixture>
|
||||||
|
{
|
||||||
|
readonly WebServerFixture _server;
|
||||||
|
public DumpHtml(WebServerFixture server) { _server = server; }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("debug", "html")]
|
||||||
|
public void DumpHomePageHtml()
|
||||||
|
{
|
||||||
|
var settings = _server.SiteSettings;
|
||||||
|
var handler = new HttpClientHandler
|
||||||
|
{
|
||||||
|
ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
|
||||||
|
};
|
||||||
|
var httpsUrl = _server.Addresses.FirstOrDefault(u => u.StartsWith("https:"))
|
||||||
|
?? _server.Addresses.FirstOrDefault() ?? "";
|
||||||
|
using var client = new HttpClient(handler) { BaseAddress = new Uri(httpsUrl) };
|
||||||
|
|
||||||
|
var paths = new[] { "/Home/About", "/css/site.css", "/lib/bootstrap.quartz.min.css", "/nonexistent" };
|
||||||
|
var sb = new System.Text.StringBuilder();
|
||||||
|
sb.AppendLine($"BaseAddress = {httpsUrl}");
|
||||||
|
foreach (var p in paths)
|
||||||
|
{
|
||||||
|
var r = client.GetAsync(p).GetAwaiter().GetResult();
|
||||||
|
var b = r.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||||
|
sb.AppendLine($"GET {p} => {r.StatusCode} len={b.Length} ct={r.Content.Headers.ContentType}");
|
||||||
|
if (b.Length > 0 && b.Length < 500)
|
||||||
|
sb.AppendLine($" body: {b.Substring(0, Math.Min(300, b.Length))}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.Fail(sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,24 +1,47 @@
|
||||||
using System;
|
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Chrome;
|
using OpenQA.Selenium.Chrome;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
using Yavsc.Tests;
|
||||||
|
|
||||||
namespace SeleniumDocs.GettingStarted;
|
namespace yavscTests.ServerFixtures;
|
||||||
|
|
||||||
[Collection("Yavsc Server")]
|
|
||||||
[Trait("regression", "oui")]
|
[Collection("Yavsc Server")]
|
||||||
public static class FirstScript
|
|
||||||
|
public class FirstScript : BaseTestContext
|
||||||
{
|
{
|
||||||
[Fact]
|
public readonly WebServerFixture _serverFixture;
|
||||||
public static void DoTestSeleniumWebSite()
|
readonly ITestOutputHelper _output;
|
||||||
{
|
|
||||||
IWebDriver driver = new ChromeDriver();
|
|
||||||
|
|
||||||
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html");
|
IWebDriver driver = new ChromeDriver();
|
||||||
|
public FirstScript(ITestOutputHelper output, WebServerFixture fixture) : base(output, fixture)
|
||||||
|
{
|
||||||
|
_serverFixture = fixture;
|
||||||
|
this._output = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task DoTestYavscSite()
|
||||||
|
{
|
||||||
|
var chromeOptions = new ChromeOptions
|
||||||
|
{
|
||||||
|
AcceptInsecureCertificates = true
|
||||||
|
};
|
||||||
|
|
||||||
|
var driver = new ChromeDriver(chromeOptions);
|
||||||
|
var url = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:"));
|
||||||
|
Assert.NotNull(url);
|
||||||
|
driver.Navigate().GoToUrl(url);
|
||||||
|
|
||||||
var title = driver.Title;
|
var title = driver.Title;
|
||||||
|
|
||||||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
|
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
|
||||||
|
|
||||||
|
var navbar = driver.FindElement(By.Id("navbar"));
|
||||||
|
Assert.NotNull(navbar);
|
||||||
|
/*
|
||||||
var textBox = driver.FindElement(By.Name("my-text"));
|
var textBox = driver.FindElement(By.Name("my-text"));
|
||||||
var submitButton = driver.FindElement(By.TagName("button"));
|
var submitButton = driver.FindElement(By.TagName("button"));
|
||||||
|
|
||||||
|
|
@ -27,7 +50,9 @@ public static class FirstScript
|
||||||
|
|
||||||
var message = driver.FindElement(By.Id("message"));
|
var message = driver.FindElement(By.Id("message"));
|
||||||
var value = message.Text;
|
var value = message.Text;
|
||||||
|
*/
|
||||||
driver.Quit();
|
driver.Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using Yavsc.Models;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using Yavsc.Server.Models.IT.SourceCode;
|
using Yavsc.Server.Models.IT.SourceCode;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using isnd.tests;
|
using Yavsc.Tests;
|
||||||
using Yavsc.Server.Models.IT;
|
using Yavsc.Server.Models.IT;
|
||||||
|
|
||||||
namespace yavscTests
|
namespace yavscTests
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using isnd.tests;
|
using Yavsc.Tests;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using IdentityModel.Client;
|
using IdentityModel.Client;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using isnd.tests;
|
using Yavsc.Tests;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace yavscTests.Mandatory;
|
namespace yavscTests.Mandatory;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using isnd.tests;
|
using Yavsc.Tests;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace yavscTests.Mandatory
|
namespace yavscTests.Mandatory
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using isnd.tests;
|
using Yavsc.Tests;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
@ -15,15 +14,15 @@ using Microsoft.Extensions.Options;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using Yavsc;
|
|
||||||
using Yavsc.Extensions;
|
using Yavsc.Extensions;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Server.Helpers;
|
||||||
using Client = IdentityServer8.EntityFramework.Entities.Client;
|
using Client = IdentityServer8.EntityFramework.Entities.Client;
|
||||||
|
|
||||||
namespace isnd.tests
|
namespace Yavsc.Tests
|
||||||
{
|
{
|
||||||
|
|
||||||
[CollectionDefinition("Web server collection")]
|
[CollectionDefinition("Yavsc Server")]
|
||||||
public class WebServerFixture : IDisposable
|
public class WebServerFixture : IDisposable
|
||||||
{
|
{
|
||||||
private static readonly Lazy<X509Certificate2> _selfSignedCertificate = new Lazy<X509Certificate2>(CreateSelfSignedCertificate);
|
private static readonly Lazy<X509Certificate2> _selfSignedCertificate = new Lazy<X509Certificate2>(CreateSelfSignedCertificate);
|
||||||
|
|
@ -116,33 +115,19 @@ namespace isnd.tests
|
||||||
|
|
||||||
public async Task SetupHost()
|
public async Task SetupHost()
|
||||||
{
|
{
|
||||||
|
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||||
|
// Set ContentRoot to the Yavsc.Org project directory so WebRootPath resolves correctly
|
||||||
|
var cwd = System.IO.Directory.GetCurrentDirectory();
|
||||||
|
var yavscOrgPath = Path.GetFullPath(
|
||||||
|
Path.Combine(cwd,
|
||||||
|
"../../../../../src/Yavsc.Org"));
|
||||||
|
Environment.CurrentDirectory = yavscOrgPath;
|
||||||
var builder = WebApplication.CreateBuilder();
|
var builder = WebApplication.CreateBuilder();
|
||||||
builder.Environment.EnvironmentName = "Development";
|
builder.Environment.EnvironmentName = "Development";
|
||||||
// Set ContentRoot to the Yavsc.Org project directory so WebRootPath resolves correctly.
|
|
||||||
// Walk up from BaseDir until we find a directory that contains src/Yavsc.Org. This is
|
|
||||||
// robust against the test runner changing the current working directory.
|
|
||||||
var testAssemblyLocation = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
string yavscOrgPath = "";
|
|
||||||
for (var d = new DirectoryInfo(testAssemblyLocation); d != null; d = d.Parent)
|
|
||||||
{
|
|
||||||
var candidate = Path.Combine(d.FullName, "src/Yavsc.Org");
|
|
||||||
if (Directory.Exists(candidate))
|
|
||||||
{
|
|
||||||
yavscOrgPath = candidate;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(yavscOrgPath))
|
|
||||||
throw new InvalidOperationException(
|
|
||||||
$"Could not locate src/Yavsc.Org by walking up from {testAssemblyLocation}");
|
|
||||||
builder.Environment.ContentRootPath = yavscOrgPath;
|
builder.Environment.ContentRootPath = yavscOrgPath;
|
||||||
|
|
||||||
builder.Configuration
|
builder.AddConfiguration("org").AddInMemoryCollection(new Dictionary<string, string?>
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
|
|
||||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
||||||
{
|
{
|
||||||
[$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory"
|
[$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory"
|
||||||
});
|
});
|
||||||
|
|
@ -176,23 +161,12 @@ namespace isnd.tests
|
||||||
EnsureUser(TestingUserName, TestingUserPassword, TestingUserEmail, migrationScope);
|
EnsureUser(TestingUserName, TestingUserPassword, TestingUserEmail, migrationScope);
|
||||||
AddAuthorizedClient(migrationScope, TestClientId, TestClientSecret);
|
AddAuthorizedClient(migrationScope, TestClientId, TestClientSecret);
|
||||||
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
|
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
|
||||||
}
|
|
||||||
|
|
||||||
// Seed IdentityServer ConfigurationDbContext with API resources and scopes
|
|
||||||
using (var configScope = _app.Services.CreateScope())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var configDbContext = configScope.ServiceProvider.GetService<IdentityServer8.EntityFramework.DbContexts.ConfigurationDbContext>();
|
|
||||||
if (configDbContext != null)
|
|
||||||
{
|
|
||||||
configDbContext.Database.EnsureCreated();
|
|
||||||
|
|
||||||
// Add test API scope if it doesn't exist
|
// Add test API scope if it doesn't exist
|
||||||
var testScope = configDbContext.ApiScopes.FirstOrDefault(s => s.Name == "test");
|
var testScope = db.ApiScopes.FirstOrDefault(s => s.Name == "test");
|
||||||
if (testScope == null)
|
if (testScope == null)
|
||||||
{
|
{
|
||||||
configDbContext.ApiScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiScope
|
db.ApiScopes.Add(new IdentityServer8.EntityFramework.Entities.ApiScope
|
||||||
{
|
{
|
||||||
Name = "test",
|
Name = "test",
|
||||||
Enabled = true,
|
Enabled = true,
|
||||||
|
|
@ -219,20 +193,15 @@ namespace isnd.tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
configDbContext.ApiResources.Add(apiResource);
|
db.ApiResources.Add(apiResource);
|
||||||
configDbContext.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_sharedLogger?.LogWarning($"Failed to seed ConfigurationDbContext: {ex.Message}");
|
|
||||||
// Don't fail the fixture if seeding fails
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _app!.ConfigurePipeline();
|
|
||||||
_app.UseSession();
|
|
||||||
|
_app = await _app.ConfigurePipeline();
|
||||||
|
|
||||||
await _app.StartAsync();
|
await _app.StartAsync();
|
||||||
|
|
||||||
_sharedServices = _app.Services;
|
_sharedServices = _app.Services;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue