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 @sasjslint {"maxLineLength": 110}
19
20**/
21
22data work.check;
23 length val $64;
24 /* valid: a plain libds */
25 exp=1; val='WORK.CLASS'; output;
26 exp=1; val='DC.MPE_TABLES'; output;
27 exp=1; val='_A._B'; output;
28 /* valid: the format-catalog form, however the suffix is cased */
29 exp=1; val='DCTEST.DCFMTS-FC'; output;
30 exp=1; val='dctest.dcfmts-fc'; output;
31 exp=1; val='WORK.CLASS-FC'; output;
32 /* valid: padded values are trimmed before the check */
33 exp=1; val='WORK.CLASS '; output;
34 /* invalid: not a libds at all */
35 exp=0; val='WORK'; output;
36 exp=0; val='WORK.CLASS.NOPE'; output;
37 exp=0; val=''; output;
38 exp=0; val='-FC'; output;
39 exp=0; val='../secprobe'; output;
40 /* invalid: the dash suffix is not exactly -FC */
41 exp=0; val='WORK.CLASS-FCX'; output;
42 exp=0; val='WORK.CLASS-C'; output;
43 exp=0; val='WORK.CLASS-FC X'; output;
44 /* invalid: content smuggled past a valid libds prefix */
45 exp=0; val="WORK.CLASS-FC'"; output;
46 exp=0; val='WORK.CLASS-FC;proc sql;'; output;
47 exp=0; val='WORK.CLASS-FC) or 1=1'; output;
48 exp=0; val='WORK.CLASS-fc-'; output;
49run;
50
51data work.check;
52 set work.check;
53 is_libds=0;
54 %mpe_validatecol(val,LIBDS,is_libds)
55 got=is_libds;
56 if got ne exp then putlog 'ERR' 'OR: unexpected result for [' val +(-1) ']';
57run;
58
59data work.mismatch;
60 set work.check;
61 where got ne exp;
62run;
63
64%mp_assertdsobs(work.mismatch,
65 desc=%str(Every LIBDS value validated as expected (catalog form permitted, nothing smuggled past the dash)),
66 test=EQUALS 0,
67 outds=work.test_results
68)
69
70/* dump for offline inspection */
71data _null_;
72 set work.check;
73 putlog 'TEST_RESULT_LINE: [' val +(-1) '] exp=' exp 'got=' got;
74run;