/*
 * Copyright (c) eHealth
 */

#region Header

/*
 * Copyright (c) eHealth
 */

#endregion Header

/**
 * IntegrationTest for TrustStoreUpdater
 */
namespace be.fgov.ehealth.technicalconnector.bootstrap.tsl.signature {

	using be.ehealth.technicalconnector.config;
	using be.ehealth.technicalconnector.exception;
	using NUnit.Framework;
	using java.lang;
	using be.ehealth.technicalconnector.utils;
	using be.fgov.ehealth.technicalconnector.bootstrap.tsl.signature;
	
	[TestFixture]
	public class TrustStoreUpdaterIntegrationTest
	{
		#region Methods
			
		[Test]
		public void offline()
		{
			ConfigFactory.setConfigLocation("./be.ehealth.technicalconnector-generic.properties");
			string oldValue = ConfigFactory.getConfigValidator().getProperty("KEYSTORE_DIR");
			ConfigFactory.getConfigValidator().setProperty("KEYSTORE_DIR", "./P12/acc/");
			TrustServiceStatusListSignatureVerifier.reloadCertStore();
			Assert.IsTrue(TrustServiceStatusListSignatureVerifier.isValid(ConnectorIOUtils.getResourceAsString("./tsl-samples/acc/tsl-ehpbe-person.xml")));
			ConfigFactory.getConfigValidator().setProperty("KEYSTORE_DIR", oldValue);
			TrustServiceStatusListSignatureVerifier.reloadCertStore();
			
		}
		
		[Test]
		public void online()
		{
			ConfigFactory.setConfigLocation("./be.ehealth.technicalconnector-generic.properties");
			ConfigFactory.getConfigValidator().setProperty("KEYSTORE_DIR", "./P12/acc/");
			Assert.IsTrue(TrustServiceStatusListSignatureVerifier.isValid(ConnectorIOUtils.getResourceAsString("https://tsl-acpt.ehealth.fgov.be/tsl-ehpbe-transport.xml")));
		}

		#endregion Methods
	}
}
