From: <svn...@op...> - 2009-02-19 17:30:30
|
Author: bellmich Date: Thu Feb 19 18:31:09 2009 New Revision: 938 URL: http://libsyncml.opensync.org/changeset/938 Log: fixed the OMA DS 1.2 SAN tests This is necessary because there was a massive update of the according implementation which includes digest/authentication support and fixed identifiers. Modified: trunk/tests/check_san.c Modified: trunk/tests/check_san.c ============================================================================== --- trunk/tests/check_san.c Thu Feb 19 18:29:24 2009 (r937) +++ trunk/tests/check_san.c Thu Feb 19 18:31:09 2009 (r938) @@ -76,11 +76,15 @@ sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); - unsigned char target[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + unsigned char target[] = { + /* old implementation without digest support + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + */ + 0x95, 0x5d, 0x6f, 0x61, 0xa4, 0x20, 0xb1, 0xa7, 0x46, 0x00, 0xc1, 0x12, 0x81, 0x06, 0x5e, 0x64, //DIGEST 0x03, 0x00, //version + ui + init + start of future 0x00, 0x00, 0x00, //Future 0x00, 0x00, //Session id - 0x05, 0x74, 0x74, 0x74, 0x74, 0x00, //server identifier + 0x04, 0x74, 0x74, 0x74, 0x74, //server identifier 0x00}; // num syncs + future char *buffer = NULL; @@ -105,11 +109,15 @@ sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); - unsigned char target[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + unsigned char target[] = { + /* old implementation without digest support + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + */ + 0x9e, 0x0d, 0x43, 0x31, 0x4f, 0x18, 0xb6, 0x96, 0x6d, 0x88, 0xf1, 0xa2, 0xdb, 0x00, 0x06, 0x15, //DIGEST 0x03, 0x38, //version + ui + init + start of future 0x00, 0x00, 0x00, //Future 0xFF, 0xFF, //Session id - 0x06, 0x74, 0x74, 0x74, 0x74, 0x74, 0x00, //server identifier + 0x05, 0x74, 0x74, 0x74, 0x74, 0x74, //server identifier 0x00}; // num syncs + future char *buffer = NULL; @@ -137,15 +145,19 @@ sml_fail_unless(smlNotificationNewAlert(san, SML_ALERT_TWO_WAY_BY_SERVER, SML_ELEMENT_TEXT_VCARD, "tttt", &error), NULL); sml_fail_unless(error == NULL, NULL); - unsigned char target[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + unsigned char target[] = { + /* old implementation without digest support + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + */ + 0x7e, 0x39, 0x00, 0x91, 0x5e, 0x39, 0x3a, 0x69, 0xd2, 0x60, 0x18, 0x1f, 0x65, 0x65, 0x49, 0xe5, //DIGEST 0x03, 0x38, //version + ui + init + start of future 0x00, 0x00, 0x00, //Future 0xFF, 0xFF, //Session id - 0x06, 0x74, 0x74, 0x74, 0x74, 0x74, 0x00, //server identifier + 0x05, 0x74, 0x74, 0x74, 0x74, 0x74, //server identifier 0x10,// num syncs + future 0x60, //Sync type + future 0x00, 0x00, 0x07, //Content type - 0x05, 0x74, 0x74, 0x74, 0x74, 0x00 }; //Server URI; + 0x04, 0x74, 0x74, 0x74, 0x74}; //Server URI; char *buffer = NULL; unsigned int size = 0; @@ -175,18 +187,66 @@ sml_fail_unless(smlNotificationNewAlert(san, SML_ALERT_REFRESH_FROM_SERVER_BY_SERVER, SML_ELEMENT_TEXT_VCARD, "tttt", &error), NULL); sml_fail_unless(error == NULL, NULL); - unsigned char target[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + unsigned char target[] = { + /* old implementation without digest support + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //DIGEST + */ + 0x6d, 0x47, 0xd6, 0x78, 0xb2, 0xe0, 0xa3, 0x72, 0x75, 0x03, 0xcc, 0xae, 0xd0, 0x39, 0x3d, 0xea, //DIGEST 0x03, 0x38, //version + ui + init + start of future 0x00, 0x00, 0x00, //Future 0xFF, 0xFF, //Session id - 0x06, 0x74, 0x74, 0x74, 0x74, 0x74, 0x00, //server identifier + 0x05, 0x74, 0x74, 0x74, 0x74, 0x74, //server identifier 0x20,// num syncs + future 0x60, //Sync type + future 0x00, 0x00, 0x07, //Content type - 0x05, 0x74, 0x74, 0x74, 0x74, 0x00, //Server URI; + 0x04, 0x74, 0x74, 0x74, 0x74, //Server URI; 0xA0, //Sync type + future 0x00, 0x00, 0x07, //Content type - 0x05, 0x74, 0x74, 0x74, 0x74, 0x00 }; //Server URI; + 0x04, 0x74, 0x74, 0x74, 0x74}; //Server URI; + + char *buffer = NULL; + unsigned int size = 0; + sml_fail_unless(smlNotificationAssemble(san, &buffer, &size, &error), NULL); + sml_fail_unless(error == NULL, NULL); + + sml_fail_unless(size == sizeof(target), NULL); + sml_fail_unless(memcmp(target, buffer, size) == 0, NULL); + + g_free(buffer); + smlNotificationFree(san); +} +END_TEST + +START_TEST (check_san_alert_auth) +{ + setup_testbed(NULL); + + SmlError *error = NULL; + SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "OpenSync", "/", SML_MIMETYPE_UNKNOWN, &error); + sml_fail_unless(san != NULL, NULL); + sml_fail_unless(error == NULL, NULL); + + sml_fail_unless(smlNotificationNewAlert(san, SML_ALERT_TWO_WAY_BY_SERVER, SML_ELEMENT_TEXT_VCARD, "contacts", &error), NULL); + sml_fail_unless(error == NULL, NULL); + + SmlCred *cred = smlCredNewAuth( + SML_AUTH_TYPE_MD5, + "username", + "password", + &error); + smlNotificationSetCred(san, cred); + smlCredUnref(cred); + + unsigned char target[] = { + 0x61, 0x59, 0x71, 0x16, 0x2e, 0x7d, 0x3e, 0x83, 0xa8, 0x23, 0x48, 0xa8, 0x5b, 0x21, 0x79, 0x49, //DIGEST + 0x03, 0x38, //version + ui + init + start of future + 0x00, 0x00, 0x00, //Future + 0xFF, 0xFF, //Session id + 0x08, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x79, 0x6e, 0x63, //server identifier + 0x10,// num syncs + future + 0x60, //Sync type + future + 0x00, 0x00, 0x07, //Content type + 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73}; //Server URI; char *buffer = NULL; unsigned int size = 0; @@ -508,6 +568,7 @@ create_case(s, "check_san_empty2", check_san_empty2); create_case(s, "check_san_alert", check_san_alert); create_case(s, "check_san_alert2", check_san_alert2); + create_case(s, "check_san_alert_auth", check_san_alert_auth); create_case(s, "check_san_parse", check_san_parse); create_case(s, "check_san_parse2", check_san_parse2); #ifdef ENABLE_HTTP |