Loading...
Searching...
No Matches
mpe_validatecol.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing the mpe_validatecol macro (LIBDS rule)
4 @details The LIBDS rule must accept the Data Controller format-catalog
5 reference (LIBREF.CATALOGNAME-FC) and reject everything else - including
6 a value that merely *starts* with a valid libds and continues past the
7 dash, which a bare scan on the dash would let through.
8
9 <h4> SAS Macros </h4>
10 @li mpe_validatecol.sas
11 @li mp_assertdsobs.sas
12
13 @author 4GL Apps Ltd
14 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
15 and may not be re-distributed or re-sold without the express permission of
16 4GL Apps Ltd.
17
18**/
19
20data work.check;
21 length val $64;
22 /* valid: a plain libds */
23 exp=1; val='WORK.CLASS'; output;
24 exp=1; val='DC.MPE_TABLES'; output;
25 exp=1; val='_A._B'; output;
26 /* valid: the format-catalog form, however the suffix is cased */
27 exp=1; val='DCTEST.DCFMTS-FC'; output;
28 exp=1; val='dctest.dcfmts-fc'; output;
29 exp=1; val='WORK.CLASS-FC'; output;
30 /* valid: padded values are trimmed before the check */
31 exp=1; val='WORK.CLASS '; output;
32 /* invalid: not a libds at all */
33 exp=0; val='WORK'; output;
34 exp=0; val='WORK.CLASS.NOPE'; output;
35 exp=0; val=''; output;
36 exp=0; val='-FC'; output;
37 exp=0; val='../secprobe'; output;
38 /* invalid: the dash suffix is not exactly -FC */
39 exp=0; val='WORK.CLASS-FCX'; output;
40 exp=0; val='WORK.CLASS-C'; output;
41 exp=0; val='WORK.CLASS-FC X'; output;
42 /* invalid: content smuggled past a valid libds prefix */
43 exp=0; val="WORK.CLASS-FC'"; output;
44 exp=0; val='WORK.CLASS-FC;proc sql;'; output;
45 exp=0; val='WORK.CLASS-FC) or 1=1'; output;
46 exp=0; val='WORK.CLASS-fc-'; output;
47run;
48
49data work.check;
50 set work.check;
51 is_libds=0;
52 %mpe_validatecol(val,LIBDS,is_libds)
53 got=is_libds;
54 if got ne exp then putlog 'ERR' 'OR: unexpected result for [' val +(-1) ']';
55run;
56
57data work.mismatch;
58 set work.check;
59 where got ne exp;
60run;
61
62%mp_assertdsobs(work.mismatch,
63 desc=Every LIBDS value validated as expected (catalog form permitted, nothing smuggled past the dash),
64 test=EQUALS 0,
65 outds=work.test_results
66)
67
68/* dump for offline inspection */
69data _null_;
70 set work.check;
71 putlog 'TEST_RESULT_LINE: [' val +(-1) '] exp=' exp 'got=' got;
72run;