Tests inferred whether a service call worked by reading an outlib that a failed call never touched, so assertions ran against the previous call's tables. This adds dc_execute, which wraps mx_execute and makes each call observable: - failfast: abort as soon as the child did not complete, with its message, so the first failure is the real one - a status row per call (outstatus) so a test can assert the outcome - the child's log behind the harness debug flag, quiet otherwise testsetup reseeds the data baseline before the test library is built, makedata honours a keepme switch and getdata initialises the variables it later tests with %length, plus desc= values reworded where a comma or apostrophe unbalanced the parameter. sasjs/macros/mx_execute.sas is a TEMPORARY copy from sasjs/core#476, which adds outlogds/outstatus and stops leaving work.results in the caller WORK. Delete it and bump the dependency once that PR is released.
73 lines
2.4 KiB
SAS
73 lines
2.4 KiB
SAS
/**
|
|
@file
|
|
@brief testing the mpe_validatecol macro (LIBDS rule)
|
|
@details The LIBDS rule must accept the Data Controller format-catalog
|
|
reference (LIBREF.CATALOGNAME-FC) and reject everything else - including
|
|
a value that merely *starts* with a valid libds and continues past the
|
|
dash, which a bare scan on the dash would let through.
|
|
|
|
<h4> SAS Macros </h4>
|
|
@li mpe_validatecol.sas
|
|
@li mp_assertdsobs.sas
|
|
|
|
@author 4GL Apps Ltd
|
|
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
|
|
and may not be re-distributed or re-sold without the express permission of
|
|
4GL Apps Ltd.
|
|
|
|
**/
|
|
|
|
data work.check;
|
|
length val $64;
|
|
/* valid: a plain libds */
|
|
exp=1; val='WORK.CLASS'; output;
|
|
exp=1; val='DC.MPE_TABLES'; output;
|
|
exp=1; val='_A._B'; output;
|
|
/* valid: the format-catalog form, however the suffix is cased */
|
|
exp=1; val='DCTEST.DCFMTS-FC'; output;
|
|
exp=1; val='dctest.dcfmts-fc'; output;
|
|
exp=1; val='WORK.CLASS-FC'; output;
|
|
/* valid: padded values are trimmed before the check */
|
|
exp=1; val='WORK.CLASS '; output;
|
|
/* invalid: not a libds at all */
|
|
exp=0; val='WORK'; output;
|
|
exp=0; val='WORK.CLASS.NOPE'; output;
|
|
exp=0; val=''; output;
|
|
exp=0; val='-FC'; output;
|
|
exp=0; val='../secprobe'; output;
|
|
/* invalid: the dash suffix is not exactly -FC */
|
|
exp=0; val='WORK.CLASS-FCX'; output;
|
|
exp=0; val='WORK.CLASS-C'; output;
|
|
exp=0; val='WORK.CLASS-FC X'; output;
|
|
/* invalid: content smuggled past a valid libds prefix */
|
|
exp=0; val="WORK.CLASS-FC'"; output;
|
|
exp=0; val='WORK.CLASS-FC;proc sql;'; output;
|
|
exp=0; val='WORK.CLASS-FC) or 1=1'; output;
|
|
exp=0; val='WORK.CLASS-fc-'; output;
|
|
run;
|
|
|
|
data work.check;
|
|
set work.check;
|
|
is_libds=0;
|
|
%mpe_validatecol(val,LIBDS,is_libds)
|
|
got=is_libds;
|
|
if got ne exp then putlog 'ERR' 'OR: unexpected result for [' val +(-1) ']';
|
|
run;
|
|
|
|
data work.mismatch;
|
|
set work.check;
|
|
where got ne exp;
|
|
run;
|
|
|
|
%mp_assertdsobs(work.mismatch,
|
|
desc=%str(Every LIBDS value validated as expected (catalog form permitted, nothing smuggled past the dash)),
|
|
test=EQUALS 0,
|
|
outds=work.test_results
|
|
)
|
|
|
|
/* dump for offline inspection */
|
|
data _null_;
|
|
set work.check;
|
|
putlog 'TEST_RESULT_LINE: [' val +(-1) '] exp=' exp 'got=' got;
|
|
run;
|