mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
Merge pull request #29 from yannh/test-without-network
Run some acceptance tests without network
This commit is contained in:
commit
3ce3992c23
5 changed files with 8323 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
FROM bats/bats:v1.2.1
|
||||
RUN apk --no-cache add ca-certificates parallel
|
||||
COPY bin/kubeconform /code/bin/
|
||||
COPY acceptance.bats /code/acceptance.bats
|
||||
COPY acceptance.bats acceptance-nonetwork.bats /code/
|
||||
COPY fixtures /code/fixtures
|
||||
|
|
|
|||
1
Makefile
1
Makefile
|
|
@ -27,6 +27,7 @@ build-bats:
|
|||
|
||||
docker-acceptance: build-bats
|
||||
docker run -t bats -p acceptance.bats
|
||||
docker run --network none -t bats -p acceptance-nonetwork.bats
|
||||
|
||||
release:
|
||||
docker run -e GITHUB_TOKEN -t -v $$PWD:/go/src/github.com/yannh/kubeconform -w /go/src/github.com/yannh/kubeconform goreleaser/goreleaser:v0.138 goreleaser release --rm-dist
|
||||
21
acceptance-nonetwork.bats
Executable file
21
acceptance-nonetwork.bats
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
@test "Fail when parsing a valid Kubernetes config YAML file without network access" {
|
||||
run bin/kubeconform fixtures/valid.yaml
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a valid config YAML file without network access, with cache" {
|
||||
run bin/kubeconform -cache fixtures/cache/ fixtures/valid.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a Custom Resource and using a local schema registry with appropriate CRD" {
|
||||
run bin/kubeconform -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a Custom Resource and specifying several local registries, the last one having the appropriate CRD" {
|
||||
run bin/kubeconform -schema-location 'fixtures/{{ .ResourceKind }}.json' -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
resetCacheFolder() {
|
||||
rm -rf cache
|
||||
mkdir -p cache
|
||||
}
|
||||
|
||||
@test "Pass when parsing a valid Kubernetes config YAML file" {
|
||||
run bin/kubeconform -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
@ -110,16 +115,6 @@
|
|||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a Custom Resource and using a local schema registry with appropriate CRD" {
|
||||
run bin/kubeconform -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a Custom Resource and specifying several local registries, the last one having the appropriate CRD" {
|
||||
run bin/kubeconform -schema-location 'fixtures/{{ .ResourceKind }}.json' -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a config with additional properties" {
|
||||
run bin/kubeconform -summary fixtures/extra_property.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
@ -204,13 +199,21 @@
|
|||
}
|
||||
|
||||
@test "Pass when parsing a valid Kubernetes config YAML file and store cache" {
|
||||
run mkdir cache
|
||||
resetCacheFolder
|
||||
run bin/kubeconform -cache cache -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0" ]
|
||||
[ "`ls cache/ | wc -l`" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "Fail when no schema found, ensure 404 is not cached on disk" {
|
||||
resetCacheFolder
|
||||
run bin/kubeconform -cache cache -schema-location 'https://raw.githubusercontent.com/garethr/openshift-json-schema/master/doesnotexist.json' fixtures/valid.yaml
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" == 'fixtures/valid.yaml - ReplicationController bob failed validation: could not find schema for ReplicationController' ]
|
||||
[ "`ls cache/ | wc -l`" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Fail when cache folder does not exist" {
|
||||
run bin/kubeconform -cache cache_does_not_exist -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 1 ]
|
||||
|
|
|
|||
8286
fixtures/cache/c83be334b785044137611770c677d106
vendored
Normal file
8286
fixtures/cache/c83be334b785044137611770c677d106
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue