(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestValidateController(t *testing.T) { |
| 31 | c := conf.Configuration{ |
| 32 | Checks: map[string]conf.Severity{ |
| 33 | "hostIPCSet": conf.SeverityDanger, |
| 34 | "hostPIDSet": conf.SeverityDanger, |
| 35 | }, |
| 36 | } |
| 37 | deployment, err := kube.NewGenericResourceFromPod(test.MockPod(), nil) |
| 38 | assert.NoError(t, err) |
| 39 | deployment.Kind = "Deployment" |
| 40 | expectedSum := CountSummary{ |
| 41 | Successes: uint(2), |
| 42 | Warnings: uint(0), |
| 43 | Dangers: uint(0), |
| 44 | } |
| 45 | |
| 46 | expectedResults := ResultSet{ |
| 47 | "hostIPCSet": {ID: "hostIPCSet", Message: "Host IPC is not configured", Success: true, Severity: "danger", Category: "Security"}, |
| 48 | "hostPIDSet": {ID: "hostPIDSet", Message: "Host PID is not configured", Success: true, Severity: "danger", Category: "Security"}, |
| 49 | } |
| 50 | |
| 51 | var actualResult Result |
| 52 | actualResult, err = applyControllerSchemaChecks(context.Background(), &c, nil, deployment) |
| 53 | if err != nil { |
| 54 | panic(err) |
| 55 | } |
| 56 | |
| 57 | assert.Equal(t, "Deployment", actualResult.Kind) |
| 58 | assert.Equal(t, 1, len(actualResult.PodResult.ContainerResults), "should be equal") |
| 59 | assert.EqualValues(t, expectedSum, actualResult.GetSummary()) |
| 60 | assert.EqualValues(t, expectedResults, actualResult.PodResult.Results) |
| 61 | } |
| 62 | |
| 63 | func TestControllerLevelChecks(t *testing.T) { |
| 64 | testResources := func(res *kube.ResourceProvider) { |
nothing calls this directly
no test coverage detected