netapi: add NetUserModalsGet and NetUserModalsSet tests.
authorGünther Deschner <gd@samba.org>
Thu, 31 Jul 2008 19:09:00 +0000 (21:09 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 11 Aug 2008 17:14:19 +0000 (19:14 +0200)
Guenther

source/lib/netapi/tests/netuser.c

index ca2dc1a2f405b62681fd97185e2eefd9b2d4e44c..c50e3849510495099e1597df4906a1ee4e99dc75 100644 (file)
@@ -152,6 +152,56 @@ NET_API_STATUS test_netuseradd(const char *hostname,
        return NetUserAdd(hostname, 1, (uint8_t *)&u1, &parm_err);
 }
 
+static NET_API_STATUS test_netusermodals(struct libnetapi_ctx *ctx,
+                                        const char *hostname)
+{
+       NET_API_STATUS status;
+       struct USER_MODALS_INFO_0 *u0 = NULL;
+       struct USER_MODALS_INFO_0 *_u0 = NULL;
+       uint8_t *buffer = NULL;
+       uint32_t parm_err = 0;
+       uint32_t levels[] = { 0, 1, 2, 3 };
+       int i = 0;
+
+       for (i=0; i<ARRAY_SIZE(levels); i++) {
+
+               printf("testing NetUserModalsGet level %d\n", levels[i]);
+
+               status = NetUserModalsGet(hostname, levels[i], &buffer);
+               if (status) {
+                       NETAPI_STATUS(ctx, status, "NetUserModalsGet");
+                       return status;
+               }
+       }
+
+       status = NetUserModalsGet(hostname, 0, (uint8_t **)&u0);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetUserModalsGet");
+               return status;
+       }
+
+       printf("testing NetUserModalsSet\n");
+
+       status = NetUserModalsSet(hostname, 0, (uint8_t *)u0, &parm_err);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetUserModalsSet");
+               return status;
+       }
+
+       status = NetUserModalsGet(hostname, 0, (uint8_t **)&_u0);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetUserModalsGet");
+               return status;
+       }
+
+       if (memcmp(u0, _u0, sizeof(u0) != 0)) {
+               printf("USER_MODALS_INFO_0 struct has changed!!!!\n");
+               return -1;
+       }
+
+       return 0;
+}
+
 NET_API_STATUS netapitest_user(struct libnetapi_ctx *ctx,
                               const char *hostname)
 {
@@ -246,6 +296,11 @@ NET_API_STATUS netapitest_user(struct libnetapi_ctx *ctx,
                goto out;
        }
 
+       status = test_netusermodals(ctx, hostname);
+       if (status) {
+               goto out;
+       }
+
        status = 0;
 
        printf("NetUser tests succeeded\n");