aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-06-22 00:51:18 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2008-06-22 00:51:18 +0100
commit98de2cca016d458ad2980c59f334fae10164b3bb (patch)
tree09ba75f3fd231a9256a234c66bf896b84f01e6fe /tests
parent3e6764ab9c8ebd99683fd3c153161d96b32e05de (diff)
Now preserving case in JID resources, and handling them with case sensitivity
since apparently that's how the RFC wants it. (While the rest of the JID should be case IN-sensitive. Consistency is hard to find these days...) Also extended the unittests a little bit. Closes #422.
Diffstat (limited to 'tests')
-rw-r--r--tests/check_jabber_util.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/tests/check_jabber_util.c b/tests/check_jabber_util.c
index 2d54ed23..4728c5ee 100644
--- a/tests/check_jabber_util.c
+++ b/tests/check_jabber_util.c
@@ -10,47 +10,61 @@ static struct im_connection *ic;
static void check_buddy_add(int l)
{
- struct jabber_buddy *budw1, *budw2, *budw3, *budw4, *budn;
- int i;
+ struct jabber_buddy *budw1, *budw2, *budw3, *budn, *bud;
budw1 = jabber_buddy_add( ic, "wilmer@gaast.net/BitlBee" );
budw1->last_act = time( NULL ) - 100;
- budw2 = jabber_buddy_add( ic, "wilmer@gaast.net/Telepathy" );
+ budw2 = jabber_buddy_add( ic, "WILMER@gaast.net/Telepathy" );
budw2->priority = 2;
budw2->last_act = time( NULL );
- budw3 = jabber_buddy_add( ic, "wilmer@gaast.net/Druif" );
+ budw3 = jabber_buddy_add( ic, "wilmer@GAAST.NET/bitlbee" );
budw3->last_act = time( NULL ) - 200;
budw3->priority = 4;
/* TODO(wilmer): Shouldn't this just return budw3? */
- fail_if( jabber_buddy_add( ic, "wilmer@gaast.net/druif" ) != NULL );
+ fail_if( jabber_buddy_add( ic, "wilmer@gaast.net/Telepathy" ) != NULL );
budn = jabber_buddy_add( ic, "nekkid@lamejab.net" );
/* Shouldn't be allowed if there's already a bare JID. */
fail_if( jabber_buddy_add( ic, "nekkid@lamejab.net/Illegal" ) );
+ /* Case sensitivity: Case only matters after the / */
+ fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net/BitlBee", 0 ) ==
+ jabber_buddy_by_jid( ic, "wilmer@gaast.net/bitlbee", 0 ) );
+ fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net/telepathy", 0 ) );
+
fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net/BitlBee", 0 ) == budw1 );
- fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net/bitlbee", GET_BUDDY_EXACT ) == budw1 );
- fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net/BitlBee", GET_BUDDY_CREAT ) == budw1 );
+ fail_unless( jabber_buddy_by_jid( ic, "WILMER@GAAST.NET/BitlBee", GET_BUDDY_EXACT ) == budw1 );
+ fail_unless( jabber_buddy_by_jid( ic, "wilmer@GAAST.NET/BitlBee", GET_BUDDY_CREAT ) == budw1 );
fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_EXACT ) );
- fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_FIRST ) == budw1 );
- fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw3 );
+ fail_unless( jabber_buddy_by_jid( ic, "WILMER@gaast.net", 0 ) == budw3 );
+
+ /* Check O_FIRST and see if it's indeed the first item from the list. */
+ fail_unless( ( bud = jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_FIRST ) ) == budw1 );
+ fail_unless( bud->next == budw2 && bud->next->next == budw3 && bud->next->next->next == NULL );
+ /* Change the resource_select setting, now we should get a different resource. */
set_setstr( &ic->acc->set, "resource_select", "activity" );
- fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw2 );
+ fail_unless( jabber_buddy_by_jid( ic, "wilmer@GAAST.NET", 0 ) == budw2 );
+ /* Some testing of bare JID handling (which is horrible). */
fail_if( jabber_buddy_by_jid( ic, "nekkid@lamejab.net/Illegal", 0 ) );
- fail_if( jabber_buddy_by_jid( ic, "nekkid@lamejab.net/Illegal", GET_BUDDY_CREAT ) );
+ fail_if( jabber_buddy_by_jid( ic, "NEKKID@LAMEJAB.NET/Illegal", GET_BUDDY_CREAT ) );
fail_unless( jabber_buddy_by_jid( ic, "nekkid@lamejab.net", 0 ) == budn );
- fail_unless( jabber_buddy_by_jid( ic, "nekkid@lamejab.net", GET_BUDDY_EXACT ) == budn );
- fail_unless( jabber_buddy_by_jid( ic, "nekkid@lamejab.net", GET_BUDDY_CREAT ) == budn );
+ fail_unless( jabber_buddy_by_jid( ic, "NEKKID@lamejab.net", GET_BUDDY_EXACT ) == budn );
+ fail_unless( jabber_buddy_by_jid( ic, "nekkid@LAMEJAB.NET", GET_BUDDY_CREAT ) == budn );
- jabber_buddy_remove( ic, "wilmer@gaast.net/telepathy" );
+ /* More case sensitivity testing, and see if remove works properly. */
+ fail_if( jabber_buddy_remove( ic, "wilmer@gaast.net/telepathy" ) );
+ fail_if( jabber_buddy_by_jid( ic, "wilmer@GAAST.NET/telepathy", GET_BUDDY_CREAT ) == budw2 );
+ fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/Telepathy" ) );
+ fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/telepathy" ) );
fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw1 );
fail_if( jabber_buddy_remove( ic, "wilmer@gaast.net" ) );
fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw1 );
+ /* Check if remove_bare() indeed gets rid of all. */
fail_unless( jabber_buddy_remove_bare( ic, "wilmer@gaast.net" ) );
fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) );