Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
ms_getgroups.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing ms_getgroups.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mf_getuniquename.sas
7 @li ms_adduser2group.sas
8 @li ms_creategroup.sas
9 @li ms_getgroups.sas
10 @li mp_assert.sas
11 @li mp_assertdsobs.sas
12 @li mp_assertscope.sas
13
14**/
15
16/* create a group */
17%let group=%substr(%mf_getuniquename(),1,8);
18%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1)
19
20/* get groups */
21%mp_assertscope(SNAPSHOT)
22%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
23%mp_assertscope(COMPARE
24 ,ignorelist=MCLIB2_JADP1LEN MCLIB2_JADPNUM MCLIB2_JADVLEN MC2_JADP1LEN
25 MC2_JADPNUM MC2_JADVLEN
26)
27
28/* check the group was created */
29%mp_assertdsobs(work.test1,test=ATLEAST 1)
30
31%let test2=0;
32%put &=group;
33data _null_;
34 set work.test1;
35 putlog (_all_)(=);
36 if upcase(name)="%upcase(&group)" then do;
37 putlog "&group found!";
38 call symputx('test2',1);
39 call symputx('gid',groupid); /* used in next test */
40 end;
41run;
42
43%mp_assert(
44 iftrue=("&test2"="1"),
45 desc=Checking group was created,
46 outds=work.test_results
47)
48
49
50/* now check if the filter for the groups for a user works */
51
52/* add a member */
53%ms_adduser2group(uid=1,gid=&gid)
54
55%ms_getgroups(user=secretuser,outds=work.test3)
56
57%let test3=0;
58data _null_;
59 set work.test3;
60 if groupid=&gid then call symputx('test3',1);
61run;
62
63%mp_assert(
64 iftrue=("&test3"="1"),
65 desc=Checking group list was returned for a user,
66 outds=work.test_results
67)