Line data Source code
1 : /*
2 : * gnome-keyring
3 : *
4 : * Copyright (C) 2010 Stefan Walter
5 : *
6 : * This program is free software; you can redistribute it and/or modify
7 : * it under the terms of the GNU Lesser General Public License as
8 : * published by the Free Software Foundation; either version 2.1 of
9 : * the License, or (at your option) any later version.
10 : *
11 : * This program is distributed in the hope that it will be useful, but
12 : * WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : * Lesser General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU Lesser General Public
17 : * License along with this program; if not, see
18 : * <http://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include "config.h"
22 :
23 : #include "egg/egg-secure-memory.h"
24 : #include "egg/egg-testing.h"
25 :
26 : #include "wrap-layer/gkm-wrap-layer.h"
27 : #include "wrap-layer/gkm-wrap-login.h"
28 :
29 : #include <glib-object.h>
30 :
31 : static void
32 1 : test_did_unlock_fail (void)
33 : {
34 : gchar *password;
35 : gboolean ret;
36 :
37 1 : gkm_wrap_layer_mark_login_unlock_failure ("failure");
38 :
39 1 : ret = gkm_wrap_login_did_unlock_fail ();
40 1 : g_assert (ret == TRUE);
41 :
42 1 : password = gkm_wrap_login_steal_failed_password ();
43 1 : g_assert_cmpstr (password, ==, "failure");
44 1 : egg_secure_strfree (password);
45 :
46 1 : gkm_wrap_layer_mark_login_unlock_failure ("failed password");
47 1 : gkm_wrap_layer_mark_login_unlock_failure ("failed password");
48 1 : gkm_wrap_layer_mark_login_unlock_success ();
49 :
50 1 : ret = gkm_wrap_login_did_unlock_fail ();
51 1 : g_assert (ret == FALSE);
52 1 : }
53 :
54 : int
55 1 : main (int argc, char **argv)
56 : {
57 : #if !GLIB_CHECK_VERSION(2,35,0)
58 : g_type_init ();
59 : #endif
60 1 : g_test_init (&argc, &argv, NULL);
61 :
62 1 : g_test_add_func ("/wrap-layer/login-hints/did_unlock_fail", test_did_unlock_fail);
63 :
64 1 : return egg_tests_run_in_thread_with_loop ();
65 : }
|