22using Keyfactor . Orchestrators . Common . Enums ;
33using Keyfactor . Orchestrators . Extensions ;
44using Keyfactor . Orchestrators . Extensions . Interfaces ;
5+
56using Moq ;
67
8+ using Org . BouncyCastle . X509 ;
9+ using Org . BouncyCastle . Utilities . IO . Pem ;
10+
711namespace RemoteFileIntegrationTests
812{
913 public class RFPEMInventoryTests : BaseRFPEMTest
@@ -12,11 +16,11 @@ public class RFPEMInventoryTests : BaseRFPEMTest
1216 public void RFPEM_Inventory_InternalPrivateKey_EmptyStore_Linux_Test0001 ( )
1317 {
1418 InventoryJobConfiguration config = BuildBaseInventoryConfig ( ) ;
15- config . CertificateStoreDetails . ClientMachine = Environment . GetEnvironmentVariable ( " LinuxServer" ) ;
16- config . CertificateStoreDetails . StorePath = Environment . GetEnvironmentVariable ( " LinuxStorePath" ) ;
19+ config . CertificateStoreDetails . ClientMachine = EnvironmentVariables . LinuxServer ;
20+ config . CertificateStoreDetails . StorePath = EnvironmentVariables . LinuxStorePath ;
1721 config . CertificateStoreDetails . Properties = "{}" ;
1822 //config.CertificateStoreDetails.Properties = JsonConvert.SerializeObject(new Dictionary<string, string?>() { { "SeparatePrivateKeyFilePath", Environment.GetEnvironmentVariable("LinuxStorePath") + "Test0001.key" } });
19- config . CertificateStoreDetails . ClientMachine = Environment . GetEnvironmentVariable ( " LinuxServer" ) ;
23+ config . CertificateStoreDetails . ClientMachine = EnvironmentVariables . LinuxServer ;
2024
2125 Mock < IPAMSecretResolver > secretResolver = GetMockSecretResolver ( config ) ;
2226
@@ -30,7 +34,16 @@ public void RFPEM_Inventory_InternalPrivateKey_EmptyStore_Linux_Test0001()
3034 IInvocation invocation = submitInventoryUpdate . Invocations [ 0 ] ;
3135 List < CurrentInventoryItem > inventoryItems = ( List < CurrentInventoryItem > ) invocation . Arguments [ 0 ] ;
3236 Assert . Single ( inventoryItems ) ;
33- inventoryItems [ 0 ] . Certificates ) .
37+
38+ using ( StringReader rdr = new StringReader ( inventoryItems [ 0 ] . Certificates . First ( ) ) )
39+ {
40+ PemReader pemReader = new PemReader ( rdr ) ;
41+ PemObject pemObject = pemReader . ReadPemObject ( ) ;
42+ X509CertificateParser parser = new X509CertificateParser ( ) ;
43+ X509Certificate certificate = parser . ReadCertificate ( pemObject . Content ) ;
44+
45+ Assert . Equal ( EnvironmentVariables . CertificateSubjectDN , certificate . SubjectDN . ToString ( ) ) ;
46+ }
3447
3548 }
3649
@@ -57,8 +70,8 @@ private InventoryJobConfiguration BuildBaseInventoryConfig()
5770 config . CertificateStoreDetails = new CertificateStore ( ) ;
5871 config . JobId = new Guid ( ) ;
5972 config . JobProperties = new Dictionary < string , object > ( ) ;
60- config . ServerUsername = Environment . GetEnvironmentVariable ( " LinuxUserId" ) ;
61- config . ServerPassword = Environment . GetEnvironmentVariable ( " LinuxUserPassword" ) ;
73+ config . ServerUsername = EnvironmentVariables . LinuxUserId ;
74+ config . ServerPassword = EnvironmentVariables . LinuxUserPassword ;
6275
6376 return config ;
6477 }
0 commit comments