Commit 76d680a0 authored by Pekka Pessi's avatar Pekka Pessi

nua (test_init.c, test_register.c): using test_proxy domains

darcs-hash:20070725164053-65a35-fd86cfc492eb078ff69c733cf138827cf6863f44.gz
parent fae6144c
......@@ -36,6 +36,7 @@
#include "test_nua.h"
#include <sofia-sip/tport_tag.h>
#include <sofia-sip/auth_module.h>
#if HAVE_FUNC
#elif HAVE_FUNCTION
......@@ -107,17 +108,49 @@ int test_nua_init(struct context *ctx,
TEST_1(close(temp) == 0);
ctx->p = test_proxy_create(ctx->root,
AUTHTAG_METHOD("Digest"),
AUTHTAG_REALM("test-proxy"),
AUTHTAG_OPAQUE("kuik"),
AUTHTAG_DB(passwd_name),
AUTHTAG_QOP("auth-int"),
AUTHTAG_ALGORITHM("md5"),
AUTHTAG_NEXT_EXPIRES(60),
TAG_IF(ctx->proxy_logging, TPTAG_LOG(1)),
TAG_END());
ctx->proxy_tests = ctx->p != NULL;
if (ctx->p) {
ctx->a.domain =
test_proxy_add_domain(ctx->p,
URL_STRING_MAKE("sip:example.com")->us_url,
AUTHTAG_METHOD("Digest"),
AUTHTAG_REALM("test-proxy"),
AUTHTAG_OPAQUE("kuik"),
AUTHTAG_DB(passwd_name),
AUTHTAG_QOP("auth-int"),
AUTHTAG_ALGORITHM("md5"),
AUTHTAG_NEXT_EXPIRES(60),
TAG_END());
ctx->b.domain =
test_proxy_add_domain(ctx->p,
URL_STRING_MAKE("sip:example.org")->us_url,
AUTHTAG_METHOD("Digest"),
AUTHTAG_REALM("test-proxy"),
AUTHTAG_OPAQUE("kuik"),
AUTHTAG_DB(passwd_name),
AUTHTAG_QOP("auth-int"),
AUTHTAG_ALGORITHM("md5"),
AUTHTAG_NEXT_EXPIRES(60),
TAG_END());
ctx->c.domain =
test_proxy_add_domain(ctx->p,
URL_STRING_MAKE("sip:example.net")->us_url,
AUTHTAG_METHOD("Digest"),
AUTHTAG_REALM("test-proxy"),
AUTHTAG_OPAQUE("kuik"),
AUTHTAG_DB(passwd_name),
AUTHTAG_QOP("auth-int"),
AUTHTAG_ALGORITHM("md5"),
AUTHTAG_NEXT_EXPIRES(60),
TAG_END());
ctx->proxy_tests = 1;
}
if (print_headings)
printf("TEST NUA-2.1.1: PASSED\n");
......
......@@ -139,6 +139,7 @@ struct context
int running;
struct domain *domain;
condition_function *next_condition;
nua_event_t next_event, last_event;
nua_t *nua;
......
......@@ -57,9 +57,6 @@ int test_register_to_proxy(struct context *ctx)
sip_cseq_t cseq[1];
int seen_401;
if (ctx->p)
test_proxy_set_expiration(ctx->p, 5, 5, 10);
if (print_headings)
printf("TEST NUA-2.3.0.1: un-REGISTER a\n");
......@@ -108,7 +105,6 @@ int test_register_to_proxy(struct context *ctx)
if (print_headings)
printf("TEST NUA-2.3.0.3: PASSED\n");
/* REGISTER test
A B
......@@ -123,6 +119,8 @@ int test_register_to_proxy(struct context *ctx)
if (print_headings)
printf("TEST NUA-2.3.1: REGISTER a\n");
test_proxy_domain_set_expiration(ctx->a.domain, 5, 5, 10);
TEST_1(a_reg->nh = nua_handle(a->nua, a_reg, TAG_END()));
sip_cseq_init(cseq)->cs_seq = 12;
......@@ -184,12 +182,16 @@ int test_register_to_proxy(struct context *ctx)
TEST_1(e = a->specials->head);
}
test_proxy_domain_set_expiration(ctx->a.domain, 600, 3600, 36000);
if (print_headings)
printf("TEST NUA-2.3.1: PASSED\n");
if (print_headings)
printf("TEST NUA-2.3.2: REGISTER b\n");
test_proxy_domain_set_expiration(ctx->b.domain, 5, 5, 10);
TEST_1(b_reg->nh = nua_handle(b->nua, b_reg, TAG_END()));
/* Test application-supplied contact */
......@@ -237,14 +239,14 @@ int test_register_to_proxy(struct context *ctx)
if (print_headings)
printf("TEST NUA-2.3.2: PASSED\n");
if (ctx->p) {
test_proxy_close_tports(ctx->p);
test_proxy_set_expiration(ctx->p, 600, 3600, 36000);
}
test_proxy_domain_set_expiration(ctx->b.domain, 600, 3600, 36000);
if (print_headings)
printf("TEST NUA-2.3.3: REGISTER c\n");
test_proxy_domain_set_expiration(ctx->c.domain, 600, 3600, 36000);
test_proxy_domain_set_authorize(ctx->c.domain, 2);
TEST_1(c_reg->nh = nua_handle(c->nua, c_reg, TAG_END()));
REGISTER(c, c_reg, c_reg->nh, SIPTAG_TO(c->to),
......@@ -279,7 +281,12 @@ int test_register_to_proxy(struct context *ctx)
TEST_1(sip = sip_object(e->data->e_msg));
TEST(sip->sip_status->st_status, 423);
TEST_1(e = e->next);
TEST(e->data->e_status, 200);
if (e->data->e_status == 100 && e->data->e_event == nua_r_register) {
TEST_1(sip = sip_object(e->data->e_msg));
TEST(sip->sip_status->st_status, 401);
TEST_1(e = e->next);
}
TEST(e->data->e_status, 200); TEST_E(e->data->e_event, nua_r_register);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_display, "C");
......@@ -366,6 +373,30 @@ int test_register_to_proxy(struct context *ctx)
if (print_headings)
printf("TEST NUA-2.3.4: PASSED\n");
if (!ctx->p)
return 0;
if (print_headings)
printf("TEST NUA-2.3.5: re-REGISTER when TCP connection is closed\n");
test_proxy_close_tports(ctx->p);
run_b_until(ctx, -1, save_until_final_response);
TEST_1(e = b->events->head);
TEST_E(e->data->e_event, nua_r_register);
if (e->data->e_status == 100)
TEST_1(e = e->next);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_expires, "3600");
TEST_1(!e->next);
free_events_in_list(ctx, b->events);
if (print_headings)
printf("TEST NUA-2.3.5: PASSED\n");
END();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment