m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-14 15:10:33 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-14 15:10:33 +0100
commit95436ff2914f3310f07195583c50076479384ccd (patch)
tree55f0f5bb4b27be5bc81023020bb532b4a40ce620
parent17200906a037f4d323573e56117f0aaf5b6197e6 (diff)
Add validation test
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/QuerySignerApiImplementationTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/QuerySignerApiImplementationTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/QuerySignerApiImplementationTest.java
index e99cccb..70aad63 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/QuerySignerApiImplementationTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/QuerySignerApiImplementationTest.java
@@ -1,4 +1,49 @@
package pl.edu.mimuw.cloudatlas.agent;
+import org.junit.Test;
+import pl.edu.mimuw.cloudatlas.querysigner.KeyUtils;
+import pl.edu.mimuw.cloudatlas.querysigner.QueryData;
+import pl.edu.mimuw.cloudatlas.querysigner.QuerySigner;
+import pl.edu.mimuw.cloudatlas.querysigner.QuerySignerApiImplementation;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
public class QuerySignerApiImplementationTest {
+
+ @Test
+ public void testQueryVerification() {
+ QuerySignerApiImplementation queryApi;
+
+ try {
+ String publicKeyFile = "build/tmp/query_signer.pub";
+ String privateKeyFile = "build/tmp/query_signer";
+ PublicKey publicKey = KeyUtils.getPublicKey(publicKeyFile);
+ PrivateKey privateKey = KeyUtils.getPrivateKey(privateKeyFile);
+ queryApi = new QuerySignerApiImplementation(publicKey, privateKey);
+ QueryData signedQuery = queryApi.signInstallQuery("&a", "SELECT 1 AS ONE");
+ QuerySignerApiImplementation.validateInstallQuery("&a", signedQuery, publicKey);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (NoSuchPaddingException e) {
+ e.printStackTrace();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ } catch (InvalidKeyException e) {
+ e.printStackTrace();
+ } catch (IllegalBlockSizeException e) {
+ e.printStackTrace();
+ } catch (BadPaddingException e) {
+ e.printStackTrace();
+ } catch (QuerySigner.InvalidQueryException e) {
+ e.printStackTrace();
+ }
+
+ }
}