Skip to content

Commit

Permalink
ts: test --user/--group on module-forbid
Browse files Browse the repository at this point in the history
  • Loading branch information
xdelaruelle committed Feb 19, 2024
1 parent df31dc8 commit 91b4de7
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
71 changes: 71 additions & 0 deletions testsuite/modulefiles.2/hide1/.modulerc
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,74 @@ if {[info exists env(TESTSUITE_HIDE_USER_GROUP)]} {
}
}
}

# 20/117 --user and --group tests
if {[info exists env(TESTSUITE_FORBID_USER_GROUP)]} {
switch -- $env(TESTSUITE_FORBID_USER_GROUP) {
user2 {
module-forbid --user [list unknown1 [module-info username] unknown2] hide1
}
user3 {
module-forbid --user [list unknown1 unknown2] hide1
}
user_time1 {
set tomorrow [clock format [expr {[clock seconds]+86400}] -format %Y-%m-%d]
module-forbid --user [module-info username] --after $tomorrow hide1
}
user_time2 {
set yesterday [clock format [expr {[clock seconds]-86400}] -format %Y-%m-%d]
module-forbid --user [module-info username] --after $yesterday hide1
}
user_time3 {
set tomorrow [clock format [expr {[clock seconds]+86400}] -format %Y-%m-%d]
module-forbid --user unknown1 --after $tomorrow hide1
}
user_time4 {
set yesterday [clock format [expr {[clock seconds]-86400}] -format %Y-%m-%d]
module-forbid --user unknown1 --after $yesterday hide1
}
user_notgroup3 {
module-forbid --user [module-info username] --not-group [module-info usergroups] hide1
}
user_notgroup4 {
module-forbid --user unknown1 --not-group unknown1 hide1
}
group2 {
module-forbid --group [concat [list unknown1 unknown2] [module-info usergroups]] hide1
}
group3 {
module-forbid --group [list unknown1 unknown2] hide1
}
group_time1 {
set tomorrow [clock format [expr {[clock seconds]+86400}] -format %Y-%m-%d]
module-forbid --group [module-info usergroups] --after $tomorrow hide1
}
group_time2 {
set yesterday [clock format [expr {[clock seconds]-86400}] -format %Y-%m-%d]
module-forbid --group [module-info usergroups] --after $yesterday hide1
}
group_time3 {
set tomorrow [clock format [expr {[clock seconds]+86400}] -format %Y-%m-%d]
module-forbid --group unknown1 --after $tomorrow hide1
}
group_time4 {
set yesterday [clock format [expr {[clock seconds]-86400}] -format %Y-%m-%d]
module-forbid --group unknown1 --after $yesterday hide1
}
group_notuser1 {
module-forbid --group [module-info usergroups] --not-user unknown1 hide1
}
group_notuser2 {
module-forbid --group unknown1 --not-user [module-info username] hide1
}
group_user1 {
module-forbid --group [module-info usergroups] --user unknown1 hide1
}
group_user2 {
module-forbid --group unknown1 --user [module-info username] hide1
}
group_user_notuser_notgroup2 {
module-forbid --group unknown1 --user unknown1 hide1 --not-user unknown1 --not-group unknown1 hide1
}
}
}
68 changes: 68 additions & 0 deletions testsuite/modules.20-locate/117-forbid-user-group.exp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,74 @@ unsetenv_var TESTSUITE_FORBID_ALLOW_USER_GROUP_ERR_SET2
}


#
# --user/--group options test
#

setenv_var MODULES_NEARLY_FORBIDDEN_DAYS 2

set tserr_forbidden "$mp:\nhide1/5.0 <F>"
set tserr_not_forbidden $mp:\nhide1/5.0
set tserr_nearly_forbidden "$mp:\nhide1/5.0 <nF>"

setenv_var TESTSUITE_FORBID_USER_GROUP user2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user3
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_time1
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_nearly_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_time2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_time3
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_time4
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_notgroup3
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP user_notgroup4
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group3
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_time1
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_nearly_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_time2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_time3
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_time4
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_notuser1
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_notuser2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_user1
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_user2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_forbidden

setenv_var TESTSUITE_FORBID_USER_GROUP group_user_notuser_notgroup2
testouterr_cmd sh {avail -t hide1/5.0} OK $tserr_not_forbidden


#
# Cleanup
#
Expand Down

0 comments on commit 91b4de7

Please sign in to comment.