mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ae2981f1 | ||
|
|
a3043ac685 | ||
|
|
2bdb90b0be | ||
|
|
2cd846d504 | ||
|
|
f593c7bec9 | ||
|
|
c8805db0b5 | ||
|
|
1eb6d8cec9 | ||
|
|
ed19ee03af | ||
|
|
a1c931b5e6 | ||
|
|
cb553a31ab | ||
|
|
557df272ff | ||
|
|
0cb3c96c15 |
267
all.sas
267
all.sas
@@ -2256,7 +2256,7 @@ Usage:
|
|||||||
|
|
||||||
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
||||||
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
||||||
and "&SYSPROCESSNAME " ne "Compute Server "
|
and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
||||||
%then %do;
|
%then %do;
|
||||||
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
||||||
data &errds;
|
data &errds;
|
||||||
@@ -2274,7 +2274,7 @@ Usage:
|
|||||||
|
|
||||||
/* Web App Context */
|
/* Web App Context */
|
||||||
%if %symexist(_PROGRAM)
|
%if %symexist(_PROGRAM)
|
||||||
or "&SYSPROCESSNAME "="Compute Server "
|
or %superq(SYSPROCESSNAME) = %str(Compute Server)
|
||||||
or &mode=INCLUDE
|
or &mode=INCLUDE
|
||||||
%then %do;
|
%then %do;
|
||||||
options obs=max replace mprint;
|
options obs=max replace mprint;
|
||||||
@@ -13015,7 +13015,10 @@ create table &libds(
|
|||||||
@file mm_adduser2group.sas
|
@file mm_adduser2group.sas
|
||||||
@brief Adds a user to a group
|
@brief Adds a user to a group
|
||||||
@details Adds a user to a metadata group. The macro first checks whether the
|
@details Adds a user to a metadata group. The macro first checks whether the
|
||||||
user is in that group, and if not, the user is added.
|
user is in that group, and if not, the user is added.
|
||||||
|
|
||||||
|
Note that the macro does not check inherited group memberships - it looks at
|
||||||
|
direct members only.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -13025,10 +13028,10 @@ create table &libds(
|
|||||||
|
|
||||||
@param user= the user name (not displayname)
|
@param user= the user name (not displayname)
|
||||||
@param group= the group to which to add the user
|
@param group= the group to which to add the user
|
||||||
@param mdebug= set to 1 to show debug info in log
|
@param mdebug= (0) set to 1 to show debug info in log
|
||||||
|
|
||||||
@warning the macro does not check inherited group memberships - it looks at
|
<h4> Related Files </h4>
|
||||||
direct members only
|
@li ms_adduser2group.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -19101,6 +19104,128 @@ run;
|
|||||||
%let rc=%sysfunc(filename(&fref));
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
|
||||||
%mend mfs_httpheader;
|
%mend mfs_httpheader;
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Adds a user to a group on SASjs Server
|
||||||
|
@details Adds a user to a group based on userid and groupid. Both user and
|
||||||
|
group must already exist.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
%ms_adduser2group(uid=1,gid=1)
|
||||||
|
|
||||||
|
|
||||||
|
@param [in] uid= (0) The User ID to be added
|
||||||
|
@param [in] gid= (0) The Group ID to contain the new user
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outds= (work.ms_adduser2group) This output dataset will contain
|
||||||
|
the new list of group members, eg:
|
||||||
|
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
||||||
|
|---|---|---|
|
||||||
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
|
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
||||||
|
|`Ivor Townsend `|`ivor `|`4`|
|
||||||
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_createuser.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_adduser2group(uid=0
|
||||||
|
,gid=0
|
||||||
|
,outds=work.ms_adduser2group
|
||||||
|
,mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 fref2 libref optval rc msg;
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then put "accept: application/json";
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
%put _local_;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
proc http method='POST' headerin=&fref0 out=&fref1
|
||||||
|
url="&_sasjs_apiserverurl/SASjsApi/group/&gid/&uid";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(Issue submitting query to SASjsApi/group)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=0 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref1;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_adduser2group;
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Creates a file on SASjs Drive
|
@brief Creates a file on SASjs Drive
|
||||||
@@ -20146,13 +20271,24 @@ filename &headref clear;
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of groups from SASjs Server
|
@brief Fetches the list of groups from SASjs Server
|
||||||
@details Fetches the list of groups from SASjs Server and writes them to an
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getgroups(outds=userlist)
|
%ms_getgroups(outds=userlist)
|
||||||
|
|
||||||
|
With filter on username:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, user=James)
|
||||||
|
|
||||||
|
With filter on userid:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, uid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] user= (0) Provide the username on which to filter
|
||||||
|
@param [in] uid= (0) Provide the userid on which to filter
|
||||||
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
@@ -20169,28 +20305,33 @@ filename &headref clear;
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_creategroup.sas
|
@li ms_creategroup.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getgroups(
|
%macro ms_getgroups(
|
||||||
outds=work.ms_getgroups
|
user=0,
|
||||||
,mdebug=0
|
uid=0,
|
||||||
);
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
|
|
||||||
%if %sysget(MODE)=desktop %then %do;
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
/* groups api does not exist in desktop mode */
|
/* groups api does not exist in desktop mode */
|
||||||
data &outds;
|
data &outds;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
call missing (of _all_);
|
name="&sysuserid";
|
||||||
|
description="&sysuserid (group - desktop mode)";
|
||||||
|
groupid=1;
|
||||||
|
output;
|
||||||
stop;
|
stop;
|
||||||
run;
|
run;
|
||||||
%return;
|
%return;
|
||||||
@@ -20220,8 +20361,13 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
|
||||||
|
%else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
|
||||||
|
%else %let url=/SASjsApi/group;
|
||||||
|
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/group";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
@@ -20230,17 +20376,27 @@ run;
|
|||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getgroups.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/group)
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
data &outds;
|
||||||
if _n_=1 then call missing(of _all_);
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
set &libref..root;
|
if _n_=1 then call missing(of _all_);
|
||||||
drop ordinal_root;
|
set &libref..root;
|
||||||
run;
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
if _n_=1 then call missing(of _all_);
|
||||||
|
set &libref..groups;
|
||||||
|
drop ordinal_:;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -20262,16 +20418,26 @@ options &optval;
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of users from SASjs Server
|
@brief Fetches the list of users from SASjs Server
|
||||||
@details Fetches the list of users from SASjs Server and writes them to an
|
@details Fetches the list of users from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Can also be filtered, for a particular group.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getusers(outds=userlist)
|
%ms_getusers(outds=userlist)
|
||||||
|
|
||||||
|
Filtering for a group by group name:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, group=GROUPNAME)
|
||||||
|
|
||||||
|
Filtering for a group by group id:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, gid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] group= (0) Set to a group name to filter members for that group
|
||||||
|
@param [in] gid= (0) Set to a group id to filter members for that group
|
||||||
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
||||||
list of user accounts. Format:
|
list of user accounts. Format:
|
||||||
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|DISPLAYNAME:$60.|USERNAME:$30.|ID:best.|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|`Super Admin `|`secretuser `|`1`|
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|`Sabir Hassan`|`sabir`|`2`|
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
@@ -20280,7 +20446,6 @@ options &optval;
|
|||||||
|`New User `|`newuser `|`5`|
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquelibref.sas
|
||||||
@@ -20288,14 +20453,17 @@ options &optval;
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_createuser.sas
|
@li ms_createuser.sas
|
||||||
|
@li ms_getgroups.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getusers.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getusers(
|
%macro ms_getusers(
|
||||||
outds=work.ms_getusers
|
outds=work.ms_getusers,
|
||||||
,mdebug=0
|
group=0,
|
||||||
);
|
gid=0,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -20303,11 +20471,24 @@ options &optval;
|
|||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
%let fref0=%mf_getuniquefileref();
|
%let fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* users api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
USERNAME="&sysuserid";
|
||||||
|
DISPLAYNAME="&sysuserid (desktop mode)";
|
||||||
|
ID=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* avoid sending bom marker to API */
|
/* avoid sending bom marker to API */
|
||||||
%let optval=%sysfunc(getoption(bomfile));
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
options nobomfile;
|
options nobomfile;
|
||||||
@@ -20328,26 +20509,40 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&group" ne "0" %then %let url=/SASjsApi/group/by/groupname/&group;
|
||||||
|
%else %if "&gid" ne "0" %then %let url=/SASjsApi/group/&gid;
|
||||||
|
%else %let url=/SASjsApi/user;
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/user";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getusers.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
,msg=%str(Issue submitting API query)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&group"="0" and "&gid"="0" %then %do;
|
||||||
set &libref..root;
|
data &outds;
|
||||||
drop ordinal_root;
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
run;
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
||||||
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
||||||
and "&SYSPROCESSNAME " ne "Compute Server "
|
and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
||||||
%then %do;
|
%then %do;
|
||||||
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
||||||
data &errds;
|
data &errds;
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
|
|
||||||
/* Web App Context */
|
/* Web App Context */
|
||||||
%if %symexist(_PROGRAM)
|
%if %symexist(_PROGRAM)
|
||||||
or "&SYSPROCESSNAME "="Compute Server "
|
or %superq(SYSPROCESSNAME) = %str(Compute Server)
|
||||||
or &mode=INCLUDE
|
or &mode=INCLUDE
|
||||||
%then %do;
|
%then %do;
|
||||||
options obs=max replace mprint;
|
options obs=max replace mprint;
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
@file mm_adduser2group.sas
|
@file mm_adduser2group.sas
|
||||||
@brief Adds a user to a group
|
@brief Adds a user to a group
|
||||||
@details Adds a user to a metadata group. The macro first checks whether the
|
@details Adds a user to a metadata group. The macro first checks whether the
|
||||||
user is in that group, and if not, the user is added.
|
user is in that group, and if not, the user is added.
|
||||||
|
|
||||||
|
Note that the macro does not check inherited group memberships - it looks at
|
||||||
|
direct members only.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -12,10 +15,10 @@
|
|||||||
|
|
||||||
@param user= the user name (not displayname)
|
@param user= the user name (not displayname)
|
||||||
@param group= the group to which to add the user
|
@param group= the group to which to add the user
|
||||||
@param mdebug= set to 1 to show debug info in log
|
@param mdebug= (0) set to 1 to show debug info in log
|
||||||
|
|
||||||
@warning the macro does not check inherited group memberships - it looks at
|
<h4> Related Files </h4>
|
||||||
direct members only
|
@li ms_adduser2group.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"serverUrl": "https://sas.analytium.co.uk:5007",
|
"serverUrl": "https://sas.4gl.io",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"httpsAgentOptions": {
|
"httpsAgentOptions": {
|
||||||
"allowInsecureRequests": false
|
"allowInsecureRequests": false
|
||||||
@@ -107,4 +107,4 @@
|
|||||||
"contextName": "SAS Job Execution compute context"
|
"contextName": "SAS Job Execution compute context"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
122
server/ms_adduser2group.sas
Normal file
122
server/ms_adduser2group.sas
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Adds a user to a group on SASjs Server
|
||||||
|
@details Adds a user to a group based on userid and groupid. Both user and
|
||||||
|
group must already exist.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
%ms_adduser2group(uid=1,gid=1)
|
||||||
|
|
||||||
|
|
||||||
|
@param [in] uid= (0) The User ID to be added
|
||||||
|
@param [in] gid= (0) The Group ID to contain the new user
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outds= (work.ms_adduser2group) This output dataset will contain
|
||||||
|
the new list of group members, eg:
|
||||||
|
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
||||||
|
|---|---|---|
|
||||||
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
|
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
||||||
|
|`Ivor Townsend `|`ivor `|`4`|
|
||||||
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_createuser.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_adduser2group(uid=0
|
||||||
|
,gid=0
|
||||||
|
,outds=work.ms_adduser2group
|
||||||
|
,mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 fref2 libref optval rc msg;
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then put "accept: application/json";
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
%put _local_;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
proc http method='POST' headerin=&fref0 out=&fref1
|
||||||
|
url="&_sasjs_apiserverurl/SASjsApi/group/&gid/&uid";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(Issue submitting query to SASjsApi/group)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=0 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref1;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_adduser2group;
|
||||||
@@ -2,13 +2,24 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of groups from SASjs Server
|
@brief Fetches the list of groups from SASjs Server
|
||||||
@details Fetches the list of groups from SASjs Server and writes them to an
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getgroups(outds=userlist)
|
%ms_getgroups(outds=userlist)
|
||||||
|
|
||||||
|
With filter on username:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, user=James)
|
||||||
|
|
||||||
|
With filter on userid:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, uid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] user= (0) Provide the username on which to filter
|
||||||
|
@param [in] uid= (0) Provide the userid on which to filter
|
||||||
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
@@ -25,28 +36,33 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_creategroup.sas
|
@li ms_creategroup.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getgroups(
|
%macro ms_getgroups(
|
||||||
outds=work.ms_getgroups
|
user=0,
|
||||||
,mdebug=0
|
uid=0,
|
||||||
);
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
|
|
||||||
%if %sysget(MODE)=desktop %then %do;
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
/* groups api does not exist in desktop mode */
|
/* groups api does not exist in desktop mode */
|
||||||
data &outds;
|
data &outds;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
call missing (of _all_);
|
name="&sysuserid";
|
||||||
|
description="&sysuserid (group - desktop mode)";
|
||||||
|
groupid=1;
|
||||||
|
output;
|
||||||
stop;
|
stop;
|
||||||
run;
|
run;
|
||||||
%return;
|
%return;
|
||||||
@@ -76,8 +92,13 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
|
||||||
|
%else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
|
||||||
|
%else %let url=/SASjsApi/group;
|
||||||
|
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/group";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
@@ -86,17 +107,27 @@ run;
|
|||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getgroups.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/group)
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
data &outds;
|
||||||
if _n_=1 then call missing(of _all_);
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
set &libref..root;
|
if _n_=1 then call missing(of _all_);
|
||||||
drop ordinal_root;
|
set &libref..root;
|
||||||
run;
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
if _n_=1 then call missing(of _all_);
|
||||||
|
set &libref..groups;
|
||||||
|
drop ordinal_:;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
|
|||||||
@@ -2,16 +2,26 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of users from SASjs Server
|
@brief Fetches the list of users from SASjs Server
|
||||||
@details Fetches the list of users from SASjs Server and writes them to an
|
@details Fetches the list of users from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Can also be filtered, for a particular group.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getusers(outds=userlist)
|
%ms_getusers(outds=userlist)
|
||||||
|
|
||||||
|
Filtering for a group by group name:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, group=GROUPNAME)
|
||||||
|
|
||||||
|
Filtering for a group by group id:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, gid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] group= (0) Set to a group name to filter members for that group
|
||||||
|
@param [in] gid= (0) Set to a group id to filter members for that group
|
||||||
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
||||||
list of user accounts. Format:
|
list of user accounts. Format:
|
||||||
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|DISPLAYNAME:$60.|USERNAME:$30.|ID:best.|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|`Super Admin `|`secretuser `|`1`|
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|`Sabir Hassan`|`sabir`|`2`|
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
@@ -20,7 +30,6 @@
|
|||||||
|`New User `|`newuser `|`5`|
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquelibref.sas
|
||||||
@@ -28,14 +37,17 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_createuser.sas
|
@li ms_createuser.sas
|
||||||
|
@li ms_getgroups.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getusers.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getusers(
|
%macro ms_getusers(
|
||||||
outds=work.ms_getusers
|
outds=work.ms_getusers,
|
||||||
,mdebug=0
|
group=0,
|
||||||
);
|
gid=0,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -43,11 +55,24 @@
|
|||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
%let fref0=%mf_getuniquefileref();
|
%let fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* users api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
USERNAME="&sysuserid";
|
||||||
|
DISPLAYNAME="&sysuserid (desktop mode)";
|
||||||
|
ID=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* avoid sending bom marker to API */
|
/* avoid sending bom marker to API */
|
||||||
%let optval=%sysfunc(getoption(bomfile));
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
options nobomfile;
|
options nobomfile;
|
||||||
@@ -68,26 +93,40 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&group" ne "0" %then %let url=/SASjsApi/group/by/groupname/&group;
|
||||||
|
%else %if "&gid" ne "0" %then %let url=/SASjsApi/group/&gid;
|
||||||
|
%else %let url=/SASjsApi/user;
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/user";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getusers.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
,msg=%str(Issue submitting API query)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&group"="0" and "&gid"="0" %then %do;
|
||||||
set &libref..root;
|
data &outds;
|
||||||
drop ordinal_root;
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
run;
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
|
|||||||
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
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where name="&group";
|
where upcase(name)="%upcase(&group)";
|
||||||
call symputx('checkid',groupid);
|
call symputx('checkid',groupid);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
data _null_;
|
data _null_;
|
||||||
set work.test1;
|
set work.test1;
|
||||||
call symputx('id',id);
|
call symputx('id',id);
|
||||||
|
putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(&id>0),
|
iftrue=(&id>0),
|
||||||
@@ -35,7 +36,8 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where username="&user";
|
if _n_<20 then putlog (_all_)(=);
|
||||||
|
if upcase(username)="%upcase(&user)";
|
||||||
call symputx('checkid',id);
|
call symputx('checkid',id);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -3,21 +3,64 @@
|
|||||||
@brief Testing ms_getgroups.sas macro
|
@brief Testing ms_getgroups.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
|
@li ms_creategroup.sas
|
||||||
@li ms_getgroups.sas
|
@li ms_getgroups.sas
|
||||||
|
@li mp_assert.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/* create a group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1)
|
||||||
|
|
||||||
|
/* get groups */
|
||||||
%mp_assertscope(SNAPSHOT)
|
%mp_assertscope(SNAPSHOT)
|
||||||
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
||||||
%mp_assertscope(COMPARE
|
%mp_assertscope(COMPARE
|
||||||
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* check the group was created */
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||||
|
|
||||||
|
%let test2=0;
|
||||||
|
%put &=group;
|
||||||
|
data _null_;
|
||||||
|
set work.test1;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
if upcase(name)="%upcase(&group)" then do;
|
||||||
|
putlog "&group found!";
|
||||||
|
call symputx('test2',1);
|
||||||
|
call symputx('gid',groupid); /* used in next test */
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test2"="1"),
|
||||||
|
desc=Checking group was created,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/* now check if the filter for the groups for a user works */
|
||||||
|
|
||||||
|
/* add a member */
|
||||||
|
%ms_adduser2group(uid=1,gid=&gid)
|
||||||
|
|
||||||
|
%ms_getgroups(user=secretuser,outds=work.test3)
|
||||||
|
|
||||||
|
%let test3=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test3;
|
||||||
|
if groupid=&gid then call symputx('test3',1);
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test3"="1"),
|
||||||
|
desc=Checking group list was returned for a user,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
@brief Testing ms_getusers.sas macro
|
@brief Testing ms_getusers.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
@li ms_getusers.sas
|
@li ms_getusers.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
@@ -18,6 +20,39 @@
|
|||||||
|
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%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)
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
libname webeen json (weboot);
|
libname webeen json fileref=weboot;
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile weboot;
|
infile weboot;
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
filename ft15f001 temp;
|
filename ft15f001 temp;
|
||||||
parmcards4;
|
data _null_;
|
||||||
|
file ft15f001;
|
||||||
|
infile cards;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
cards4;
|
||||||
%put Initialising sendObj: ;
|
%put Initialising sendObj: ;
|
||||||
%put _all_;
|
%put _all_;
|
||||||
%webout(FETCH)
|
%webout(FETCH)
|
||||||
@@ -27,6 +32,7 @@ parmcards4;
|
|||||||
%mend x; %x()
|
%mend x; %x()
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
;;;;
|
;;;;
|
||||||
|
run;
|
||||||
%put creating web service: &mcTestAppLoc/services;
|
%put creating web service: &mcTestAppLoc/services;
|
||||||
%ms_createwebservice(
|
%ms_createwebservice(
|
||||||
path=&mcTestAppLoc/services,
|
path=&mcTestAppLoc/services,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ run;
|
|||||||
%ms_webout(OBJ,datasets,fref=&fref)
|
%ms_webout(OBJ,datasets,fref=&fref)
|
||||||
%ms_webout(CLOSE,fref=&fref)
|
%ms_webout(CLOSE,fref=&fref)
|
||||||
|
|
||||||
libname test JSON (&fref);
|
libname test JSON fileref=&fref;
|
||||||
data root;
|
data root;
|
||||||
set test.root;
|
set test.root;
|
||||||
call symputx('checkval',sysvlong);
|
call symputx('checkval',sysvlong);
|
||||||
|
|||||||
Reference in New Issue
Block a user