MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / StartAsync

Method StartAsync

dotnet/test/testing.webserver/AppServer.cs:46–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44 public UrlBuilder Urls { get; private set; } = null!;
45
46 public async Task<(string HttpUrl, string HttpsUrl)> StartAsync()
47 {
48 var builder = WebApplication.CreateSlimBuilder();
49
50 var certificate = GenerateSelfSignedCertificate();
51
52 builder.WebHost.ConfigureKestrel(options =>
53 {
54 options.Listen(IPAddress.Loopback, 0);
55 options.Listen(IPAddress.Loopback, 0, listenOptions =>
56 {
57 listenOptions.UseHttps(certificate);
58 });
59 });
60 builder.Services.AddDirectoryBrowser();
61
62 _app = builder.Build();
63
64 MapEndpoints(_app);
65 MapEndpoints(_app.MapGroup("/common"));
66
67 if (Directory.Exists(_webContentRoot))
68 {
69 var fileProvider = new PhysicalFileProvider(_webContentRoot);
70
71 _app.UseStaticFiles(new StaticFileOptions
72 {
73 FileProvider = fileProvider,
74 ServeUnknownFileTypes = true
75 });
76
77 _app.UseStaticFiles(new StaticFileOptions
78 {
79 FileProvider = fileProvider,
80 RequestPath = "/common",
81 ServeUnknownFileTypes = true
82 });
83
84 _app.UseDirectoryBrowser(new DirectoryBrowserOptions
85 {
86 FileProvider = fileProvider
87 });
88
89 _app.UseDirectoryBrowser(new DirectoryBrowserOptions
90 {
91 FileProvider = fileProvider,
92 RequestPath = "/common"
93 });
94 }
95
96 await _app.StartAsync();
97
98 int httpPort = new Uri(_app.Urls.First(u => u.StartsWith("http://"))).Port;
99 int httpsPort = new Uri(_app.Urls.First(u => u.StartsWith("https://"))).Port;
100
101 var httpUrl = $"http://localhost:{httpPort}";
102 var httpsUrl = $"https://localhost:{httpsPort}";
103

Callers 2

RunBeforeAnyTestAsyncMethod · 0.45
RunBeforeAnyTestAsyncMethod · 0.45

Calls 2

ListenMethod · 0.80
BuildMethod · 0.80

Tested by

no test coverage detected