Commit 9ef1f442 authored by Niels Möller's avatar Niels Möller

Added one more test.

Rev: src/testsuite/Makefile.am:1.3
Rev: src/testsuite/macros.m4:1.3
Rev: src/testsuite/spki-tag-test.m4:1.1
parent a4d41497
# Testsuite
TESTS = des-test
TESTS = des-test spki-tag-test
# SUFFIXES = .c .o
noinst_PROGRAMS = $(TESTS)
......@@ -11,6 +11,7 @@ EXTRA_DIST = macros.m4 $(SOURCES:.c=.m4)
all:
@echo make check to build testprograms.
M4FLAGS = -P #-s
%.c: macros.m4 %.m4
$(M4) -s -P $^ > $@
$(M4) $(M4FLAGS) $^ > $@
......@@ -11,7 +11,14 @@ TS_DEFINE(
TS_DEFINE(TS_OK, TS_WRITE(ok.\n))
TS_DEFINE(TS_FAIL, { TS_WRITE(failed.\n); exit(1); })
TS_DEFINE(TS_TEST_STRING_EQ,
TS_DEFINE(TS_STRING,
m4_ifelse(m4_index($1, "), 0,
ssh_format("%lz", $1), simple_decode_hex("m4_translit($1, 0-9a-zA-Z #, 0-9a-zA-Z)")) )
TS_DEFINE(TS_SEXP, string_to_sexp(TS_STRING($1), 1))
TS_DEFINE(TS_TEST_STRING_EQ,
{
struct lsh_string *a, *b;
TS_MESSAGE($1)
......@@ -25,10 +32,6 @@ TS_DEFINE(
}
)
TS_DEFINE(TS_STRING,
m4_ifelse(m4_index($1, "), 0,
ssh_format("%lz", $1), simple_decode_hex("m4_translit($1, 0-9a-zA-Z #, 0-9a-zA-Z)")) )
m4_dnl TS_TEST_HASH(name, algorithm, data, digest)
TS_DEFINE(TS_TEST_HASH,
TS_TEST_STRING_EQ($1, hash_string($2, TS_STRING($3)), TS_STRING($4)))
......@@ -61,6 +64,45 @@ TS_DEFINE(
}
)
m4_dnl TS_TAG_GRANT(msg, tag-set, access)
TS_DEFINE(TS_TAG_GRANT,
{
struct spki_tag *tag = spki_sexp_to_tag(TS_SEXP($2), 17);
struct sexp *access = TS_SEXP($3);
TS_MESSAGE(Granting access $1)
assert(tag);
assert(access);
if (SPKI_TAG_MATCH(tag, access))
TS_OK
else
TS_FAIL
KILL(tag);
KILL(access);
})
m4_dnl TS_TAG_DENY(msg, tag-set, access)
TS_DEFINE(TS_TAG_DENY,
{
struct spki_tag *tag = spki_sexp_to_tag(TS_SEXP($2), 17);
struct sexp *access = TS_SEXP($3);
TS_MESSAGE(Denying access $1)
assert(tag);
assert(access);
if (!SPKI_TAG_MATCH(tag, access))
TS_OK
else
TS_FAIL
KILL(tag);
KILL(access);
})
m4_divert(1)
return 0;
} m4_divert
......@@ -71,6 +113,8 @@ m4_dnl C code
#include "crypto.h"
#include "digits.h"
#include "format.h"
#include "sexp.h"
#include "spki.h"
#include "xalloc.h"
#include <assert.h>
......
/* Examples taken from RFC-2693 */
TS_TAG_GRANT(1,
"(3:ftp13:ftp.clark.net3:cme(1:*3:set4:read5:write))",
"(3:ftp13:ftp.clark.net3:cme4:read)")
TS_TAG_DENY(2,
"(3:ftp13:ftp.clark.net3:cme(1:*3:set4:read5:write))",
"(3:ftp13:ftp.clark.net3:cme6:delete)")
TS_TAG_DENY(3,
"(3:ftp13:ftp.clark.net3:cme(1:*3:set4:read5:write))",
"(3:ftp13:ftp.clark.net3:cme)")
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