b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose Sumit Bose <sbose@redhat.com>
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose Copyright (C) 2017 Red Hat
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose Test for the MIT Kerberos localauth plugin
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose This program is free software; you can redistribute it and/or modify
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose it under the terms of the GNU General Public License as published by
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose the Free Software Foundation; either version 3 of the License, or
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose (at your option) any later version.
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose This program is distributed in the hope that it will be useful,
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose GNU General Public License for more details.
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose You should have received a copy of the GNU General Public License
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Boseenum nss_status _nss_sss_getpwnam_r(const char *name, struct passwd *result,
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose test_data = sss_mock_ptr_type(struct _nss_sss_getpwnam_r_test_data *);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Boselocalauth_sssd_initvt(krb5_context context, int maj_ver, int min_ver,
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = localauth_sssd_initvt(NULL, 0, 0, (krb5_plugin_vtable) &vtable);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = localauth_sssd_initvt(NULL, 1, 1, (krb5_plugin_vtable) &vtable);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_SUCCESS}, { 1234, NULL, NSS_STATUS_SUCCESS},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose /* second _nss_sss_getpwnam_r() is never called because the first one
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz * already returned an error */
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_NOTFOUND}, { 0, NULL, 0},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_SUCCESS}, { 1234, NULL, NSS_STATUS_NOTFOUND},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_SUCCESS}, { 4321, NULL, NSS_STATUS_SUCCESS},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose /* second _nss_sss_getpwnam_r() is never called because the first one
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz * already returned an error */
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_UNAVAIL}, { 0, NULL, 0},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose {{ 1234, NULL, NSS_STATUS_SUCCESS}, { 1234, NULL, NSS_STATUS_TRYAGAIN},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = localauth_sssd_initvt(krb5_ctx, 1, 1, (krb5_plugin_vtable) &vtable);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = krb5_parse_name(krb5_ctx, "name@REALM", &princ);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose will_return(_nss_sss_getpwnam_r, &test_data[c].d1);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose will_return(_nss_sss_getpwnam_r, &test_data[c].d2);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = vtable.userok(krb5_ctx, NULL, princ, "name");
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose { { 0, "my_name", NSS_STATUS_NOTFOUND}, KRB5_LNAME_NOTRANS},
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose { { 0, NULL, 0 } , 0}
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = localauth_sssd_initvt(krb5_ctx, 1, 1, (krb5_plugin_vtable) &vtable);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = krb5_parse_name(krb5_ctx, "name@REALM", &princ);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose will_return(_nss_sss_getpwnam_r, &test_data[c].d);
b4e45531b3e98efce868d8a01ebd2dbe54348217Sumit Bose kerr = vtable.an2ln(krb5_ctx, NULL, NULL, NULL, princ, &lname);