@@ -43,91 +43,91 @@ public class OtlpMtlsCertificateManagerTests
4343 [ Xunit . Fact ]
4444 public void LoadClientCertificate_ThrowsFileNotFoundException_WhenCertificateFileDoesNotExist ( )
4545 {
46- var exception = Xunit . Assert . Throws < System . IO . FileNotFoundException > ( ( ) =>
47- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate (
46+ var exception = Xunit . Assert . Throws < FileNotFoundException > ( ( ) =>
47+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate (
4848 "/nonexistent/client.crt" ,
4949 "/nonexistent/client.key" ) ) ;
5050
51- Xunit . Assert . Contains ( "Certificate file not found" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
52- Xunit . Assert . Contains ( "/nonexistent/client.crt" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
51+ Xunit . Assert . Contains ( "Certificate file not found" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
52+ Xunit . Assert . Contains ( "/nonexistent/client.crt" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
5353 }
5454
5555 [ Xunit . Fact ]
5656 public void LoadClientCertificate_ThrowsFileNotFoundException_WhenPrivateKeyFileDoesNotExist ( )
5757 {
58- var tempCertFile = System . IO . Path . GetTempFileName ( ) ;
59- System . IO . File . WriteAllText ( tempCertFile , TestCertPem ) ;
58+ var tempCertFile = Path . GetTempFileName ( ) ;
59+ File . WriteAllText ( tempCertFile , TestCertPem ) ;
6060
6161 try
6262 {
63- var exception = Xunit . Assert . Throws < System . IO . FileNotFoundException > ( ( ) =>
64- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate (
63+ var exception = Xunit . Assert . Throws < FileNotFoundException > ( ( ) =>
64+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate (
6565 tempCertFile ,
6666 "/nonexistent/client.key" ) ) ;
6767
68- Xunit . Assert . Contains ( "Private key file not found" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
69- Xunit . Assert . Contains ( "/nonexistent/client.key" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
68+ Xunit . Assert . Contains ( "Private key file not found" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
69+ Xunit . Assert . Contains ( "/nonexistent/client.key" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
7070 }
7171 finally
7272 {
73- System . IO . File . Delete ( tempCertFile ) ;
73+ File . Delete ( tempCertFile ) ;
7474 }
7575 }
7676
7777 [ Xunit . Fact ]
7878 public void LoadCaCertificate_ThrowsFileNotFoundException_WhenTrustStoreFileDoesNotExist ( )
7979 {
80- var exception = Xunit . Assert . Throws < System . IO . FileNotFoundException > ( ( ) =>
81- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadCaCertificate ( "/nonexistent/ca.crt" ) ) ;
80+ var exception = Xunit . Assert . Throws < FileNotFoundException > ( ( ) =>
81+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadCaCertificate ( "/nonexistent/ca.crt" ) ) ;
8282
83- Xunit . Assert . Contains ( "CA certificate file not found" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
84- Xunit . Assert . Contains ( "/nonexistent/ca.crt" , exception . Message , System . StringComparison . OrdinalIgnoreCase ) ;
83+ Xunit . Assert . Contains ( "CA certificate file not found" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
84+ Xunit . Assert . Contains ( "/nonexistent/ca.crt" , exception . Message , StringComparison . OrdinalIgnoreCase ) ;
8585 }
8686
8787 [ Xunit . Fact ]
8888 public void LoadClientCertificate_ThrowsInvalidOperationException_WhenCertificateFileIsEmpty ( )
8989 {
90- var tempCertFile = System . IO . Path . GetTempFileName ( ) ;
91- var tempKeyFile = System . IO . Path . GetTempFileName ( ) ;
92- System . IO . File . WriteAllText ( tempCertFile , string . Empty ) ;
93- System . IO . File . WriteAllText ( tempKeyFile , string . Empty ) ;
90+ var tempCertFile = Path . GetTempFileName ( ) ;
91+ var tempKeyFile = Path . GetTempFileName ( ) ;
92+ File . WriteAllText ( tempCertFile , string . Empty ) ;
93+ File . WriteAllText ( tempKeyFile , string . Empty ) ;
9494
9595 try
9696 {
97- var exception = Xunit . Assert . Throws < System . InvalidOperationException > ( ( ) =>
98- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate ( tempCertFile , tempKeyFile ) ) ;
97+ var exception = Xunit . Assert . Throws < InvalidOperationException > ( ( ) =>
98+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadClientCertificate ( tempCertFile , tempKeyFile ) ) ;
9999
100100 Xunit . Assert . Contains (
101101 "Failed to load client certificate" ,
102102 exception . Message ,
103- System . StringComparison . OrdinalIgnoreCase ) ;
103+ StringComparison . OrdinalIgnoreCase ) ;
104104 }
105105 finally
106106 {
107- System . IO . File . Delete ( tempCertFile ) ;
108- System . IO . File . Delete ( tempKeyFile ) ;
107+ File . Delete ( tempCertFile ) ;
108+ File . Delete ( tempKeyFile ) ;
109109 }
110110 }
111111
112112 [ Xunit . Fact ]
113113 public void LoadCaCertificate_ThrowsInvalidOperationException_WhenTrustStoreFileIsEmpty ( )
114114 {
115- var tempTrustStoreFile = System . IO . Path . GetTempFileName ( ) ;
116- System . IO . File . WriteAllText ( tempTrustStoreFile , string . Empty ) ;
115+ var tempTrustStoreFile = Path . GetTempFileName ( ) ;
116+ File . WriteAllText ( tempTrustStoreFile , string . Empty ) ;
117117
118118 try
119119 {
120- var exception = Xunit . Assert . Throws < System . InvalidOperationException > ( ( ) =>
121- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadCaCertificate ( tempTrustStoreFile ) ) ;
120+ var exception = Xunit . Assert . Throws < InvalidOperationException > ( ( ) =>
121+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . LoadCaCertificate ( tempTrustStoreFile ) ) ;
122122
123123 Xunit . Assert . Contains (
124124 "Failed to load CA certificate" ,
125125 exception . Message ,
126- System . StringComparison . OrdinalIgnoreCase ) ;
126+ StringComparison . OrdinalIgnoreCase ) ;
127127 }
128128 finally
129129 {
130- System . IO . File . Delete ( tempTrustStoreFile ) ;
130+ File . Delete ( tempTrustStoreFile ) ;
131131 }
132132 }
133133
@@ -138,7 +138,7 @@ public void ValidateCertificateChain_DoesNotThrow_WithValidCertificate()
138138 using var cert = CreateSelfSignedCertificate ( ) ;
139139
140140 // Should not throw for self-signed certificate with proper validation
141- var result = OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "test certificate" ) ;
141+ var result = OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "test certificate" ) ;
142142
143143 // For self-signed certificates, validation may fail, but method should not throw
144144 Xunit . Assert . True ( result || ! result ) ; // Just check that it returns a boolean
@@ -150,13 +150,13 @@ public void ValidateCertificateChain_ThrowsInvalidOperationException_WhenCertifi
150150 // Create an expired certificate for testing
151151 using var cert = CreateExpiredCertificate ( ) ;
152152
153- var exception = Xunit . Assert . Throws < System . InvalidOperationException > ( ( ) =>
154- OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "expired certificate" ) ) ;
153+ var exception = Xunit . Assert . Throws < InvalidOperationException > ( ( ) =>
154+ OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "expired certificate" ) ) ;
155155
156156 Xunit . Assert . Contains (
157157 "Certificate chain validation failed" ,
158158 exception . Message ,
159- System . StringComparison . OrdinalIgnoreCase ) ;
159+ StringComparison . OrdinalIgnoreCase ) ;
160160 }
161161
162162 [ Xunit . Fact ]
@@ -166,7 +166,7 @@ public void ValidateCertificateChain_ReturnsResult_WithValidCertificate()
166166 using var cert = CreateSelfSignedCertificate ( ) ;
167167
168168 // Should return a boolean result
169- var result = OpenTelemetry . Exporter . OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "test certificate" ) ;
169+ var result = OpenTelemetryProtocol . Implementation . OtlpMtlsCertificateManager . ValidateCertificateChain ( cert , "test certificate" ) ;
170170
171171 // The result can be true or false, but the method should not throw
172172 Xunit . Assert . True ( result || ! result ) ;
@@ -182,8 +182,8 @@ private static System.Security.Cryptography.X509Certificates.X509Certificate2 Cr
182182 System . Security . Cryptography . RSASignaturePadding . Pkcs1 ) ;
183183
184184 var cert = req . CreateSelfSigned (
185- System . DateTimeOffset . UtcNow . AddDays ( - 1 ) ,
186- System . DateTimeOffset . UtcNow . AddDays ( 30 ) ) ;
185+ DateTimeOffset . UtcNow . AddDays ( - 1 ) ,
186+ DateTimeOffset . UtcNow . AddDays ( 30 ) ) ;
187187 return cert ;
188188 }
189189
@@ -198,8 +198,8 @@ private static System.Security.Cryptography.X509Certificates.X509Certificate2 Cr
198198
199199 // Create a certificate that expired yesterday
200200 var cert = req . CreateSelfSigned (
201- System . DateTimeOffset . UtcNow . AddDays ( - 30 ) ,
202- System . DateTimeOffset . UtcNow . AddDays ( - 1 ) ) ;
201+ DateTimeOffset . UtcNow . AddDays ( - 30 ) ,
202+ DateTimeOffset . UtcNow . AddDays ( - 1 ) ) ;
203203 return cert ;
204204 }
205205}
0 commit comments