Browse Source

mconn-crypt-vala-test: mconn-crypt tests in Vala

bboozzoo/device-cache
Maciek Borzecki 10 years ago
parent
commit
13c4a1dc25
2 changed files with 50 additions and 2 deletions
  1. +9
    -2
      Makefile.am
  2. +41
    -0
      test/mconn-crypt-vala-test.vala

+ 9
- 2
Makefile.am View File

@ -1,6 +1,7 @@
bin_PROGRAMS = mconnect bin_PROGRAMS = mconnect
noinst_PROGRAMS = test-mconn-crypt
noinst_PROGRAMS = test-mconn-crypt \
test-mconn-crypt-vala
mconnect_SOURCES = src/main.vala \ mconnect_SOURCES = src/main.vala \
src/discovery.vala \ src/discovery.vala \
@ -19,5 +20,11 @@ test_mconn_crypt_SOURCES = test/mconn-crypt-test.c \
test_mconn_crypt_LDADD = $(MCONNECT_LIBS) test_mconn_crypt_LDADD = $(MCONNECT_LIBS)
test_mconn_crypt_CFLAGS = $(MCONNECT_CFLAGS) -Isrc test_mconn_crypt_CFLAGS = $(MCONNECT_CFLAGS) -Isrc
VALAFLAGS = $(MCONNECT_VALAFLAGS)
test_mconn_crypt_vala_SOURCES = test/mconn-crypt-vala-test.vala \
src/mconn-crypt.c \
src/mconn-crypt.h
test_mconn_crypt_vala_LDADD = $(MCONNECT_LIBS)
test_mconn_crypt_vala_CFLAGS = $(MCONNECT_CFLAGS) -Isrc
VALAFLAGS = $(MCONNECT_VALAFLAGS) --vapidir=src --pkg=mconn-crypt

+ 41
- 0
test/mconn-crypt-vala-test.vala View File

@ -0,0 +1,41 @@
using MConn;
void test_simple() {
string file_path = "/tmp/test-key-vala.pem";
FileUtils.remove(file_path);
string pubkey1;
string pubkey2;
{
assert(FileUtils.test(file_path, FileTest.EXISTS) == false);
var c = new Crypt.for_key_path(file_path);
assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
pubkey1 = c.get_public_key_pem();
assert(pubkey1 != null);
}
// file should still exist
assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
{
assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
var c = new Crypt.for_key_path(file_path);
assert(FileUtils.test(file_path, FileTest.EXISTS) == true);
pubkey2 = c.get_public_key_pem();
assert(pubkey2 != null);
}
debug("public key1:\n%s", pubkey1);
debug("public key2:\n%s", pubkey2);
assert(pubkey1 == pubkey2);
}
public static void main(string[] args) {
Test.init(ref args);
Test.add_func("/mconn-crypt-vala/simple", () => {
test_simple();
});
Test.run();
}

Loading…
Cancel
Save