public void GetPrivateKeyFromPemFile_ValidRSAFile_ExpectedNotNullResult() { // Arrange var pemFilePath = "example_rsa.pem"; // Act var result = RSAUtilities.GetPrivateKeyFromPemFile(pemFilePath); // Assert Assert.IsNotNull(result); }
/// <summary> /// Initializes a new instance of the Tikkie API configuration. /// </summary> /// <param name="apiKey">The API key that allows the usage of the Tikkie API</param> /// <param name="privateKeyPath">The directory path where the RSA private key PEM file can be found.</param> /// <param name="useTestEnvironment">True if the connexion is made to the development/sandbox Tikkie API environment. False by default.</param> /// <exception cref="ArgumentException">If the API Key is null or empty.</exception> /// <exception cref="FileNotFoundException">If the private key pem file doesn't exist in the specified location.</exception> /// <exception cref="InvalidDataException">If the RSA private key PEM file cannot be read.</exception> public TikkieConfiguration(string apiKey, string privateKeyPath, bool useTestEnvironment = false) { ApiKey = string.IsNullOrEmpty(apiKey) ? throw new ArgumentException(nameof(apiKey)) : apiKey; RSAKey = RSAUtilities.GetPrivateKeyFromPemFile(privateKeyPath); IsTestEnvironment = useTestEnvironment; }
public void GetPrivateKeyFromPemFile_FileIsNotAnRSAFile_ExpectedInvalidDataException() { // Arrange + Act + Assert Assert.Throws <InvalidDataException>(() => RSAUtilities.GetPrivateKeyFromPemFile("non_rsa.pem")); }
public void GetPrivateKeyFromPemFile_FileDoesNotExist_ExpectedFileNotFoundException() { // Arrange + Act + Assert Assert.Throws <FileNotFoundException>(() => RSAUtilities.GetPrivateKeyFromPemFile("non/existing/path/file.pem")); }