selinux/mustrunas_test.go(TestMustRunAsValidate): add more test cases to improve code coverage.
This commit is contained in:
		@@ -93,9 +93,6 @@ func TestMustRunAsValidate(t *testing.T) {
 | 
				
			|||||||
	user := newValidOpts()
 | 
						user := newValidOpts()
 | 
				
			||||||
	user.User = "invalid"
 | 
						user.User = "invalid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	level := newValidOpts()
 | 
					 | 
				
			||||||
	level.Level = "invalid"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	seType := newValidOpts()
 | 
						seType := newValidOpts()
 | 
				
			||||||
	seType.Type = "invalid"
 | 
						seType.Type = "invalid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -116,15 +113,20 @@ func TestMustRunAsValidate(t *testing.T) {
 | 
				
			|||||||
			pspSeLinux:  validOpts,
 | 
								pspSeLinux:  validOpts,
 | 
				
			||||||
			expectedMsg: "user: Invalid value",
 | 
								expectedMsg: "user: Invalid value",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"invalid level": {
 | 
							"levels are not equal": {
 | 
				
			||||||
			podSeLinux:  level,
 | 
								podSeLinux:  newValidOptsWithLevel("s0"),
 | 
				
			||||||
			pspSeLinux:  validOpts,
 | 
								pspSeLinux:  newValidOptsWithLevel("s0:c1,c2"),
 | 
				
			||||||
			expectedMsg: "level: Invalid value",
 | 
								expectedMsg: "level: Invalid value",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"invalid type": {
 | 
							"levels differ by sensitivity": {
 | 
				
			||||||
			podSeLinux:  seType,
 | 
								podSeLinux:  newValidOptsWithLevel("s0:c6"),
 | 
				
			||||||
			pspSeLinux:  validOpts,
 | 
								pspSeLinux:  newValidOptsWithLevel("s1:c6"),
 | 
				
			||||||
			expectedMsg: "type: Invalid value",
 | 
								expectedMsg: "level: Invalid value",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"levels differ by categories": {
 | 
				
			||||||
 | 
								podSeLinux:  newValidOptsWithLevel("s0:c0,c8"),
 | 
				
			||||||
 | 
								pspSeLinux:  newValidOptsWithLevel("s0:c1,c7"),
 | 
				
			||||||
 | 
								expectedMsg: "level: Invalid value",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"valid": {
 | 
							"valid": {
 | 
				
			||||||
			podSeLinux:  validOpts,
 | 
								podSeLinux:  validOpts,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user