chia7712 commented on code in PR #915:
URL: https://github.com/apache/yunikorn-core/pull/915#discussion_r1675177363


##########
pkg/scheduler/placement/filter_test.go:
##########
@@ -321,12 +321,15 @@ func TestAllowUser(t *testing.T) {
                Groups: nil,
        }
        // test deny user list
+       const (

Review Comment:
   ```go
   // test allowing user access with user list
   func TestAllowUser(t *testing.T) {
        // user object to test with
        user1Obj := security.UserGroup{
                User:   "user1",
                Groups: nil,
        }
        user2Obj := security.UserGroup{
                User:   "user2",
                Groups: nil,
        }
        // test deny user list
        conf := configs.Filter{}
        conf.Type = filterDeny
        conf.Users = []string{user1Obj.User}
        filter := newFilter(conf)
        if filter.allowUser(user1Obj) {
                t.Error("deny filter did not deny user 'user1' while in list")
        }
        if !filter.allowUser(user2Obj) {
                t.Error("deny filter did deny user 'user2' while not in list")
        }
   
        // test allow user list
        conf = configs.Filter{}
        conf.Type = filterAllow
        conf.Users = []string{user1Obj.User}
   
        filter = newFilter(conf)
        if !filter.allowUser(user1Obj) {
                t.Error("allow filter did not allow user 'user1' while in list")
        }
        if filter.allowUser(user2Obj) {
                t.Error("allow filter did allow user 'user2' while not in list")
        }
   
        // test deny user exp
        conf = configs.Filter{}
        conf.Type = filterDeny
        conf.Users = []string{"user[0-1]"}
   
        filter = newFilter(conf)
        if filter.allowUser(user1Obj) {
                t.Error("deny filter did not deny user 'user1' while in 
expression")
        }
        if !filter.allowUser(user2Obj) {
                t.Error("deny filter did deny user 'user2' while not in 
expression")
        }
   
        // test allow user exp
        conf = configs.Filter{}
        conf.Type = filterAllow
        conf.Users = []string{"user[0-1]"}
   
        filter = newFilter(conf)
        if !filter.allowUser(user1Obj) {
                t.Error("allow filter did not allow user 'user1' while in 
expression")
        }
        if filter.allowUser(user2Obj) {
                t.Error("allow filter did allow user 'user2' while not in 
expression")
        }
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to