You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by ma...@apache.org on 2024/06/24 07:05:49 UTC

(yunikorn-core) branch master updated: [YUNIKORN-2686] Validate user and group specified in filter config (#898)

This is an automated email from the ASF dual-hosted git repository.

mani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 97c38a97 [YUNIKORN-2686] Validate user and group specified in filter config (#898)
97c38a97 is described below

commit 97c38a97a55ee9b457c366c11a4ae32348093e2c
Author: Manikandan R <ma...@gmail.com>
AuthorDate: Mon Jun 24 12:35:32 2024 +0530

    [YUNIKORN-2686] Validate user and group specified in filter config (#898)
    
    Closes: #898
    
    Signed-off-by: Manikandan R <ma...@gmail.com>
---
 pkg/scheduler/placement/filter_test.go | 41 ++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/pkg/scheduler/placement/filter_test.go b/pkg/scheduler/placement/filter_test.go
index 0e5d77f4..ddda0452 100644
--- a/pkg/scheduler/placement/filter_test.go
+++ b/pkg/scheduler/placement/filter_test.go
@@ -88,8 +88,8 @@ func TestNewFilterLists(t *testing.T) {
 	// test simple single user or group
 	conf = configs.Filter{}
 	conf.Type = ""
-	conf.Users = []string{"user1"}
-	conf.Groups = []string{"group1"}
+	conf.Users = []string{"user1_a_#_b_c-d-/-e:f_@_gmail.com"}
+	conf.Groups = []string{"group1_a_b_c-d-e:f_gmail.com"}
 
 	filter = newFilter(conf)
 	if !filter.allow {
@@ -192,6 +192,43 @@ func TestNewFilterExceptions(t *testing.T) {
 	if filter.groupExp != nil || len(filter.groupList) != 1 {
 		t.Error("filter create did not set group filter correctly regexp not in first entry")
 	}
+
+	// test single invalid user or group
+	conf = configs.Filter{}
+	conf.Type = ""
+	conf.Users = []string{"user!1"}
+	conf.Groups = []string{"grou#p1"}
+
+	filter = newFilter(conf)
+	if !filter.allow {
+		t.Error("filter create did not set allow flag correctly from empty string")
+	}
+	if filter.userExp != nil || len(filter.userList) != 0 {
+		t.Error("filter create cannot set user filter correctly single invalid entry not regexp")
+	}
+	if filter.groupExp != nil || len(filter.groupList) != 0 {
+		t.Error("filter create cannot not set group filter correctly single invalid entry not regexp")
+	}
+	if filter.empty {
+		t.Error("filter create did not set empty flag correctly")
+	}
+
+	// test multiple invalid user or group
+	conf = configs.Filter{}
+	conf.Type = ""
+	conf.Users = []string{"use!r1", "user2"}
+	conf.Groups = []string{"gro!up1", "gro#up2"}
+
+	filter = newFilter(conf)
+	if !filter.allow {
+		t.Error("filter create did not set allow flag correctly from empty string")
+	}
+	if filter.userExp != nil || len(filter.userList) != 1 {
+		t.Error("filter create cannot set user filter correctly invalid multiple entry not regexp")
+	}
+	if filter.groupExp != nil || len(filter.groupList) != 0 {
+		t.Error("filter create cannot set group filter correctly invalid multiple entry not regexp")
+	}
 }
 
 // Test user matching


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org