summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-26 01:32:40 +0300
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-01 23:13:00 +0200
commit97e7f48f7504132ca7f661c6ed56905c235f5715 (patch)
tree43c42ce6432570cc8f88a13bfa6429c8b5cff547 /lib
parent5021301a0e6a15de5552583b1ffeb66619d398d8 (diff)
downloadsamba-97e7f48f7504132ca7f661c6ed56905c235f5715.tar.gz
samba-97e7f48f7504132ca7f661c6ed56905c235f5715.tar.bz2
samba-97e7f48f7504132ca7f661c6ed56905c235f5715.zip
s4/asn1: Added test for ber_read_partial_OID_String()
Diffstat (limited to 'lib')
-rw-r--r--lib/util/tests/asn1_tests.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/util/tests/asn1_tests.c b/lib/util/tests/asn1_tests.c
index 633a9346b4..bc7af85306 100644
--- a/lib/util/tests/asn1_tests.c
+++ b/lib/util/tests/asn1_tests.c
@@ -195,6 +195,48 @@ static bool test_ber_write_partial_OID_String(struct torture_context *tctx)
return true;
}
+/* Testing ber_read_partial_OID_String() function */
+static bool test_ber_read_partial_OID_String(struct torture_context *tctx)
+{
+ int i;
+ const char *oid;
+ DATA_BLOB oid_blob;
+ TALLOC_CTX *mem_ctx;
+ struct oid_data *data = oid_data_ok;
+
+ mem_ctx = talloc_new(tctx);
+
+ /* ber_read_partial_OID_String() should work with not partial OIDs also */
+ for (i = 0; i < ARRAY_SIZE(oid_data_ok); i++) {
+ oid_blob = strhex_to_data_blob(mem_ctx, data[i].bin_oid);
+
+ torture_assert(tctx, ber_read_partial_OID_String(mem_ctx, oid_blob, &oid),
+ "ber_read_partial_OID_String failed");
+
+ torture_assert(tctx, strequal(data[i].oid, oid),
+ talloc_asprintf(mem_ctx,
+ "Failed: oid=%s, bin_oid:%s",
+ data[i].oid, data[i].bin_oid));
+ }
+
+ /* ber_read_partial_OID_String() test with partial OIDs */
+ data = partial_oid_data_ok;
+ for (i = 0; i < ARRAY_SIZE(partial_oid_data_ok); i++) {
+ oid_blob = strhex_to_data_blob(mem_ctx, data[i].bin_oid);
+
+ torture_assert(tctx, ber_read_partial_OID_String(mem_ctx, oid_blob, &oid),
+ "ber_read_partial_OID_String failed");
+
+ torture_assert(tctx, strequal(data[i].oid, oid),
+ talloc_asprintf(mem_ctx,
+ "Failed: oid=%s, bin_oid:%s",
+ data[i].oid, data[i].bin_oid));
+ }
+
+ talloc_free(mem_ctx);
+
+ return true;
+}
/* LOCAL-ASN1 test suite creation */
@@ -211,5 +253,8 @@ struct torture_suite *torture_local_util_asn1(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "ber_write_partial_OID_String",
test_ber_write_partial_OID_String);
+ torture_suite_add_simple_test(suite, "ber_read_partial_OID_String",
+ test_ber_read_partial_OID_String);
+
return suite;
}