mirror of
https://github.com/sasjs/core.git
synced 2026-01-05 00:20:05 +00:00
feat: enabling group macros on sasjs/server
This PR updates ms_getgroups with a user filter, and ms_getusers with a group filter. ms_adduser2group was also created to faciliate the necessary test(s).
This commit is contained in:
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing ms_adduser2group.sas macro
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mf_getuniquename.sas
|
||||
@li mp_assert.sas
|
||||
@li mp_assertscope.sas
|
||||
@li ms_adduser2group.sas
|
||||
@li ms_creategroup.sas
|
||||
|
||||
**/
|
||||
|
||||
/* first, create an empty group */
|
||||
%let group=%substr(%mf_getuniquename(),1,8);
|
||||
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1a)
|
||||
%let groupid=0;
|
||||
data _null_;
|
||||
set work.test1a;
|
||||
call symputx('groupid',groupid);
|
||||
run;
|
||||
%mp_assert(
|
||||
iftrue=(&groupid>0),
|
||||
desc=Checking that group was created with an ID,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
/* now add a user (user 1 always exists) */
|
||||
|
||||
|
||||
%mp_assertscope(SNAPSHOT)
|
||||
%ms_adduser2group(uid=1,gid=&groupid,mdebug=&sasjs_mdebug,outds=test1)
|
||||
%mp_assertscope(COMPARE
|
||||
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||
)
|
||||
|
||||
/* check the user is in the output list */
|
||||
%let checkid=0;
|
||||
data _null_;
|
||||
set work.test1;
|
||||
if id=1 then call symputx('checkid',1);
|
||||
run;
|
||||
%mp_assert(
|
||||
iftrue=(&checkid=1),
|
||||
desc=Checking that user was created in the new group,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
data _null_;
|
||||
set work.test1;
|
||||
call symputx('id',id);
|
||||
putlog (_all_)(=);
|
||||
run;
|
||||
%mp_assert(
|
||||
iftrue=(&id>0),
|
||||
@@ -35,7 +36,8 @@ run;
|
||||
%let checkid=0;
|
||||
data _null_;
|
||||
set work.test2;
|
||||
where username="&user";
|
||||
if _n_<20 then putlog (_all_)(=);
|
||||
if username="&user";
|
||||
call symputx('checkid',id);
|
||||
run;
|
||||
%mp_assert(
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
@brief Testing ms_getusers.sas macro
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li ms_creategroup.sas
|
||||
@li ms_adduser2group.sas
|
||||
@li ms_getusers.sas
|
||||
@li mp_assertdsobs.sas
|
||||
@li mp_assertscope.sas
|
||||
@@ -18,6 +20,39 @@
|
||||
|
||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||
|
||||
/**
|
||||
* test the extraction of group members
|
||||
*/
|
||||
|
||||
/* create a group */
|
||||
%let group=%substr(%mf_getuniquename(),1,8);
|
||||
%ms_creategroup(&group, desc=some desc,mdebug=&sasjs_mdebug,outds=work.group)
|
||||
%let gid=0;
|
||||
data _null_;
|
||||
set work.group;
|
||||
call symputx('gid',groupid);
|
||||
run;
|
||||
|
||||
/* add a member */
|
||||
%ms_adduser2group(uid=1,gid=&gid)
|
||||
|
||||
/* extract the members */
|
||||
%ms_getusers(group=&group,outds=test2)
|
||||
|
||||
/* check the user is in the output list */
|
||||
%let checkid=0;
|
||||
data _null_;
|
||||
set work.test2;
|
||||
if id=1 then call symputx('checkid',1);
|
||||
run;
|
||||
%mp_assert(
|
||||
iftrue=(&checkid=1),
|
||||
desc=Checking that admin user was created in the new group,
|
||||
outds=work.test_results
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ options mprint;
|
||||
)
|
||||
%mp_assertscope(COMPARE)
|
||||
|
||||
libname webeen json (weboot);
|
||||
libname webeen json fileref=weboot;
|
||||
|
||||
data _null_;
|
||||
infile weboot;
|
||||
|
||||
@@ -10,7 +10,12 @@
|
||||
**/
|
||||
|
||||
filename ft15f001 temp;
|
||||
parmcards4;
|
||||
data _null_;
|
||||
file ft15f001;
|
||||
infile cards;
|
||||
input;
|
||||
put _infile_;
|
||||
cards4;
|
||||
%put Initialising sendObj: ;
|
||||
%put _all_;
|
||||
%webout(FETCH)
|
||||
@@ -27,6 +32,7 @@ parmcards4;
|
||||
%mend x; %x()
|
||||
%webout(CLOSE)
|
||||
;;;;
|
||||
run;
|
||||
%put creating web service: &mcTestAppLoc/services;
|
||||
%ms_createwebservice(
|
||||
path=&mcTestAppLoc/services,
|
||||
|
||||
@@ -20,7 +20,7 @@ run;
|
||||
%ms_webout(OBJ,datasets,fref=&fref)
|
||||
%ms_webout(CLOSE,fref=&fref)
|
||||
|
||||
libname test JSON (&fref);
|
||||
libname test JSON fileref=&fref;
|
||||
data root;
|
||||
set test.root;
|
||||
call symputx('checkval',sysvlong);
|
||||
|
||||
Reference in New Issue
Block a user