mconnect - KDE Connect protocol implementation in Vala/C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
975 B

  1. using Mconn;
  2. void test_simple() {
  3. string file_path = "/tmp/test-key-vala.pem";
  4. FileUtils.remove(file_path);
  5. string pubkey1;
  6. string pubkey2;
  7. {
  8. assert(FileUtils.test(file_path, FileTest.EXISTS) == false);
  9. var c = new Crypt.for_key_path(file_path);
  10. assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
  11. pubkey1 = c.get_public_key_pem();
  12. assert(pubkey1 != null);
  13. }
  14. // file should still exist
  15. assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
  16. {
  17. assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
  18. var c = new Crypt.for_key_path(file_path);
  19. assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
  20. pubkey2 = c.get_public_key_pem();
  21. assert(pubkey2 != null);
  22. }
  23. debug("public key1:\n%s", pubkey1);
  24. debug("public key2:\n%s", pubkey2);
  25. assert(pubkey1 == pubkey2);
  26. }
  27. public static void main(string[] args) {
  28. Test.init(ref args);
  29. Test.add_func("/mconn-crypt-vala/simple", () => {
  30. test_simple();
  31. });
  32. Test.run();
  33. }