|
@@ -1,7 +1,38 @@
|
|
|
#include <glib.h>
|
|
#include <glib.h>
|
|
|
#include <gio/gio.h>
|
|
#include <gio/gio.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
|
+#include <json-glib/json-glib.h>
|
|
|
#include "iridium-crypto.h"
|
|
#include "iridium-crypto.h"
|
|
|
|
|
+#include "iridium-standard-file.h"
|
|
|
|
|
+
|
|
|
|
|
+typedef struct {
|
|
|
|
|
+ JsonParser *parser;
|
|
|
|
|
+} Dump;
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+dump_003_set_up (Dump *dump, gconstpointer user_data)
|
|
|
|
|
+{
|
|
|
|
|
+ GBytes *data;
|
|
|
|
|
+ GError *error = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ data = g_resources_lookup_data ("/net/bloerg/Test/dumps/003.json",
|
|
|
|
|
+ G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
|
|
|
|
+ g_assert_nonnull (data);
|
|
|
|
|
+
|
|
|
|
|
+ dump->parser = json_parser_new_immutable ();
|
|
|
|
|
+
|
|
|
|
|
+ g_assert (json_parser_load_from_data (dump->parser, g_bytes_get_data (data, NULL),
|
|
|
|
|
+ g_bytes_get_size(data), &error));
|
|
|
|
|
+
|
|
|
|
|
+ g_assert_null (error);
|
|
|
|
|
+ g_bytes_unref (data);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+dump_003_tear_down (Dump *dump, gconstpointer user_data)
|
|
|
|
|
+{
|
|
|
|
|
+ g_object_unref (dump->parser);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
test_hexlify (void)
|
|
test_hexlify (void)
|
|
@@ -22,14 +53,18 @@ test_unhexlify (void)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
-test_decrypt_003 (void)
|
|
|
|
|
|
|
+test_decrypt_003_wrong_password (Dump *dump, gconstpointer user_data)
|
|
|
{
|
|
{
|
|
|
- GBytes *data;
|
|
|
|
|
|
|
+ IridiumAuthParams *params;
|
|
|
|
|
+ GList *items;
|
|
|
|
|
+ GError *error;
|
|
|
|
|
|
|
|
- data = g_resources_lookup_data ("/net/bloerg/Test/dumps/003.json",
|
|
|
|
|
- G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
|
|
|
|
- g_assert_nonnull (data);
|
|
|
|
|
- g_bytes_unref (data);
|
|
|
|
|
|
|
+ params = iridium_crypto_auth_params_new ();
|
|
|
|
|
+ iridium_crypto_derive_keys (params, "foo");
|
|
|
|
|
+ items = iridium_standard_file_get_items (dump->parser, params, &error);
|
|
|
|
|
+ g_assert_null (items);
|
|
|
|
|
+ g_assert_nonnull (error);
|
|
|
|
|
+ iridium_crypto_auth_params_free (params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int
|
|
int
|
|
@@ -38,7 +73,9 @@ main (int argc, char * argv[])
|
|
|
g_test_init (&argc, &argv, NULL);
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
g_test_add_func ("/crypto/hexlify", test_hexlify);
|
|
g_test_add_func ("/crypto/hexlify", test_hexlify);
|
|
|
g_test_add_func ("/crypto/unhexlify", test_unhexlify);
|
|
g_test_add_func ("/crypto/unhexlify", test_unhexlify);
|
|
|
- g_test_add_func ("/crypto/decrypt/003", test_decrypt_003);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ g_test_add ("/crypto/decrypt/003/wrong-password", Dump, NULL,
|
|
|
|
|
+ dump_003_set_up, test_decrypt_003_wrong_password, dump_003_tear_down);
|
|
|
|
|
|
|
|
return g_test_run ();
|
|
return g_test_run ();
|
|
|
}
|
|
}
|