Line data Source code
1 : /* 2 : * Unix SMB/CIFS implementation. 3 : * 4 : * Copyright (C) 2020 Andreas Schneider <asn@samba.org> 5 : * 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. 10 : * 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. 15 : * 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/>. 18 : */ 19 : 20 : #include <stdarg.h> 21 : #include <stddef.h> 22 : #include <stdint.h> 23 : #include <setjmp.h> 24 : #include <cmocka.h> 25 : 26 : #include "lib/replace/replace.h" 27 : #include <talloc.h> 28 : 29 : #include "libcli/smb/util.c" 30 : 31 1 : static void test_smb_signing_setting_translate(void **state) 32 : { 33 1 : enum smb_signing_setting signing_state; 34 : 35 1 : signing_state = smb_signing_setting_translate("wurst"); 36 1 : assert_int_equal(signing_state, SMB_SIGNING_REQUIRED); 37 : 38 1 : signing_state = smb_signing_setting_translate("off"); 39 1 : assert_int_equal(signing_state, SMB_SIGNING_OFF); 40 : 41 1 : signing_state = smb_signing_setting_translate("if_required"); 42 1 : assert_int_equal(signing_state, SMB_SIGNING_IF_REQUIRED); 43 : 44 1 : signing_state = smb_signing_setting_translate("mandatory"); 45 1 : assert_int_equal(signing_state, SMB_SIGNING_REQUIRED); 46 : 47 1 : } 48 : 49 1 : static void test_smb_encryption_setting_translate(void **state) 50 : { 51 1 : enum smb_encryption_setting encryption_state; 52 : 53 1 : encryption_state = smb_encryption_setting_translate("wurst"); 54 1 : assert_int_equal(encryption_state, SMB_ENCRYPTION_REQUIRED); 55 : 56 1 : encryption_state = smb_encryption_setting_translate("off"); 57 1 : assert_int_equal(encryption_state, SMB_ENCRYPTION_OFF); 58 : 59 1 : encryption_state = smb_encryption_setting_translate("if_required"); 60 1 : assert_int_equal(encryption_state, SMB_ENCRYPTION_IF_REQUIRED); 61 : 62 1 : encryption_state = smb_encryption_setting_translate("mandatory"); 63 1 : assert_int_equal(encryption_state, SMB_ENCRYPTION_REQUIRED); 64 : 65 1 : } 66 : 67 1 : int main(int argc, char *argv[]) 68 : { 69 1 : int rc; 70 1 : const struct CMUnitTest tests[] = { 71 : cmocka_unit_test(test_smb_signing_setting_translate), 72 : cmocka_unit_test(test_smb_encryption_setting_translate), 73 : }; 74 : 75 1 : if (argc == 2) { 76 0 : cmocka_set_test_filter(argv[1]); 77 : } 78 1 : cmocka_set_message_output(CM_OUTPUT_SUBUNIT); 79 : 80 1 : rc = cmocka_run_group_tests(tests, NULL, NULL); 81 : 82 1 : return rc; 83 : }