From e80fe972e15809cd19ac25ee2ce642510ebf4e51 Mon Sep 17 00:00:00 2001 From: bhashinee Date: Tue, 28 Nov 2023 13:33:56 +0530 Subject: [PATCH] Refactor the code --- ballerina/tests/sign_verify_test.bal | 12 ++++++------ .../ballerina/stdlib/crypto/nativeimpl/Decode.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ballerina/tests/sign_verify_test.bal b/ballerina/tests/sign_verify_test.bal index 2f899580..f80b5872 100644 --- a/ballerina/tests/sign_verify_test.bal +++ b/ballerina/tests/sign_verify_test.bal @@ -252,9 +252,9 @@ isolated function testDecodeRsaPrivateKeyError() returns Error? { }; PrivateKey|Error privateKey = decodeRsaPrivateKeyFromKeyStore(keyStore, "ec-keypair", "ballerina"); if privateKey is Error { - test:assertEquals(privateKey.message(), "Not a valid RSA key."); + test:assertEquals(privateKey.message(), "Not a valid RSA key"); } else { - test:assertFail("Expected error not found."); + test:assertFail("Expected error not found"); } } @@ -266,9 +266,9 @@ isolated function testDecodeEcPrivateKeyError() returns Error? { }; PrivateKey|Error privateKey = decodeEcPrivateKeyFromKeyStore(keyStore, "ballerina", "ballerina"); if privateKey is Error { - test:assertEquals(privateKey.message(), "Not a valid EC key."); + test:assertEquals(privateKey.message(), "Not a valid EC key"); } else { - test:assertFail("Expected error not found."); + test:assertFail("Expected error not found"); } } @@ -280,7 +280,7 @@ isolated function testDecodeEcPublicKeyError() returns Error? { }; PublicKey|Error publicKey = decodeEcPublicKeyFromTrustStore(keyStore, "ballerina"); if publicKey is Error { - test:assertEquals(publicKey.message(), "Not a valid EC public key."); + test:assertEquals(publicKey.message(), "Not a valid EC public key"); } else { test:assertFail("Expected error not found"); } @@ -294,7 +294,7 @@ isolated function testDecodeRsaPublicKeyError() returns Error? { }; PublicKey|Error publicKey = decodeRsaPublicKeyFromTrustStore(keyStore, "ec-keypair"); if publicKey is Error { - test:assertEquals(publicKey.message(), "Not a valid RSA public key."); + test:assertEquals(publicKey.message(), "Not a valid RSA public key"); } else { test:assertFail("Expected error not found"); } diff --git a/native/src/main/java/io/ballerina/stdlib/crypto/nativeimpl/Decode.java b/native/src/main/java/io/ballerina/stdlib/crypto/nativeimpl/Decode.java index fe5fef28..e93425a7 100644 --- a/native/src/main/java/io/ballerina/stdlib/crypto/nativeimpl/Decode.java +++ b/native/src/main/java/io/ballerina/stdlib/crypto/nativeimpl/Decode.java @@ -168,7 +168,7 @@ private static Object buildRsPrivateKeyRecord(PrivateKey privateKey) { if (privateKey.getAlgorithm().equals(Constants.RSA_ALGORITHM)) { return getPrivateKeyRecord(privateKey); } else { - return CryptoUtils.createError("Not a valid RSA key."); + return CryptoUtils.createError("Not a valid RSA key"); } } @@ -185,7 +185,7 @@ private static Object buildEcPrivateKeyRecord(PrivateKey privateKey) { if (privateKey.getAlgorithm().equals(Constants.EC_ALGORITHM)) { return getPrivateKeyRecord(privateKey); } else { - return CryptoUtils.createError("Not a valid EC key."); + return CryptoUtils.createError("Not a valid EC key"); } } @@ -247,7 +247,7 @@ private static Object buildRsaPublicKeyRecord(Certificate certificate) { if (publicKey.getAlgorithm().equals(Constants.RSA_ALGORITHM)) { return getPublicKeyRecord(certificate, certificateBMap, publicKey); } - return CryptoUtils.createError("Not a valid RSA public key."); + return CryptoUtils.createError("Not a valid RSA public key"); } private static Object buildEcPublicKeyRecord(Certificate certificate) { @@ -256,7 +256,7 @@ private static Object buildEcPublicKeyRecord(Certificate certificate) { if (publicKey.getAlgorithm().equals(Constants.EC_ALGORITHM)) { return getPublicKeyRecord(certificate, certificateBMap, publicKey); } - return CryptoUtils.createError("Not a valid EC public key."); + return CryptoUtils.createError("Not a valid EC public key"); } private static Object getPublicKeyRecord(Certificate certificate, BMap certificateBMap,