150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek Copyright (C) 2013 Red Hat
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek SSSD tests: NSS responder tests
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek This program is free software; you can redistribute it and/or modify
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek it under the terms of the GNU General Public License as published by
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek (at your option) any later version.
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek This program is distributed in the hope that it will be useful,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek GNU General Public License for more details.
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek You should have received a copy of the GNU General Public License
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
50936fc7230a9b3f01e285e72c4182013542f53eJakub Hrozek#include "db/sysdb_private.h" /* new_subdomain() */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek#define TEST_DOM_SID "S-1-5-21-444379608-1639770488-2995963434"
7543052f562f157f7b17fdc46a6777d80c0cb3bdSumit Boseconst char *global_extra_attrs[] = {"phone", "mobile", NULL};
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Mock NSS structure */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose err = sss_idmap_init(sss_idmap_talloc, nctx, sss_idmap_talloc_free,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FATAL_FAILURE, "sss_idmap_init failed.\n");
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Mock reading requests from a client. Use values passed from mock
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekvoid __real_sss_packet_get_body(struct sss_packet *packet,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekvoid __wrap_sss_packet_get_body(struct sss_packet *packet,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek enum sss_test_wrapper_call wtype = sss_mock_type(enum sss_test_wrapper_call);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek return __real_sss_packet_get_body(packet, body, blen);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Mock returning result to client. Terminate the unit test instead. */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosetypedef int (*cmd_cb_fn_t)(uint32_t, uint8_t *, size_t );
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekvoid __wrap_sss_cmd_done(struct cli_ctx *cctx, void *freectx)
0713b92ec9f10b6dd913dc56cbc7845d1b025ccbPavel Březina pctx = talloc_get_type(cctx->protocol_ctx, struct cli_protocol);
0713b92ec9f10b6dd913dc56cbc7845d1b025ccbPavel Březina __real_sss_packet_get_body(packet, &body, &blen);
0713b92ec9f10b6dd913dc56cbc7845d1b025ccbPavel Březina nss_test_ctx->tctx->error = check_cb(sss_packet_get_status(packet),
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekenum sss_cli_command __wrap_sss_packet_get_cmd(struct sss_packet *packet)
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekint __wrap_sss_cmd_send_empty(struct cli_ctx *cctx, TALLOC_CTX *freectx)
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Intercept negative cache lookups */
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __real_sss_ncache_check_user(struct sss_nc_ctx *ctx,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek struct sss_domain_info *dom, const char *name);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __wrap_sss_ncache_check_user(struct sss_nc_ctx *ctx,
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnik ret = __real_sss_ncache_check_user(ctx, dom, name);
54039570d26e29444c398aa4ad6ba638f1713566Sumit Boseint __real_sss_ncache_check_upn(struct sss_nc_ctx *ctx,
54039570d26e29444c398aa4ad6ba638f1713566Sumit Boseint __wrap_sss_ncache_check_upn(struct sss_nc_ctx *ctx,
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose ret = __real_sss_ncache_check_upn(ctx, dom, name);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __real_sss_ncache_check_uid(struct sss_nc_ctx *ctx,
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __wrap_sss_ncache_check_uid(struct sss_nc_ctx *ctx,
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnik ret = __real_sss_ncache_check_uid(ctx, dom, uid);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __real_sss_ncache_check_sid(struct sss_nc_ctx *ctx, const char *sid);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __wrap_sss_ncache_check_sid(struct sss_nc_ctx *ctx, const char *sid)
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnik ret = __real_sss_ncache_check_sid(ctx, sid);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __real_sss_ncache_check_cert(struct sss_nc_ctx *ctx, const char *cert);
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnikint __wrap_sss_ncache_check_cert(struct sss_nc_ctx *ctx, const char *cert)
35567de112cd5d82acb582cbdb44c8652bbdfda1Lukas Slebodnik ret = __real_sss_ncache_check_cert(ctx, cert);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Mock input from the client library */
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březinastatic void mock_input_user_or_group(const char *input)
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return(__wrap_sss_packet_get_body, input);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bosestatic void mock_input_user_or_group_ex(bool do_parse_inp, const char *input,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose data = talloc_size(nss_test_ctx, len + sizeof(uint32_t));
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, len + sizeof(uint32_t));
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina mock_parse_inp(NULL, NULL, ERR_DOMAIN_NOT_FOUND);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return(__wrap_sss_packet_get_body, cert);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic void mock_input_id(TALLOC_CTX *mem_ctx, uint32_t id)
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha will_return(__wrap_sss_packet_get_body, sizeof(uint32_t));
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bosestatic void mock_input_id_ex(TALLOC_CTX *mem_ctx, uint32_t id, uint32_t flags)
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose SAFEALIGN_SETMEM_UINT32(body + sizeof(uint32_t), flags, NULL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, 2 * sizeof(uint32_t));
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* One packet for the entry and one for num entries */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* One packet for the entry and one for num entries */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekstatic int parse_user_packet(uint8_t *body, size_t blen, struct passwd *pwd)
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek SAFEALIGN_COPY_UINT32(&pwd->pw_uid, body+rp, &rp);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek SAFEALIGN_COPY_UINT32(&pwd->pw_gid, body+rp, &rp);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Sequence of null terminated strings (name, passwd, gecos, dir, shell) */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozekstatic int parse_group_packet(uint8_t *body, size_t blen, struct group *gr, uint32_t *nmem)
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek size_t rp = 2 * sizeof(uint32_t); /* Len and reserved */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek SAFEALIGN_COPY_UINT32(&gr->gr_gid, body+rp, &rp);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek gr->gr_mem = talloc_zero_array(nss_test_ctx, char *, *nmem);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek for (i = 0; i < *nmem; i++) {
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek gr->gr_mem[i] = talloc_strdup(gr->gr_mem, (char *) body+rp);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Make sure we exactly matched the end of the packet */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic void check_initgr_packet(uint8_t *body, size_t blen,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek rp = 2 * sizeof(uint32_t); /* Len and reserved */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek for (i = 0; i < num_gids; i++) {
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek SAFEALIGN_COPY_UINT32(&cur_gid, body + rp, &rp);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic errno_t store_user(struct nss_test_ctx *ctx,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek /* Prime the cache with a valid user */
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidênciostatic errno_t delete_user(struct nss_test_ctx *ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = sysdb_delete_user(dom, fqname, user->pw_uid);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic errno_t set_user_attr(struct nss_test_ctx *ctx,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = sysdb_set_user_attr(nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek fqname = sss_create_internal_fqname(mem_ctx, shortname,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = sysdb_getpwnam(mem_ctx, domain, fqname, _res);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic void assert_users_equal(struct passwd *a, struct passwd *b)
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_string_equal(a->pw_passwd, b->pw_passwd);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic errno_t store_group(struct nss_test_ctx *ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidênciostatic errno_t delete_group(struct nss_test_ctx *ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = sysdb_delete_group(dom, fqname, group->gr_gid);
caae0e53e6091806634943699f4398b6a20273b4Michal Židekstatic int cmp_func(const void *a, const void *b)
caae0e53e6091806634943699f4398b6a20273b4Michal Židekstatic void order_string_array(char **_list, int size)
caae0e53e6091806634943699f4398b6a20273b4Michal Židek if (size < 2 || _list == NULL || *_list == NULL) {
caae0e53e6091806634943699f4398b6a20273b4Michal Židek /* Nothing to do */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic void assert_groups_equal(struct group *expected,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_int_equal(gr->gr_gid, expected->gr_gid);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_string_equal(gr->gr_name, expected->gr_name);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_string_equal(gr->gr_passwd, expected->gr_passwd);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek for (i = 0; i < nmem; i++) {
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_string_equal(gr->gr_mem[i], expected->gr_mem[i]);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozekstatic errno_t store_group_member(struct nss_test_ctx *ctx,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek member_fqname = sss_create_internal_fqname(ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidênciostatic errno_t remove_group_member(struct nss_test_ctx *ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio group_fqname = sss_create_internal_fqname(ctx,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio member_fqname = sss_create_internal_fqname(ctx,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* ====================== The tests =============================== */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Check getting cached and valid user from cache. Account callback will
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * not be called and test_nss_getpwnam_check will make sure the user is
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * the same as the test entered before starting
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getpwnam_check(uint32_t status, uint8_t *body, size_t blen)
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Query for that user, call a callback when command finishes */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Wait until the test finishes with EOK */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz/* Test that searching for a nonexistent user yields ENOENT.
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * Account callback will be called
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Wait until the test finishes with ENOENT */
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Test that subsequent search for a nonexistent user yields
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * ENOENT and Account callback is not called, on the other hand
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * the ncache functions will be called
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Wait until the test finishes with ENOENT */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Negative cache was hit this time */
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 1);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testuser_search"),
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekstatic int test_nss_getpwnam_search_acct_cb(void *pvt)
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek return store_user(ctx, ctx->tctx->dom, &getpwnam_search_usr, NULL, 0);
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getpwnam_search_check(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_users_equal(&pwd, &getpwnam_search_usr);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek mock_account_recv(0, 0, NULL, test_nss_getpwnam_search_acct_cb, nss_test_ctx);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Wait until the test finishes with EOK */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* test_nss_getpwnam_search_check will check the user attributes */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Test that searching for a user that is expired in the cache goes to the DP
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * which updates the record and the NSS responder returns the updated record
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * The user's shell attribute is updated.
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozekstatic int test_nss_getpwnam_update_acct_cb(void *pvt)
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek getpwnam_update.pw_shell = discard_const("/bin/ksh");
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek return store_user(ctx, ctx->tctx->dom, &getpwnam_update, NULL, 0);
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getpwnam_update_check(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Mock client input */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Mock client command */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Call this function when user is updated by the mock DP request */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek mock_account_recv(0, 0, NULL, test_nss_getpwnam_update_acct_cb, nss_test_ctx);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Call this function to check what the responder returned to the client */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Mock output buffer */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Fire the command */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Wait until the test finishes with EOK */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Check the user was updated in the cache */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek shell = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SHELL, NULL);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek/* Check that a FQDN is returned if the domain is FQDN-only and a
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek * FQDN is requested
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getpwnam_check_fqdn(uint32_t status,
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek nss_test_ctx->cctx->rctx->domains[0].fqnames = false;
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek getpwnam_fqdn.pw_name = discard_const("testuser_fqdn@"TEST_DOM_NAME);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek mock_input_user_or_group("testuser_fqdn@"TEST_DOM_NAME);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek /* Query for that user, call a callback when command finishes */
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek nss_test_ctx->cctx->rctx->domains[0].fqnames = true;
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek /* Wait until the test finishes with EOK */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek/* Check that a user with a space in his username is returned fine.
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozekstatic int test_nss_getpwnam_check_space(uint32_t status,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Query for that user, call a callback when command finishes */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Wait until the test finishes with EOK */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozekstatic int test_nss_getpwnam_check_space_sub(uint32_t status,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek assert_string_equal(pwd.pw_name, "space_user");
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Set whitespace substitution */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Query for that user, call a callback when command finishes */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Wait until the test finishes with EOK */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozekvoid test_nss_getpwnam_space_sub_query(void **state)
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Set whitespace substitution */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Query for that user, call a callback when command finishes */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Wait until the test finishes with EOK */
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek * Check that FQDN processing is able to handle arbitrarily sized
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_name = discard_const("testuser_fqdn_fancy"),
c86904baad32fbf9e66bf1cdc667aa5e683b48baStef Walterstatic int test_nss_getpwnam_check_fancy_fqdn(uint32_t status,
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek nss_test_ctx->cctx->rctx->domains[0].fqnames = false;
c86904baad32fbf9e66bf1cdc667aa5e683b48baStef Walter assert_string_equal(pwd.pw_name, "testuser_fqdn_fancy@@@@@"TEST_DOM_NAME);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
c86904baad32fbf9e66bf1cdc667aa5e683b48baStef Walter mock_input_user_or_group("testuser_fqdn_fancy@"TEST_DOM_NAME);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek /* Query for that user, call a callback when command finishes */
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek nss_test_ctx->cctx->rctx->domains[0].fqnames = true;
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozek /* Wait until the test finishes with EOK */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha/* Check getting cached and valid id from cache. Account callback will
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * not be called and test_nss_getpwuid_check will make sure the id is
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * the same as the test entered before starting
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic int test_nss_getpwuid_check(uint32_t status, uint8_t *body, size_t blen)
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Query for that id, call a callback when command finishes */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Wait until the test finishes with EOK */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha/* Test that searching for a nonexistent id yields ENOENT.
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * Account callback will be called
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Wait until the test finishes with ENOENT */
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Test that subsequent search for a nonexistent id yields
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * ENOENT and Account callback is not called, on the other hand
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * the ncache functions will be called
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Wait until the test finishes with ENOENT */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Negative cache was hit this time */
9cc2223e0bc0478c1b47a47fd71bba7e7129492dJakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 1);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek/* Test that lookup by UID for a user that does
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek * not exist in the cache fetches the user from DP
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_name = discard_const("exampleuser_search"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/examplesearch"),
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic int test_nss_getpwuid_search_acct_cb(void *pvt)
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek return store_user(ctx, ctx->tctx->dom, &getpwuid_srch, NULL, 0);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic int test_nss_getpwuid_search_check(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek mock_input_id(nss_test_ctx, getpwuid_srch.pw_uid);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha mock_account_recv(0, 0, NULL, test_nss_getpwuid_search_acct_cb, nss_test_ctx);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sysdb_getpwuid(nss_test_ctx, nss_test_ctx->tctx->dom,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Wait until the test finishes with EOK */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* test_nss_getpwuid_search_check will check the id attributes */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sysdb_getpwuid(nss_test_ctx, nss_test_ctx->tctx->dom,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha/* Test that searching for an id that is expired in the cache goes to the DP
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * which updates the record and the NSS responder returns the updated record
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha * The user's shell attribute is updated.
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_name = discard_const("exampleuser_update"),
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic int test_nss_getpwuid_update_acct_cb(void *pvt)
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek getpwuid_update.pw_shell = discard_const("/bin/ksh");
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek return store_user(ctx, ctx->tctx->dom, &getpwuid_update, NULL, 0);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jhastatic int test_nss_getpwuid_update_check(uint32_t status,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Prime the cache with a valid but expired user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Mock client input */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek mock_input_id(nss_test_ctx, getpwuid_update.pw_uid);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Mock client command */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Call this function when id is updated by the mock DP request */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha mock_account_recv(0, 0, NULL, test_nss_getpwuid_update_acct_cb, nss_test_ctx);
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Call this function to check what the responder returned to the client */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Mock output buffer */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Fire the command */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Wait until the test finishes with EOK */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha /* Check the user was updated in the cache */
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha ret = sysdb_getpwuid(nss_test_ctx, nss_test_ctx->tctx->dom,
a044c9a1012d11a2a75e9976ebf186d2d781d291Pallavi Jha shell = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SHELL, NULL);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek/* Testsuite setup and teardown */
777374243e15c53e7b0a7345e190c1018920be18Jakub Hrozekvoid test_nss_setup(struct sss_test_conf_param params[],
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek nss_test_ctx = talloc_zero(NULL, struct nss_test_ctx);
a95c006f748fa9df0dd81509b51974133d2786afLukas Slebodnik nss_test_ctx->tctx = create_dom_test_ctx(nss_test_ctx, TESTS_PATH,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek nss_test_ctx->tctx->dom->domain_id = discard_const(TEST_DOM_SID);
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* FIXME - perhaps this should be folded into sssd_domain_init or strictly
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek * used together
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek ret = sss_names_init(nss_test_ctx, nss_test_ctx->tctx->confdb,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek TEST_DOM_NAME, &nss_test_ctx->tctx->dom->names);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Initialize the NSS responder */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek nss_test_ctx->rctx = mock_rctx(nss_test_ctx, nss_test_ctx->tctx->ev,
e4549c5364461644723361d688badde7fe137a25Sumit Bose nss_test_ctx->rctx->cdb = nss_test_ctx->tctx->confdb;
a22b0af1993a489c9c0e66fdc1083f43b410d12cPavel Březina ret = sss_ad_default_names_ctx(nss_test_ctx->nctx,
a22b0af1993a489c9c0e66fdc1083f43b410d12cPavel Březina assert_non_null(nss_test_ctx->nctx->rctx->global_names);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Create client context */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek nss_test_ctx->cctx = mock_cctx(nss_test_ctx, nss_test_ctx->rctx);
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce /* Add nss specific state_ctx */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* do after previous setup as the former nulls protocol_ctx */
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce nss_test_ctx->cctx->protocol_ctx = mock_prctx(nss_test_ctx->cctx);
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce assert_non_null(nss_test_ctx->cctx->protocol_ctx);
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_no_members_check(uint32_t status,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek assert_groups_equal(&getgrnam_no_members, &gr, nmem);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek/* Test that requesting a valid, cached group with no members returns a valid
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek * group structure
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Prime the cache with a valid group */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek mock_input_user_or_group(getgrnam_no_members.gr_name);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Query for that group, call a callback when command finishes */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek set_cmd_cb(test_nss_getgrnam_no_members_check);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Wait until the test finishes with EOK */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_members_check(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek const char *exp_members[] = { testmember1.pw_name,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek/* Test that requesting a valid, cached group with some members returns a valid
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek * group structure with those members present
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Query for that group, call a callback when command finishes */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Wait until the test finishes with EOK */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_members_check_fqdn(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek exp_members[0] = sss_tc_fqname(tmp_ctx, nss_test_ctx->tctx->dom->names,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek exp_members[1] = sss_tc_fqname(tmp_ctx, nss_test_ctx->tctx->dom->names,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek/* Test that requesting a valid, cached group with some members returns a valid
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek * group structure with those members present as fully qualified names
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozekvoid test_nss_getgrnam_members_fqdn(void **state)
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek mock_input_user_or_group("testgroup_members@"TEST_DOM_NAME);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Query for that group, call a callback when command finishes */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek set_cmd_cb(test_nss_getgrnam_members_check_fqdn);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Wait until the test finishes with EOK */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Restore FQDN settings */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek/* Test that requesting a valid, cached group with subdomain members returns
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek * a valid * group structure with those members present as fully
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek * qualified names
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_members_check_subdom(uint32_t status,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozekvoid test_nss_getgrnam_members_subdom(void **state)
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek mock_input_user_or_group("testsubdomgroup@"TEST_SUBDOM_NAME);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Query for that group, call a callback when command finishes */
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek set_cmd_cb(test_nss_getgrnam_members_check_subdom);
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek /* Wait until the test finishes with EOK */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidênciovoid test_nss_getgrnam_members_subdom_nonfqnames(void **state)
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio mock_input_user_or_group("testsubdomgroup");
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Query for that group, call a callback when command finishes */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio set_cmd_cb(test_nss_getgrnam_members_check_subdom);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Wait until the test finishes with EOK */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_check_mix_dom(uint32_t status,
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Query for that group, call a callback when command finishes */
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Wait until the test finishes with EOK */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidênciovoid test_nss_getgrnam_mix_dom_nonfqnames(void **state)
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio mock_input_user_or_group("testgroup_members");
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Query for that group, call a callback when command finishes */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio set_cmd_cb(test_nss_getgrnam_check_mix_dom);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Wait until the test finishes with EOK */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_check_mix_dom_fqdn(uint32_t status,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio exp_members[1] = sss_tc_fqname(tmp_ctx, nss_test_ctx->tctx->dom->names,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio nss_test_ctx->tctx->dom, testmember1.pw_name);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio exp_members[2] = sss_tc_fqname(tmp_ctx, nss_test_ctx->tctx->dom->names,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio nss_test_ctx->tctx->dom, testmember2.pw_name);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio expected.gr_name = testgroup_members.gr_name;
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozekvoid test_nss_getgrnam_mix_dom_fqdn(void **state)
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek mock_input_user_or_group("testgroup_members@"TEST_DOM_NAME);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Query for that group, call a callback when command finishes */
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek set_cmd_cb(test_nss_getgrnam_check_mix_dom_fqdn);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Wait until the test finishes with EOK */
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Restore FQDN settings */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidênciovoid test_nss_getgrnam_mix_dom_fqdn_nonfqnames(void **state)
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio mock_input_user_or_group("testgroup_members");
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Query for that group, call a callback when command finishes */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio set_cmd_cb(test_nss_getgrnam_check_mix_dom_fqdn);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Wait until the test finishes with EOK */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Restore FQDN settings */
32b976eb666044d106dd85e27f8d0bb1d7b6cd6cSumit Bosestatic int test_nss_getgrnam_check_mix_subdom(uint32_t status,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek /* Important: this member is from a non-qualified domain, so his name will
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek * not be qualified either
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek mock_input_user_or_group("testsubdomgroup@"TEST_SUBDOM_NAME);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Query for that group, call a callback when command finishes */
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek set_cmd_cb(test_nss_getgrnam_check_mix_subdom);
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
000e61bb652400215a9a851d3630cdc7307af398Jakub Hrozek /* Wait until the test finishes with EOK */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidênciovoid test_nss_getgrnam_mix_subdom_nonfqnames(void **state)
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio mock_input_user_or_group("testsubdomgroup");
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Query for that group, call a callback when command finishes */
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio set_cmd_cb(test_nss_getgrnam_check_mix_subdom);
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio /* Wait until the test finishes with EOK */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozekstatic int test_nss_getgrnam_space_check(uint32_t status,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek/* Test that requesting a valid, cached group with space in its name returns a valid
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek * group structure
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Prime the cache with a valid group */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Query for that group, call a callback when command finishes */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Wait until the test finishes with EOK */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozekstatic int test_nss_getgrnam_space_sub_check(uint32_t status,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = parse_group_packet(body, blen, &gr, &nmem);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek space_group.gr_name = discard_const("space_group");
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek/* Test that requesting a valid, cached group with space in its name returns a valid
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek * group structure
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Set whitespace substitution */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Query for that group, call a callback when command finishes */
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM,
ef49e1d709c3cbb3eccbc22710964e1ffe2612c9Jakub Hrozek /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosestatic int test_nss_well_known_sid_check(uint32_t status,
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose char *expected_result = sss_mock_ptr_type(char *);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getnamebysid(void **state)
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, "S-1-5-32-550");
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYSID);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(test_nss_well_known_sid_check, "Print Operators@BUILTIN");
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getnamebysid_special(void **state)
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, "S-1-2-0");
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYSID);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(test_nss_well_known_sid_check, "LOCAL@LOCAL AUTHORITY");
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getnamebysid_non_existing(void **state)
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, "S-1-5-32-123");
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYSID);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(test_nss_well_known_sid_check, NULL);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getidbysid_failure(void **state)
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(__wrap_sss_packet_get_body, "S-1-5-32-550");
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_cmd, SSS_NSS_GETIDBYSID);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose will_return(test_nss_well_known_sid_check, NULL);
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETIDBYSID,
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getsidbyname(void **state)
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose const char *names[] = { "Cryptographic Operators@BUILTIN",
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, names[c]);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(test_nss_well_known_sid_check, "S-1-5-32-569");
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getsidbyname_nonexisting(void **state)
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose const char *names[] = { "Abc@BUILTIN", "BUILTIN\\Abc", NULL };
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, names[c]);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(test_nss_well_known_sid_check, NULL);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose /* Wait until the test finishes with EOK */
36c266d467e9105041b33e9b1cdcd9ff073d893eSumit Bosevoid test_nss_well_known_getsidbyname_special(void **state)
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose const char *names[] = { "CREATOR OWNER@CREATOR AUTHORITY",
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, names[c]);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose will_return(test_nss_well_known_sid_check, "S-1-3-0");
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
4f1897ad419790834573643e88ac03e6c5c1c4beSumit Bose /* Wait until the test finishes with EOK */
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bosestatic int test_nss_getorigbyname_check(uint32_t status, uint8_t *body,
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose const char *s;
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose /* Sequence of null terminated strings */
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_NAME);
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_UIDNUM);
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek assert_string_equal(s, "testuserorig@upndomain.test");
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek const char *test_upn = "testuserorig@upndomain.test";
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, "S-1-2-3-4");
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose ret = sysdb_attrs_add_string(attrs, ORIGINALAD_PREFIX SYSDB_NAME,
9decb708802b6483de58ec27feb310baa7892ed9Sumit Bose "orig_name");
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose ret = sysdb_attrs_add_uint32(attrs, ORIGINALAD_PREFIX SYSDB_UIDNUM, 1234);
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, test_upn);
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETORIGBYNAME);
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose /* Query for that user, call a callback when command finishes */
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETORIGBYNAME,
229c292143dcd4120acb022682b5b7d0aca622ddSumit Bose /* Wait until the test finishes with EOK */
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek /* Also test looking up the same stuff with UPN */
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETORIGBYNAME);
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek /* Query for that user, call a callback when command finishes */
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETORIGBYNAME,
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek /* Wait until the test finishes with EOK */
e4549c5364461644723361d688badde7fe137a25Sumit Bosestatic int test_nss_getorigbyname_extra_check(uint32_t status, uint8_t *body,
e4549c5364461644723361d688badde7fe137a25Sumit Bose const char *s;
e4549c5364461644723361d688badde7fe137a25Sumit Bose /* Sequence of null terminated strings */
e4549c5364461644723361d688badde7fe137a25Sumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_NAME);
e4549c5364461644723361d688badde7fe137a25Sumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_UIDNUM);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testuserorigextra"),
e4549c5364461644723361d688badde7fe137a25Sumit Bosevoid test_nss_getorigbyname_extra_attrs(void **state)
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, "S-1-2-3-4");
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_string(attrs, ORIGINALAD_PREFIX SYSDB_NAME,
9decb708802b6483de58ec27feb310baa7892ed9Sumit Bose "orig_name");
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_uint32(attrs, ORIGINALAD_PREFIX SYSDB_UIDNUM, 1234);
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_string(attrs, "phone", "+12-34 56 78");
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_string(attrs, "mobile", "+98-76 54 32");
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sysdb_attrs_add_string(attrs, "not_extra", "abc");
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
e4549c5364461644723361d688badde7fe137a25Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETORIGBYNAME);
e4549c5364461644723361d688badde7fe137a25Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
e4549c5364461644723361d688badde7fe137a25Sumit Bose /* Query for that user, call a callback when command finishes */
e4549c5364461644723361d688badde7fe137a25Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETORIGBYNAME,
e4549c5364461644723361d688badde7fe137a25Sumit Bose /* Wait until the test finishes with EOK */
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bosestatic int test_nss_getorigbyname_multi_check(uint32_t status, uint8_t *body,
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose const char *s;
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose /* Sequence of null terminated strings */
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_NAME);
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose assert_string_equal(s, ORIGINALAD_PREFIX SYSDB_UIDNUM);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testuserorigmulti"),
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bosevoid test_nss_getorigbyname_multi_value_attrs(void **state)
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, "S-1-2-3-4");
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_string(attrs, ORIGINALAD_PREFIX SYSDB_NAME,
9decb708802b6483de58ec27feb310baa7892ed9Sumit Bose "orig_name");
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_uint32(attrs, ORIGINALAD_PREFIX SYSDB_UIDNUM, 1234);
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_ORIG_MEMBEROF, "cn=abc");
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_ORIG_MEMBEROF, "cn=def");
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_ORIG_MEMBEROF, "cn=123");
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETORIGBYNAME);
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose /* Query for that user, call a callback when command finishes */
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETORIGBYNAME,
5f4d896ec8e06476f4282b562b1044de14c48ecfSumit Bose /* Wait until the test finishes with EOK */
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozekstatic int test_nss_getpwnam_upn_check(uint32_t status,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, "upnuser@upndomain.test");
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Query for that user, call a callback when command finishes */
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Wait until the test finishes with EOK */
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bosevoid test_nss_getpwnam_upn_same_domain(void **state)
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, "upnuser_upn@" TEST_DOM_NAME);
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose /* Prime the cache with a valid user */
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose mock_input_user_or_group("upnuser_upn@" TEST_DOM_NAME);
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM);
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose /* Query for that user, call a callback when command finishes */
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose /* Wait until the test finishes with EOK */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz/* Test that searching for a nonexistent user yields ENOENT.
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek * Account callback will be called
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina mock_input_upn("nosuchupnuser@upndomain.test");
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Wait until the test finishes with ENOENT */
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina assert_int_equal(nss_test_ctx->ncache_hits, 0);
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Test that subsequent search for a nonexistent user yields
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek * ENOENT and Account callback is not called, on the other hand
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek * the ncache functions will be called
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina mock_input_upn("nosuchupnuser@upndomain.test");
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Wait until the test finishes with ENOENT */
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek /* Negative cache was hit this time */
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 1);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic int test_nss_initgr_check(uint32_t status, uint8_t *body, size_t blen)
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek check_initgr_packet(body, blen, expected_gids, N_ELEMENTS(expected_gids));
390de028b3130ae564059101c662fe74e0e85a45Lukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, "upninitgr@upndomain.test");
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Query for that user, call a callback when command finishes */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with EOK */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz/* Test that searching for a nonexistent user yields ENOENT.
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek * Account callback will be called
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekvoid test_initgr_neg_by_name(const char *name, bool is_upn)
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with ENOENT */
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina assert_int_equal(nss_test_ctx->ncache_hits, 0);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Test that subsequent search for a nonexistent user yields
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek * ENOENT and Account callback is not called, on the other hand
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek * the ncache functions will be called
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with ENOENT */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Negative cache was hit this time */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 1);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek test_initgr_neg_by_name("testinitgr_neg", false);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testinitgr_srch"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_srch_gr1"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_srch_gr2"),
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic int test_nss_initgr_search_acct_cb(void *pvt)
390de028b3130ae564059101c662fe74e0e85a45Lukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic int test_nss_initgr_search_check(uint32_t status,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek check_initgr_packet(body, blen, expected_gids, N_ELEMENTS(expected_gids));
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek mock_account_recv(0, 0, NULL, test_nss_initgr_search_acct_cb, nss_test_ctx);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with EOK */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* test_nss_getpwnam_search_check will check the user attributes */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testinitgr_update"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_update_gr1"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_update_gr2"),
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic int test_nss_initgr_update_acct_cb(void *pvt)
390de028b3130ae564059101c662fe74e0e85a45Lukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozekstatic int test_nss_initgr_update_check(uint32_t status, uint8_t *body, size_t blen)
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek check_initgr_packet(body, blen, expected_gids, N_ELEMENTS(expected_gids));
390de028b3130ae564059101c662fe74e0e85a45Lukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek mock_account_recv(0, 0, NULL, test_nss_initgr_update_acct_cb, nss_test_ctx);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Query for that user, call a callback when command finishes */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with EOK */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testinitgr_2attr"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_2attr_gr11"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .gr_name = discard_const("testinitgr_2attr_gr12"),
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnikstatic int test_nss_initgr_update_acct_2expire_attributes_cb(void *pvt)
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = set_user_attr(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnikstatic int test_nss_initgr_update_2expire_attributes_check(uint32_t status,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik check_initgr_packet(body, blen, expected_gids, N_ELEMENTS(expected_gids));
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik * SYSDB_INITGR_EXPIRE has default value 0 => initgroups was not finished.
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik * SYSDB_CACHE_EXPIRE has value from future => getpwnam finished successfully
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik * Test result: DP should be contacted for update.
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnikvoid test_nss_initgr_update_two_expire_attributes(void **state)
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_group(nss_test_ctx, nss_test_ctx->tctx->dom,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik mock_input_user_or_group("testinitgr_2attr");
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik test_nss_initgr_update_acct_2expire_attributes_cb,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik set_cmd_cb(test_nss_initgr_update_2expire_attributes_check);
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik /* Query for that user, call a callback when command finishes */
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik /* Wait until the test finishes with EOK */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR);
8d5292227a8d1ab9c6aa5b88d8ac8655cd1223e5Pavel Březina will_return_always(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Query for that user, call a callback when command finishes */
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek /* Wait until the test finishes with EOK */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz/* Test that searching for a nonexistent user yields ENOENT.
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek * Account callback will be called
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek test_initgr_neg_by_name("upninitgr_neg@upndomain.test", true);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int nss_test_setup_extra_attr(void **state)
e4549c5364461644723361d688badde7fe137a25Sumit Bose nss_test_ctx->nctx->extra_attributes = global_extra_attrs;
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidênciostatic int nss_subdom_test_setup_common(void **state, bool nonfqnames)
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek const char *const testdom[4] = { TEST_SUBDOM_NAME, "TEST.SUB", "test", "S-3" };
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek subdomain = new_subdomain(nss_test_ctx, nss_test_ctx->tctx->dom,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek testdom[0], testdom[1], testdom[2], testdom[3],
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek ret = sysdb_subdomain_store(nss_test_ctx->tctx->sysdb,
34926c3809b19f9e70f18931e44bf993321647a8Jakub Hrozek testdom[0], testdom[1], testdom[2], testdom[3],
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek ret = sysdb_update_subdomains(nss_test_ctx->tctx->dom,
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidêncio dom = get_next_domain(dom, SSS_GND_ALL_DOMAINS)) {
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidêncio if (strcmp(dom->name, subdomain->name) == 0) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio ret = sss_resp_populate_cr_domains(nss_test_ctx->rctx);
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio assert_non_null(nss_test_ctx->rctx->cr_domains);
46c99a59c8d6501aa3ad701c567fba577924b48bPavel Březina nss_test_ctx->subdom = nss_test_ctx->tctx->dom->subdomains;
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = store_group(nss_test_ctx, nss_test_ctx->subdom,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = store_user(nss_test_ctx, nss_test_ctx->subdom,
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = store_user(nss_test_ctx, nss_test_ctx->subdom,
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidênciostatic int nss_subdom_test_setup(void **state)
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidêncio return nss_subdom_test_setup_common(state, false);
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidênciostatic int nss_subdom_test_setup_nonfqnames(void **state)
ed518f61f1a5d4cf5d87eec492c158725a73d6a1Fabiano Fidêncio return nss_subdom_test_setup_common(state, true);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int nss_fqdn_fancy_test_setup(void **state)
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidênciostatic int nss_subdom_test_teardown(void **state)
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = delete_user(nss_test_ctx, nss_test_ctx->subdom, &submember2);
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = delete_user(nss_test_ctx, nss_test_ctx->subdom, &submember1);
a3442e4a268ad2172c89d58e6daa759eb4b39e7cFabiano Fidêncio ret = delete_group(nss_test_ctx, nss_test_ctx->subdom, &testsubdomgroup);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_gecos = discard_const("test bysid lookup"),
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozekstatic int test_nss_getnamebysid_check(uint32_t status, uint8_t *body, size_t blen)
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek size_t rp = 2 * sizeof(uint32_t); /* num_results and reserved */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, user_sid);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYSID);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Query for that user, call a callback when command finishes */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Should go straight to back end, without contacting DP */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Wait until the test finishes with EOK */
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz/* Test that searching for a nonexistent user yields ENOENT.
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek * Account callback will be called
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek user_sid = talloc_asprintf(nss_test_ctx, "%s-499",
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Wait until the test finishes with ENOENT */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 0);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Test that subsequent search for a nonexistent user yields
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek * ENOENT and Account callback is not called, on the other hand
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek * the ncache functions will be called
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Wait until the test finishes with ENOENT */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Negative cache was hit this time */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek assert_int_equal(nss_test_ctx->ncache_hits, 1);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_name = discard_const("testsidbyname_update"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_dir = discard_const("/home/testsidbyname_update"),
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek .pw_gecos = discard_const("test bysid lookup"),
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozekstatic int test_nss_getnamebysid_update_check(uint32_t status,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek size_t rp = 2 * sizeof(uint32_t); /* num_results and reserved */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek assert_string_equal(name, "testsidbyname_update");
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozekstatic int test_nss_getnamebysid_update_acct_cb(void *pvt)
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek struct nss_test_ctx *ctx = talloc_get_type(pvt, struct nss_test_ctx);
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek testbysid_update.pw_shell = discard_const("/bin/ksh");
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, user_sid);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Prime the cache with a valid but expired user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Mock client input */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Mock client command */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYSID);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Call this function when user is updated by the mock DP request */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek mock_account_recv(0, 0, NULL, test_nss_getnamebysid_update_acct_cb,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Call this function to check what the responder returned to the client */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek set_cmd_cb(test_nss_getnamebysid_update_check);
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Mock output buffer */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Fire the command */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYSID,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Wait until the test finishes with EOK */
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek /* Check the user was updated in the cache */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = get_user(nss_test_ctx, nss_test_ctx->tctx->dom,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek shell = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SHELL, NULL);
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"MIIECTCCAvGgAwIBAgIBCDANBgkqhkiG9w0BAQsFADA0MRIwEAYDVQQKDAlJUEEu" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"REVWRUwxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNTA2MjMx" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"NjMyMDdaFw0xNzA2MjMxNjMyMDdaMDIxEjAQBgNVBAoMCUlQQS5ERVZFTDEcMBoG" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"A1UEAwwTaXBhLWRldmVsLmlwYS5kZXZlbDCCASIwDQYJKoZIhvcNAQEBBQADggEP" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"ADCCAQoCggEBALXUq56VlY+Z0aWLLpFAjFfbElPBXGQsbZb85J3cGyPjaMHC9wS+" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"wjB6Ve4HmQyPLx8hbINdDmbawMHYQvTScLYfsqLtj0Lqw20sUUmedk+Es5Oh9VHo" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"nd8MavYx25Du2u+T0iSgNIDikXguiwCmtAj8VC49ebbgITcjJGzMmiiuJkV3o93Y" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"vvYF0VjLGDQbQWOy7IxzYJeNVJnZWKo67CHdok6qOrm9rxQt81rzwV/mGLbCMUbr" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"+N4M8URtd7EmzaYZQmNm//s2owFrCYMxpLiURPj+URZVuB72504/Ix7X0HCbA/AV" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"26J27fPY5nc8DMwfhUDCbTqPH/JEjd3mvY8CAwEAAaOCASYwggEiMB8GA1UdIwQY" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"MBaAFJOq+KAQmPEnNp8Wok23eGTdE7aDMDsGCCsGAQUFBwEBBC8wLTArBggrBgEF" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"BQcwAYYfaHR0cDovL2lwYS1jYS5pcGEuZGV2ZWwvY2Evb2NzcDAOBgNVHQ8BAf8E" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"BAMCBPAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMHQGA1UdHwRtMGsw" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"aaAxoC+GLWh0dHA6Ly9pcGEtY2EuaXBhLmRldmVsL2lwYS9jcmwvTWFzdGVyQ1JM" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"LmJpbqI0pDIwMDEOMAwGA1UECgwFaXBhY2ExHjAcBgNVBAMMFUNlcnRpZmljYXRl" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"IEF1dGhvcml0eTAdBgNVHQ4EFgQUFaDNd5a53QGpaw5m63hnwXicMQ8wDQYJKoZI" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"hvcNAQELBQADggEBADH7Nj00qqGhGJeXJQAsepqSskz/wooqXh8vgVyb8SS4N0/c" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"0aQtVmY81xamlXE12ZFpwDX43d+EufBkwCUKFX/+8JFDd2doAyeJxv1xM22kKRpc" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"AqITPgMsa9ToGMWxjbVpc/X/5YfZixWPF0/eZUTotBj9oaR039UrhGfyN7OguF/G" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"rzmxtB5y4ZrMpcD/Oe90mkd9HY7sA/fB8OWOUgeRfQoh97HNS0UiDWsPtfxmjQG5" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"zotpoBIZmdH+ipYsu58HohHVlM9Wi5H4QmiiXl+Soldkq7eXYlafcmT7wv8+cKwz" \
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose"Nz0Tm3+eYpFqRo3skr6QzXi525Jkg3r6r+kkhxU="
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bosestatic int test_nss_getnamebycert_check(uint32_t status, uint8_t *body, size_t blen)
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose size_t rp = 2 * sizeof(uint32_t); /* num_results and reserved */
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bosestatic int test_nss_getlistbycert_check_exp(uint32_t status, uint8_t *body,
440797cba931aa491bf418035f55935943e22b4bSumit Bose const char *fq_name1 = "testcertuser@"TEST_DOM_NAME ;
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose const char *fq_name2 = "testcertuser2@"TEST_SUBDOM_NAME;
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* num_results and reserved */
440797cba931aa491bf418035f55935943e22b4bSumit Bose SAFEALIGN_COPY_UINT32(&reserved, body + rp, &rp);
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bosestatic int test_nss_getlistbycert_check_one(uint32_t status, uint8_t *body,
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose return test_nss_getlistbycert_check_exp(status, body, blen, 1);
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bosestatic int test_nss_getlistbycert_check_two(uint32_t status, uint8_t *body,
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose return test_nss_getlistbycert_check_exp(status, body, blen, 2);
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose der = sss_base64_decode(nss_test_ctx, TEST_TOKEN_CERT, &der_size);
81c564a0692aa4b719af2219f52894e6cd4bdf9fSumit Bose ret = sysdb_attrs_add_mem(attrs, SYSDB_USER_MAPPED_CERT, der, der_size);
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Prime the cache with a valid user */
2dcf7b9b65df21f2aee6cdf051a7fbdef6dfe034Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETNAMEBYCERT);
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Query for that user, call a callback when command finishes */
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Should go straight to back end, without contacting DP */
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYCERT,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Wait until the test finishes with EOK */
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYCERT,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Wait until the test finishes with ENOENT */
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Test that subsequent search for a nonexistent user yields
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose * ENOENT and Account callback is not called, on the other hand
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose * the ncache functions will be called
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETNAMEBYCERT,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Wait until the test finishes with ENOENT */
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose /* Negative cache was hit this time */
440797cba931aa491bf418035f55935943e22b4bSumit Bose der = sss_base64_decode(nss_test_ctx, TEST_TOKEN_CERT, &der_size);
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose ret = sysdb_attrs_add_mem(attrs, SYSDB_USER_MAPPED_CERT, der, der_size);
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Prime the cache with a valid user */
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
440797cba931aa491bf418035f55935943e22b4bSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETLISTBYCERT);
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Query for that user, call a callback when command finishes */
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Should go straight to back end, without contacting DP. */
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* If there is only a single user mapped the result will look like the */
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* result of getnamebycert. */
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETLISTBYCERT,
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Wait until the test finishes with EOK */
440797cba931aa491bf418035f55935943e22b4bSumit Bosestatic void test_nss_getlistbycert_multi(void **state)
440797cba931aa491bf418035f55935943e22b4bSumit Bose der = sss_base64_decode(nss_test_ctx, TEST_TOKEN_CERT, &der_size);
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose ret = sysdb_attrs_add_mem(attrs, SYSDB_USER_MAPPED_CERT, der, der_size);
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Prime the cache with two valid user */
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Looks like attrs is modified during store_user() makes sure we start
440797cba931aa491bf418035f55935943e22b4bSumit Bose * with fresh data. */
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose ret = sysdb_attrs_add_mem(attrs, SYSDB_USER_MAPPED_CERT, der, der_size);
71731d26dc4f2c36989779f327b0e9a399486e14Sumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->subdom,
440797cba931aa491bf418035f55935943e22b4bSumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETLISTBYCERT);
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Query for that user, call a callback when command finishes */
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Should go straight to back end, without contacting DP */
440797cba931aa491bf418035f55935943e22b4bSumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETLISTBYCERT,
440797cba931aa491bf418035f55935943e22b4bSumit Bose /* Wait until the test finishes with EOK */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozekstatic int test_nss_getsidbyname_check(uint32_t status,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek char *expected_result = sss_mock_ptr_type(char *);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, testuser_sid);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(test_nss_getsidbyname_check, testuser_sid);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Query for that user, call a callback when command finishes */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Wait until the test finishes with EOK */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek const char *testuser_upn = "testusersid@upndomain.test";
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_SID_STR, testuser_sid);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, testuser_upn);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek will_return(test_nss_getsidbyname_check, testuser_sid);
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Query for that user, call a callback when command finishes */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Wait until the test finishes with EOK */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Query for that user, call a callback when command finishes */
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek /* Wait until the test finishes with ENOENT (because there is no such SID */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bosestatic int test_nss_EINVAL_check(uint32_t status, uint8_t *body, size_t blen)
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, "testuser", 0);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Query for that user, call a callback when command finishes */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use old input format, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, "testuser");
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use unsupported flag combination, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_NO_CACHE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose * will cause a backend lookup -> mock_account_recv_simple() */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, "testuser", SSS_NSS_EX_FLAG_NO_CACHE);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Prime the cache with a valid user */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Query for that id, call a callback when command finishes */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use old input format, expect failure */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use unsupported flag combination, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, id, SSS_NSS_EX_FLAG_NO_CACHE
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_NO_CACHE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose * will cause a backend lookup -> mock_account_recv_simple() */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, id, SSS_NSS_EX_FLAG_NO_CACHE);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, id, SSS_NSS_EX_FLAG_INVALIDATE_CACHE);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETPWUID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETPWUID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bosevoid test_nss_getgrnam_ex_no_members(void **state)
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Test group is still in the cache */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, getgrnam_no_members.gr_name, 0);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Query for that group, call a callback when command finishes */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use old input format, expect failure */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, "testgroup");
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use unsupported flag combination, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(false, getgrnam_no_members.gr_name,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_NO_CACHE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose * will cause a backend lookup -> mock_account_recv_simple() */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, getgrnam_no_members.gr_name,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, getgrnam_no_members.gr_name,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRNAM_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRNAM_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bosevoid test_nss_getgrgid_ex_no_members(void **state)
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Test group is still in the cache */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, getgrnam_no_members.gr_gid, 0);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRGID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Query for that group, call a callback when command finishes */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRGID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use old input format, expect failure */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id(nss_test_ctx, getgrnam_no_members.gr_gid);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRGID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRGID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use unsupported flag combination, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, getgrnam_no_members.gr_gid,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRGID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRGID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_NO_CACHE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose * will cause a backend lookup -> mock_account_recv_simple() */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, getgrnam_no_members.gr_gid,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRGID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRGID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_id_ex(nss_test_ctx, getgrnam_no_members.gr_gid,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETGRGID_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETGRGID_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sysdb_attrs_add_time_t(attrs, SYSDB_INITGR_EXPIRE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sysdb_attrs_add_string(attrs, SYSDB_UPN, "upninitgr@upndomain.test");
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = store_user(nss_test_ctx, nss_test_ctx->tctx->dom,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose mock_input_user_or_group_ex(true, "testinitgr", 0);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Query for that user, call a callback when command finishes */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use old input format, expect failure */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_body, "testinitgr");
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use unsupported flag combination, expect EINVAL */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_NO_CACHE,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose * will cause a backend lookup -> mock_account_recv_simple() */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Use flag SSS_NSS_EX_FLAG_INVALIDATE_CACHE */
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose will_return(__wrap_sss_packet_get_cmd, SSS_NSS_INITGR_EX);
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_INITGR_EX,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose /* Wait until the test finishes with EOK */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek _("Do not delete the test database after a test run"), NULL },
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwuid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_neg,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwuid_neg,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_search,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwuid_search,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_update,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwuid_update,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_fqdn,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_fqdn_fancy,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_space,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_space_sub,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_space_sub_query,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_no_members,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_members,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_members_fqdn,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_members_subdom,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio cmocka_unit_test_setup_teardown(test_nss_getgrnam_members_subdom_nonfqnames,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom_nonfqnames,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom_fqdn,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_dom_fqdn_nonfqnames,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_subdom,
5856a621ac5909ca96520ac5a809eb83fd46d8bcFabiano Fidêncio cmocka_unit_test_setup_teardown(test_nss_getgrnam_mix_subdom_nonfqnames,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_space,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getgrnam_space_sub,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid_special,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getnamebysid_non_existing,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getidbysid_failure,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname_nonexisting,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_well_known_getsidbyname_special,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getorigbyname,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getorigbyname_extra_attrs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getorigbyname_multi_value_attrs,
03713a6444fdecd01465b9d5fbfead9601adce6eJakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getorigbyname,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_upn,
54039570d26e29444c398aa4ad6ba638f1713566Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getpwnam_upn_same_domain,
84a4c4fcc93b3dcc70604817a05f7943606ff596Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getpwnam_upn_neg,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgroups,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgr_neg,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgr_search,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgr_update,
fd60528321fd52720222ec35b895ade54cccb48dLukas Slebodnik cmocka_unit_test_setup_teardown(test_nss_initgr_update_two_expire_attributes,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgroups_upn,
aa648535f445e7a95bf6dedc7c43bb5f94ab7354Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_initgr_neg_upn,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getnamebysid,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getnamebysid_neg,
bbd6f73bbad478a450ecfa2933a63de6dc269778Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getnamebysid_update,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getnamebycert_neg,
1a45124f3f300f9afdcb08eab0938e5e7d0534d9Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getnamebycert,
440797cba931aa491bf418035f55935943e22b4bSumit Bose cmocka_unit_test_setup_teardown(test_nss_getlistbycert,
440797cba931aa491bf418035f55935943e22b4bSumit Bose cmocka_unit_test_setup_teardown(test_nss_getlistbycert_multi,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getsidbyname,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getsidbyupn,
eb9bc1c590b8c3b3b58574c70d9fe5357ef3e901Jakub Hrozek cmocka_unit_test_setup_teardown(test_nss_getsidbyname_neg,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getpwnam_ex,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getpwuid_ex,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getgrnam_ex_no_members,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose cmocka_unit_test_setup_teardown(test_nss_getgrgid_ex_no_members,
85da8a5e90bffc8b0fef5e0ea364a8d3cb50de86Sumit Bose cmocka_unit_test_setup_teardown(test_nss_initgroups_ex,
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
150b76e13b7c4f3ccf1d709bf517ca2af6b2c9a2Jakub Hrozek /* Even though normally the tests should clean up after themselves
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz * they might not after a failed run. Remove the old DB to be sure */
cb4742876508a08ba90c82466c9dba708e4bf999Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek rv = cmocka_run_group_tests(tests, NULL, NULL);
cb4742876508a08ba90c82466c9dba708e4bf999Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Cleanup NSS and NSPR to make Valgrind happy. */