summaryrefslogtreecommitdiff
path: root/test/auth.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@redhat.com>2022-07-12 15:53:50 +0100
committerJoe Orton <jorton@redhat.com>2022-07-20 14:05:04 +0100
commit2b8e2e4e3568d10cdb3ef07b3ae4c699540479ea (patch)
tree996df0e2b2d6c37eeed146a05f31b1c42bc4d723 /test/auth.c
parent93faea82fe49bfcf22d99c0e9f954ae714315de5 (diff)
downloadneon-git-2b8e2e4e3568d10cdb3ef07b3ae4c699540479ea.tar.gz
* src/ne_auth.c: Abstract out hash algorithm handling for Digest.
(struct hashalg): New structure, replacing auth_algorithm enum, alg_to_hash and alg_to_name arrays. (struct auth_challenge): Use hashalg pointer. (get_digest_h_urp, digest_challenge): Adjust accordingly. * test/auth.c (digest_failures, fail_challenge): Tweak tests to reliably trigger desired failure cases.
Diffstat (limited to 'test/auth.c')
-rw-r--r--test/auth.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/auth.c b/test/auth.c
index e985703..d0f1f8c 100644
--- a/test/auth.c
+++ b/test/auth.c
@@ -1085,26 +1085,30 @@ static int digest_failures(void)
parms.realm = "WallyWorld";
parms.nonce = "random-invented-string";
parms.opaque = NULL;
- parms.flags = PARM_AINFO;
parms.num_requests = 1;
for (n = 0; fails[n].message; n++) {
ne_session *sess;
int ret;
+ unsigned protocol = NE_AUTH_DIGEST;
parms.failure = fails[n].mode;
+ parms.flags = PARM_AINFO;
+
+ if (parms.failure == fail_req0_2069_stale) protocol |= NE_AUTH_LEGACY_DIGEST;
if (parms.failure == fail_req0_2069_stale || parms.failure == fail_2069_weak)
parms.flags &= ~PARM_RFC2617;
else
parms.flags |= PARM_RFC2617;
- NE_DEBUG(NE_DBG_HTTP, ">>> New Digest failure test, "
- "expecting failure '%s'\n", fails[n].message);
+ NE_DEBUG(NE_DBG_HTTP, ">>> New Digest failure test %u, "
+ "expecting failure '%s', protocol %x\n", n,
+ fails[n].message, protocol);
CALL(session_server(&sess, serve_digest, &parms));
- ne_set_server_auth(sess, auth_cb, NULL);
+ ne_add_server_auth(sess, protocol, auth_cb, NULL);
ret = any_2xx_request(sess, "/fish");
ONV(ret == NE_OK,
@@ -1170,7 +1174,7 @@ static int fail_challenge(void)
"domain=\"http://[::1/\"", "could not parse domain" },
/* Multiple challenge failure cases: */
- { "Basic, Digest",
+ { "Basic, Digest realm=\"foo\", algorithm=MD5, qop=auth",
"missing parameter in Digest challenge, missing realm in Basic challenge" },
{ "Digest realm=\"foo\", algorithm=MD5, qop=auth, nonce=\"foo\","