source: web/old/remctl-2.14/tests/server/version-t.c @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * Test suite for version negotiation in the server.
3 *
4 * Written by Russ Allbery <rra@stanford.edu>
5 * Copyright 2006, 2007, 2009
6 *     Board of Trustees, Leland Stanford Jr. University
7 *
8 * See LICENSE for licensing terms.
9 */
10
11#include <config.h>
12#include <portable/system.h>
13#include <portable/gssapi.h>
14
15#include <signal.h>
16#include <sys/wait.h>
17
18#include <client/internal.h>
19#include <client/remctl.h>
20#include <tests/tap/basic.h>
21#include <tests/tap/kerberos.h>
22#include <tests/tap/remctl.h>
23#include <util/util.h>
24
25/* A command token to run test test. */
26static const char token[] = {
27    9, 1, 0, 0,
28    0, 0, 0, 2,
29    0, 0, 0, 4, 't', 'e', 's', 't',
30    0, 0, 0, 4, 't', 'e', 's', 't'
31};
32
33
34int
35main(void)
36{
37    char *principal, *config, *path;
38    struct remctl *r;
39    pid_t remctld;
40    OM_uint32 major, minor;
41    int flags, status;
42    gss_buffer_desc tok;
43
44    /* Unless we have Kerberos available, we can't really do anything. */
45    if (chdir(getenv("SOURCE")) < 0)
46        bail("can't chdir to SOURCE");
47    principal = kerberos_setup();
48    if (principal == NULL)
49        skip_all("Kerberos tests not configured");
50    plan(8);
51    config = concatpath(getenv("SOURCE"), "data/conf-simple");
52    path = concatpath(getenv("BUILD"), "../server/remctld");
53    remctld = remctld_start(path, principal, config);
54
55    /* Open the connection to the site. */
56    r = remctl_new();
57    ok(r != NULL, "remctl_new");
58    ok(remctl_open(r, "localhost", 14373, principal), "remctl_open");
59
60    /* Send the command token. */
61    tok.length = sizeof(token);
62    tok.value = (char *) token;
63    status = token_send_priv(r->fd, r->context, TOKEN_DATA | TOKEN_PROTOCOL,
64                             &tok, &major, &minor);
65    if (status != TOKEN_OK)
66        bail("cannot send token");
67
68    /* Accept the remote token. */
69    status = token_recv_priv(r->fd, r->context, &flags, &tok, 1024 * 64,
70                             &major, &minor);
71    is_int(TOKEN_OK, status, "received token correctly");
72    is_int(TOKEN_DATA | TOKEN_PROTOCOL, flags, "token had correct flags");
73    is_int(3, tok.length, "token had correct length");
74    is_int(2, ((char *) tok.value)[0], "protocol version is 2");
75    is_int(MESSAGE_VERSION, ((char *) tok.value)[1], "message version code");
76    is_int(2, ((char *) tok.value)[2], "highest supported version is 2");
77
78    /* Close things out. */
79    remctl_close(r);
80
81    remctld_stop(remctld);
82    kerberos_cleanup();
83    return 0;
84}
Note: See TracBrowser for help on using the repository browser.