fix(gateway): detect Certificate:Thumbprint and cover more KestrelTlsInspector cases
This commit is contained in:
@@ -31,4 +31,31 @@ public sealed class KestrelTlsInspectorTests
|
||||
[Fact]
|
||||
public void RequiresGeneratedCertificate_False_WhenNoEndpointsConfigured()
|
||||
=> Assert.False(KestrelTlsInspector.RequiresGeneratedCertificate(Config()));
|
||||
|
||||
[Fact]
|
||||
public void RequiresGeneratedCertificate_False_WhenHttpsEndpointHasThumbprintOnly()
|
||||
=> Assert.False(KestrelTlsInspector.RequiresGeneratedCertificate(
|
||||
Config(
|
||||
("Kestrel:Endpoints:Https:Url", "https://0.0.0.0:5120"),
|
||||
("Kestrel:Endpoints:Https:Certificate:Thumbprint", "AABBCCDDEEFF00112233445566778899AABBCCDD"))));
|
||||
|
||||
[Fact]
|
||||
public void RequiresGeneratedCertificate_False_WhenHttpsEndpointHasSubjectOnly()
|
||||
=> Assert.False(KestrelTlsInspector.RequiresGeneratedCertificate(
|
||||
Config(
|
||||
("Kestrel:Endpoints:Https:Url", "https://0.0.0.0:5120"),
|
||||
("Kestrel:Endpoints:Https:Certificate:Subject", "CN=myserver"))));
|
||||
|
||||
[Fact]
|
||||
public void RequiresGeneratedCertificate_True_WhenHttpsUrlIsUppercase()
|
||||
=> Assert.True(KestrelTlsInspector.RequiresGeneratedCertificate(
|
||||
Config(("Kestrel:Endpoints:Https:Url", "HTTPS://0.0.0.0:5120"))));
|
||||
|
||||
[Fact]
|
||||
public void RequiresGeneratedCertificate_True_WhenMixedEndpointsAndOneHttpsHasNoCert()
|
||||
=> Assert.True(KestrelTlsInspector.RequiresGeneratedCertificate(
|
||||
Config(
|
||||
("Kestrel:Endpoints:Grpc:Url", "https://0.0.0.0:5120"),
|
||||
("Kestrel:Endpoints:Grpc:Certificate:Thumbprint", "AABBCCDDEEFF00112233445566778899AABBCCDD"),
|
||||
("Kestrel:Endpoints:Dashboard:Url", "https://0.0.0.0:5130"))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user