Commit 3d4b690f authored by Pekka Pessi's avatar Pekka Pessi

nua/test_proxy.[hc], nua/test_register.c: test support of multiple realms.

darcs-hash:20071116152900-65a35-6a44ba4c24fb7981341c6a8edba07c376dbc5021.gz
parent cb91cfcb
......@@ -134,7 +134,7 @@ struct domain {
struct {
sip_time_t min_expires, expires, max_expires;
int outbound_tcp; /**< Use inbound TCP connection as outbound */
int authorize;
char const *authorize; /**< Authorization realm to use */
} prefs;
tagi_t *tags;
......@@ -216,6 +216,7 @@ struct proxy_tr
auth_mod_t *am; /* Authentication module */
auth_status_t *as; /* Authentication status */
char const *realm; /* Authentication realm to use */
unsigned use_auth; /* Authentication method (401/407) to use */
unsigned rr:1;
......@@ -473,20 +474,33 @@ void test_proxy_domain_get_outbound(struct domain *d,
}
}
void test_proxy_domain_set_authorize(struct domain *d, int authorize)
int test_proxy_domain_set_authorize(struct domain *d,
char const *realm)
{
if (d) {
d->prefs.authorize = authorize;
if (realm) {
realm = su_strdup(d->home, realm);
if (!realm)
return -1;
}
d->prefs.authorize = realm;
return 0;
}
return -1;
}
void test_proxy_domain_get_authorize(struct domain *d,
int *return_authorize)
int test_proxy_domain_get_authorize(struct domain *d,
char const **return_realm)
{
if (d) {
if (return_authorize)
*return_authorize = d->prefs.authorize;
if (return_realm) {
*return_realm = d->prefs.authorize;
return 0;
}
}
return -1;
}
int test_proxy_close_tports(struct proxy *p)
......@@ -533,7 +547,7 @@ struct domain *test_proxy_add_domain(struct proxy *p,
d->prefs.expires = 3600;
d->prefs.max_expires = 36000;
d->prefs.outbound_tcp = 0;
d->prefs.authorize = 0;
d->prefs.authorize = NULL;
if (d->uri && d->tags &&
!su_task_execute(su_clone_task(p->clone), _domain_init, d, &init)) {
......@@ -795,6 +809,7 @@ static int originating_transaction(struct proxy_tr *t)
if (o && o->auth && o->prefs.authorize) {
t->am = o->auth;
t->realm = o->prefs.authorize;
t->use_auth = 407;
}
......@@ -966,6 +981,7 @@ static int challenge_transaction(struct proxy_tr *t)
as->as_method = sip->sip_request->rq_method_name;
as->as_source = msg_addrinfo(t->msg);
as->as_realm = t->realm;
as->as_user_uri = sip->sip_from->a_url;
as->as_display = sip->sip_from->a_display;
......
......@@ -64,8 +64,9 @@ void test_proxy_get_session_timer(struct proxy *p,
sip_time_t *return_session_expires,
sip_time_t *return_min_se);
void test_proxy_domain_set_authorize(struct domain *d, int authorize);
void test_proxy_domain_get_authorize(struct domain *d, int *return_authorize);
int test_proxy_domain_set_authorize(struct domain *, char const *realm);
int test_proxy_domain_get_authorize(struct domain *,
char const **return_realm);
void test_proxy_domain_set_outbound(struct domain *d,
int use_outbound);
......
......@@ -426,7 +426,7 @@ int test_register_c(struct context *ctx)
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_proxy_domain_set_authorize(ctx->c.domain, "test-proxy");
TEST_1(c_reg->nh = nua_handle(c->nua, c_reg, TAG_END()));
......@@ -778,9 +778,26 @@ int test_connectivity(struct context *ctx)
free_events_in_list(ctx, c->events);
/* Sneakily change the realm */
TEST(test_proxy_domain_set_authorize(ctx->c.domain, "test-proxy-2"), 0);
AUTHENTICATE(c, c_call, c_call->nh,
NUTAG_AUTH("Digest:\"test-proxy\":charlie:secret"),
TAG_END());
run_abc_until(ctx, -1, NULL, -1, NULL, -1, save_until_final_response);
/* Client events: nua_options(), nua_r_options */
TEST_1(e = c->events->head); TEST_E(e->data->e_event, nua_r_options);
TEST(e->data->e_status, 407);
TEST_1(!e->next);
free_events_in_list(ctx, c->events);
AUTHENTICATE(c, c_call, c_call->nh,
NUTAG_AUTH("Digest:\"test-proxy-2\":charlie:secret"),
TAG_END());
}
run_abc_until(ctx, -1, save_until_received,
......
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