ctdb-client: Add client code for disable/enable controls
[samba.git] / libcli / smb / test_util_translate.c
blobb300af52c0975b2926a8e1dd9bf53f58e9c13577
1 /*
2 * Unix SMB/CIFS implementation.
4 * Copyright (C) 2020 Andreas Schneider <asn@samba.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <stdarg.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <setjmp.h>
24 #include <cmocka.h>
26 #include "lib/replace/replace.h"
27 #include <talloc.h>
29 #include "libcli/smb/util.c"
31 static void test_smb_signing_setting_translate(void **state)
33 enum smb_signing_setting signing_state;
35 signing_state = smb_signing_setting_translate("wurst");
36 assert_int_equal(signing_state, SMB_SIGNING_REQUIRED);
38 signing_state = smb_signing_setting_translate("off");
39 assert_int_equal(signing_state, SMB_SIGNING_OFF);
41 signing_state = smb_signing_setting_translate("if_required");
42 assert_int_equal(signing_state, SMB_SIGNING_IF_REQUIRED);
44 signing_state = smb_signing_setting_translate("mandatory");
45 assert_int_equal(signing_state, SMB_SIGNING_REQUIRED);
49 static void test_smb_encryption_setting_translate(void **state)
51 enum smb_encryption_setting encryption_state;
53 encryption_state = smb_encryption_setting_translate("wurst");
54 assert_int_equal(encryption_state, SMB_ENCRYPTION_REQUIRED);
56 encryption_state = smb_encryption_setting_translate("off");
57 assert_int_equal(encryption_state, SMB_ENCRYPTION_OFF);
59 encryption_state = smb_encryption_setting_translate("if_required");
60 assert_int_equal(encryption_state, SMB_ENCRYPTION_IF_REQUIRED);
62 encryption_state = smb_encryption_setting_translate("mandatory");
63 assert_int_equal(encryption_state, SMB_ENCRYPTION_REQUIRED);
67 int main(int argc, char *argv[])
69 int rc;
70 const struct CMUnitTest tests[] = {
71 cmocka_unit_test(test_smb_signing_setting_translate),
72 cmocka_unit_test(test_smb_encryption_setting_translate),
75 if (argc == 2) {
76 cmocka_set_test_filter(argv[1]);
78 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
80 rc = cmocka_run_group_tests(tests, NULL, NULL);
82 return rc;