summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-08-18 04:44:24 +0000
committerNick Mathewson <nickm@torproject.org>2004-08-18 04:44:24 +0000
commit86980cf6e232dd30de59bec2c32e0a85c81eb1d2 (patch)
tree68b23af0d396f5b063638b3e9c4f50a33a4473b0 /src/or/test.c
parentadccf3aea6ef7d33bd5cfcd322d5168b2c12415b (diff)
downloadtor-86980cf6e232dd30de59bec2c32e0a85c81eb1d2.tar.gz
tor-86980cf6e232dd30de59bec2c32e0a85c81eb1d2.zip
Functions to test nickname validity
svn:r2269
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 80167bc57c..d9badb7462 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -758,6 +758,26 @@ test_dir_format()
test_assert(! crypto_pk_generate_key(pk2));
test_assert(! crypto_pk_generate_key(pk3));
+ test_assert( is_legal_nickname("a"));
+ test_assert(!is_legal_nickname(""));
+ test_assert(!is_legal_nickname("abcdefghijklmnopqrst")); /* 20 chars */
+ test_assert(!is_legal_nickname("abcdefghijklmnopqrst")); /* 20 chars */
+ test_assert(!is_legal_nickname("hyphen-")); /* bad char */
+ test_assert( is_legal_nickname("abcdefghijklmnopqrs")); /* 19 chars */
+ test_assert(!is_legal_nickname("$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
+ /* valid */
+ test_assert( is_legal_nickname_or_hexdigest(
+ "$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
+ /* too short */
+ test_assert(!is_legal_nickname_or_hexdigest(
+ "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
+ /* illegal char */
+ test_assert(!is_legal_nickname_or_hexdigest(
+ "$AAAAAAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
+ test_assert(is_legal_nickname_or_hexdigest("xyzzy"));
+ test_assert(is_legal_nickname_or_hexdigest("abcdefghijklmnopqrs"));
+ test_assert(!is_legal_nickname_or_hexdigest("abcdefghijklmnopqrst"));
+
get_platform_str(platform, sizeof(platform));
r1.address = "testaddr1.foo.bar";