mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-11 11:47:12 +00:00
* Start working on updating dependencies: * Fix webhook * Rollback jsonschema update * Checkin new config * Fix run as root * Update versions of kind * Fix typo in kind URL * Fix kind config * Add csr permissions * Fix weird image thing * Fixed certificates * Add to logging * Approve cert manually * Fix approval * Add cert script * Fix deployment * Add requests/limits * Wait if certificate doesn't exist yet * Add check for file size * Add variable * Try a different imagE * Fix command * Update certificate logic * Add healthz * Don't check cert size * Remove stat * Fix vet * Put in change that makes no sense * Fix cert names * Roll back * Try changing config * Add logging for each request * Cleanup code some * Remove bad deployments * Fix client injection * Update timeout * Add logging * Fixed e2e webhook tests * Add permissions for approval * Fix permissions for CSR * Remove logging code * Remove refresh certs file * Fix merge issues * Update deployments * Try beta of admission controller config * Target 1.15 for testing * Add beta versions of resourceS * Lower webhook timeout * Refactor out a method * Fix up PR issues * Fix more tabs * Remove unnecessary messageS * Fix go.sum * Fix go.sum
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package validator
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
conf "github.com/fairwindsops/polaris/pkg/config"
|
|
"github.com/fairwindsops/polaris/pkg/kube"
|
|
"github.com/fairwindsops/polaris/test"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetTemplateData(t *testing.T) {
|
|
k8s, dynamicClient := test.SetupTestAPI()
|
|
k8s = test.SetupAddControllers(context.Background(), k8s, "test")
|
|
k8s = test.SetupAddExtraControllerVersions(context.Background(), k8s, "test-extra")
|
|
// TODO figure out how to mock out dynamic client.
|
|
// and add in pods for all controllers to fill out tests.
|
|
resources, err := kube.CreateResourceProviderFromAPI(context.Background(), k8s, "test", &dynamicClient)
|
|
assert.Equal(t, err, nil, "error should be nil")
|
|
|
|
c := conf.Configuration{
|
|
Checks: map[string]conf.Severity{
|
|
"readinessProbeMissing": conf.SeverityDanger,
|
|
"livenessProbeMissing": conf.SeverityWarning,
|
|
},
|
|
}
|
|
|
|
sum := CountSummary{
|
|
Successes: uint(0),
|
|
Warnings: uint(1),
|
|
Dangers: uint(1),
|
|
}
|
|
|
|
actualAudit, err := RunAudit(context.Background(), c, resources)
|
|
|
|
assert.Equal(t, err, nil, "error should be nil")
|
|
|
|
assert.EqualValues(t, sum, actualAudit.GetSummary())
|
|
assert.Equal(t, actualAudit.SourceType, "Cluster", "should be from a cluster")
|
|
assert.Equal(t, actualAudit.SourceName, "test", "should be from a cluster")
|
|
|
|
expected := []struct {
|
|
kind string
|
|
results int
|
|
}{
|
|
{kind: "Pod", results: 2},
|
|
}
|
|
|
|
assert.Equal(t, len(expected), len(actualAudit.Results))
|
|
for idx, result := range actualAudit.Results {
|
|
assert.Equal(t, expected[idx].kind, result.Kind)
|
|
assert.Equal(t, 1, len(result.PodResult.ContainerResults))
|
|
assert.Equal(t, expected[idx].results, len(result.PodResult.ContainerResults[0].Results))
|
|
}
|
|
}
|