1*beea8b97Schristos /* $NetBSD: t_session.c,v 1.4 2011/02/12 23:21:33 christos Exp $ */
2231558cbSagc
3231558cbSagc /* Copyright (c) 2010 The NetBSD Foundation, Inc.
4231558cbSagc * All rights reserved.
5231558cbSagc *
6231558cbSagc * This code is derived from software contributed to The NetBSD Foundation
7231558cbSagc * by Mateusz Kocielski.
8231558cbSagc *
9231558cbSagc * Redistribution and use in source and binary forms, with or without
10231558cbSagc * modification, are permitted provided that the following conditions
11231558cbSagc * are met:
12231558cbSagc * 1. Redistributions of source code must retain the above copyright
13231558cbSagc * notice, this list of conditions and the following disclaimer.
14231558cbSagc * 2. Redistributions in binary form must reproduce the above copyright
15231558cbSagc * notice, this list of conditions and the following disclaimer in the
16231558cbSagc * documentation and/or other materials provided with the distribution.
17231558cbSagc * 3. All advertising materials mentioning features or use of this software
18231558cbSagc * must display the following acknowledgement:
19231558cbSagc * This product includes software developed by the NetBSD
20231558cbSagc * Foundation, Inc. and its contributors.
21231558cbSagc * 4. Neither the name of The NetBSD Foundation nor the names of its
22231558cbSagc * contributors may be used to endorse or promote products derived
23231558cbSagc * from this software without specific prior written permission.
24231558cbSagc *
25231558cbSagc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26231558cbSagc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27231558cbSagc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28231558cbSagc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29231558cbSagc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30231558cbSagc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31231558cbSagc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32231558cbSagc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33231558cbSagc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34231558cbSagc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35231558cbSagc * POSSIBILITY OF SUCH DAMAGE.
36231558cbSagc */
3719c14409Schristos #include <sys/cdefs.h>
38*beea8b97Schristos __RCSID("$NetBSD: t_session.c,v 1.4 2011/02/12 23:21:33 christos Exp $");
39*beea8b97Schristos
40231558cbSagc #include <atf-c.h>
41231558cbSagc #include <saslc.h>
4219c14409Schristos #include <stdio.h>
43231558cbSagc
44231558cbSagc ATF_TC(t_sess);
ATF_TC_HEAD(t_sess,tc)45231558cbSagc ATF_TC_HEAD(t_sess, tc)
46231558cbSagc {
4719c14409Schristos
48231558cbSagc atf_tc_set_md_var(tc, "descr", "saslc_sess_*() tests");
49231558cbSagc }
ATF_TC_BODY(t_sess,tc)50231558cbSagc ATF_TC_BODY(t_sess, tc)
51231558cbSagc {
52231558cbSagc saslc_t *ctx;
53231558cbSagc saslc_sess_t *sess;
5419c14409Schristos
55231558cbSagc ATF_REQUIRE(ctx = saslc_alloc());
5619c14409Schristos ATF_REQUIRE_EQ(saslc_init(ctx, NULL, NULL), 0);
5719c14409Schristos ATF_CHECK(sess = saslc_sess_init(ctx, "PLAIN", NULL));
58231558cbSagc if (sess != NULL)
59231558cbSagc saslc_sess_end(sess);
6019c14409Schristos ATF_CHECK_EQ(sess = saslc_sess_init(ctx, "", NULL), NULL);
6119c14409Schristos ATF_CHECK(sess = saslc_sess_init(ctx, "NOTEXISTS,LOGIN", NULL));
62231558cbSagc if (sess != NULL)
63231558cbSagc saslc_sess_end(sess);
6419c14409Schristos ATF_CHECK(sess = saslc_sess_init(ctx, "LOGIN,NOTEXISTS", NULL));
65231558cbSagc if (sess != NULL)
66231558cbSagc saslc_sess_end(sess);
6719c14409Schristos ATF_REQUIRE(sess = saslc_sess_init(ctx, "LOGiN", NULL));
6819c14409Schristos ATF_CHECK_STREQ(saslc_sess_getmech(sess), "LOGIN");
69*beea8b97Schristos ATF_REQUIRE_EQ(saslc_end(ctx), -1);
70231558cbSagc saslc_sess_end(sess);
71*beea8b97Schristos ATF_REQUIRE_EQ(saslc_end(ctx), 0);
72231558cbSagc }
73231558cbSagc
ATF_TP_ADD_TCS(tp)74231558cbSagc ATF_TP_ADD_TCS(tp)
75231558cbSagc {
7619c14409Schristos
77231558cbSagc /* context initialization */
78231558cbSagc ATF_TP_ADD_TC(tp, t_sess);
79231558cbSagc return atf_no_error();
80231558cbSagc }
81