s4-tort: Test handling of different ATTID values in prefixMap interface.
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Fri, 18 Dec 2009 23:48:41 +0000 (01:48 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 21 Dec 2009 12:45:12 +0000 (23:45 +1100)
It turns out ATTID values are separated in ranges.
Ref: MS-ADTS, 3.1.1.2.6 ATTRTYP

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/torture/drs/unit/prefixmap_tests.c

index b2449d285a6a0f47416522f7b3b8ce8acab1e0c1..4bfdcc0d8b49ff8bb6e50c3023f279df716ec054 100644 (file)
@@ -382,6 +382,48 @@ static bool torture_drs_unit_pfm_oid_from_attid(struct torture_context *tctx, st
        return true;
 }
 
+/**
+ * Tests dsdb_schema_pfm_oid_from_attid() for handling
+ * correctly different type of attid values.
+ * See: MS-ADTS, 3.1.1.2.6 ATTRTYP
+ */
+static bool torture_drs_unit_pfm_oid_from_attid_check_attid(struct torture_context *tctx,
+                                                           struct drsut_prefixmap_data *priv)
+{
+       WERROR werr;
+       const char *oid;
+
+       /* Test with valid prefixMap attid */
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0x00000000, tctx, &oid);
+       torture_assert_werr_ok(tctx, werr, "Testing prefixMap type attid = 0x0000000");
+
+       /* Test with attid in msDS-IntId range */
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0x80000000, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing msDS-IntId type attid = 0x80000000");
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0xBFFFFFFF, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing msDS-IntId type attid = 0xBFFFFFFF");
+
+       /* Test with attid in RESERVED range */
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0xC0000000, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing RESERVED type attid = 0xC0000000");
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0xFFFEFFFF, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing RESERVED type attid = 0xFFFEFFFF");
+
+       /* Test with attid in INTERNAL range */
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0xFFFF0000, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing INTERNAL type attid = 0xFFFF0000");
+       werr = dsdb_schema_pfm_oid_from_attid(priv->pfm_full, 0xFFFFFFFF, tctx, &oid);
+       torture_assert_werr_equal(tctx, werr, WERR_INVALID_PARAMETER,
+                                 "Testing INTERNAL type attid = 0xFFFFFFFF");
+
+       return true;
+}
+
 /**
  * Test Schema prefixMap conversions to/from drsuapi prefixMap
  * representation.
@@ -721,6 +763,8 @@ struct torture_tcase * torture_drs_unit_prefixmap(struct torture_suite *suite)
        torture_tcase_add_simple_test(tc, "make_attid_full_map", (pfn_run)torture_drs_unit_pfm_make_attid_full_map);
        torture_tcase_add_simple_test(tc, "make_attid_small_map", (pfn_run)torture_drs_unit_pfm_make_attid_small_map);
        torture_tcase_add_simple_test(tc, "oid_from_attid_full_map", (pfn_run)torture_drs_unit_pfm_oid_from_attid);
+       torture_tcase_add_simple_test(tc, "oid_from_attid_check_attid",
+                                     (pfn_run)torture_drs_unit_pfm_oid_from_attid_check_attid);
 
        torture_tcase_add_simple_test(tc, "pfm_to_from_drsuapi", (pfn_run)torture_drs_unit_pfm_to_from_drsuapi);