@@ -248,7 +248,6 @@ func TestContainerCapabilities(t *testing.T) {
248248 spec , err := c .generateContainerSpec (testID , testSandboxID , testPid , config , sandboxConfig , imageConfig , nil )
249249 require .NoError (t , err )
250250 specCheck (t , testID , testSandboxID , testPid , spec )
251- t .Log (spec .Process .Capabilities .Bounding )
252251 for _ , include := range test .includes {
253252 assert .Contains (t , spec .Process .Capabilities .Bounding , include )
254253 assert .Contains (t , spec .Process .Capabilities .Effective , include )
@@ -913,3 +912,45 @@ func TestGenerateApparmorSpecOpts(t *testing.T) {
913912 }
914913 }
915914}
915+
916+ func TestMaskedAndReadonlyPaths (t * testing.T ) {
917+ testID := "test-id"
918+ testSandboxID := "sandbox-id"
919+ testPid := uint32 (1234 )
920+ config , sandboxConfig , imageConfig , specCheck := getCreateContainerTestData ()
921+ c := newTestCRIService ()
922+ defaultSpec , err := defaultRuntimeSpec (testID )
923+ require .NoError (t , err )
924+ for desc , test := range map [string ]struct {
925+ masked []string
926+ readonly []string
927+ expectedMasked []string
928+ expectedReadonly []string
929+ }{
930+ "should apply default if not specified" : {
931+ expectedMasked : defaultSpec .Linux .MaskedPaths ,
932+ expectedReadonly : defaultSpec .Linux .ReadonlyPaths ,
933+ },
934+ "should be able to specify empty paths" : {
935+ masked : []string {},
936+ readonly : []string {},
937+ expectedMasked : nil ,
938+ expectedReadonly : nil ,
939+ },
940+ "should apply CRI specified paths" : {
941+ masked : []string {"/proc" },
942+ readonly : []string {"/sys" },
943+ expectedMasked : []string {"/proc" },
944+ expectedReadonly : []string {"/sys" },
945+ },
946+ } {
947+ t .Logf ("TestCase %q" , desc )
948+ config .Linux .SecurityContext .MaskedPaths = test .masked
949+ config .Linux .SecurityContext .ReadonlyPaths = test .readonly
950+ spec , err := c .generateContainerSpec (testID , testSandboxID , testPid , config , sandboxConfig , imageConfig , nil )
951+ require .NoError (t , err )
952+ specCheck (t , testID , testSandboxID , testPid , spec )
953+ assert .Equal (t , test .expectedMasked , spec .Linux .MaskedPaths )
954+ assert .Equal (t , test .expectedReadonly , spec .Linux .ReadonlyPaths )
955+ }
956+ }
0 commit comments