Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): e2e tests to support http mode
- Loading branch information
1 parent
2e62571
commit a91d2cf
Showing
33 changed files
with
282 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../libs/serviceaccount_utils.bash" | ||
|
||
setup() { | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=http://127.0.0.1:9001 | ||
} | ||
|
||
@test "Checking api-resources" { | ||
echo "Endpoint Checking api-resources $endpoint" >&3 | ||
curl -H "Authorization: Bearer $token" $endpoint/apis >&3 | ||
run sh -c "curl -s -H \"Authorization: Bearer $token\" $endpoint/apis" | ||
echo "output: $output" >&3 | ||
echo "status: $status" >&3 | ||
[ $status -eq 0 ] | ||
} | ||
|
||
@test "Checking version" { | ||
echo "Endpoint Checking version $endpoint" >&3 | ||
curl -H "Authorization: Bearer $token" $endpoint/version >&3 | ||
run sh -c "curl -s -H \"Authorization: Bearer $token\" $endpoint/version" | ||
echo "output: $output" >&3 | ||
echo "status: $status" >&3 | ||
[ $status -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../../libs/namespaces_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/tenants_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/serviceaccount_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/rolebinding_utils.bash" | ||
|
||
setup() { | ||
create_tenant oil alice User | ||
create_namespace alice oil-dev | ||
create_namespace alice oil-staging | ||
create_namespace alice oil-production | ||
kubectl patch tenants.capsule.clastix.io oil --type=json -p '[{"op": "add", "path": "/spec/owners/1", "value": {"kind": "ServiceAccount", "name": "system:serviceaccount:default:sa"}}]' | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=http://127.0.0.1:9001 | ||
} | ||
|
||
teardown() { | ||
delete_tenant oil | ||
} | ||
|
||
@test "List allowed namespace" { | ||
poll_until_equals "SA" "oil-dev" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-dev | jq -r '.metadata.name'" 3 5 | ||
poll_until_equals "SA" "oil-production" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-production | jq -r '.metadata.name'" 3 5 | ||
poll_until_equals "SA" "oil-staging" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-staging | jq -r '.metadata.name'" 3 5 | ||
} | ||
|
||
@test "List non-allowed namespaces" { | ||
poll_until_equals "SA" "Forbidden" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/kube-system | jq -r '.reason'" 3 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../../libs/namespaces_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/tenants_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/serviceaccount_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/rolebinding_utils.bash" | ||
|
||
setup() { | ||
create_tenant oil alice User | ||
create_namespace alice oil-dev | ||
create_namespace alice oil-staging | ||
create_namespace alice oil-production | ||
kubectl patch tenants.capsule.clastix.io oil --type=json -p '[{"op": "add", "path": "/spec/owners/1", "value": {"kind": "ServiceAccount", "name": "system:serviceaccount:default:sa"}}]' | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=http://127.0.0.1:9001 | ||
} | ||
|
||
teardown() { | ||
delete_tenant oil | ||
} | ||
|
||
@test "List allowed namespaces" { | ||
local sa="oil-dev | ||
oil-production | ||
oil-staging" | ||
poll_until_equals "SA" "$sa" "curl -s -H "Authorization: Bearer $token" $endpoint/api/v1/namespaces | jq -r '.items[].metadata.name'" 3 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../libs/serviceaccount_utils.bash" | ||
|
||
setup() { | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.clusters[?(@.name == "kind-capsule")].cluster.server}') | ||
} | ||
@test "Checking api-resources" { | ||
run sh -c "curl -s -H \"Authorization: Bearer $token\" $endpoint/apis" | ||
[ $status -eq 0 ] | ||
} | ||
|
||
@test "Checking version" { | ||
run sh -c "curl -s -H \"Authorization: Bearer $token\" $endpoint/version" | ||
[ $status -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../../libs/namespaces_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/tenants_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/serviceaccount_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/rolebinding_utils.bash" | ||
|
||
setup() { | ||
create_tenant oil alice User | ||
create_namespace alice oil-dev | ||
create_namespace alice oil-staging | ||
create_namespace alice oil-production | ||
kubectl patch tenants.capsule.clastix.io oil --type=json -p '[{"op": "add", "path": "/spec/owners/1", "value": {"kind": "ServiceAccount", "name": "system:serviceaccount:default:sa"}}]' | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.clusters[?(@.name == "kind-capsule")].cluster.server}') | ||
} | ||
|
||
teardown() { | ||
delete_tenant oil | ||
} | ||
|
||
@test "List allowed namespace" { | ||
poll_until_equals "SA" "oil-dev" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-dev | jq -r '.metadata.name'" 3 5 | ||
poll_until_equals "SA" "oil-production" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-production | jq -r '.metadata.name'" 3 5 | ||
poll_until_equals "SA" "oil-staging" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/oil-staging | jq -r '.metadata.name'" 3 5 | ||
} | ||
|
||
@test "List non-allowed namespaces" { | ||
poll_until_equals "SA" "Forbidden" "curl -s -H \"Authorization: Bearer $token\" $endpoint/api/v1/namespaces/kube-system | jq -r '.reason'" 3 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../../libs/namespaces_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/poll.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/tenants_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/serviceaccount_utils.bash" | ||
load "$BATS_TEST_DIRNAME/../../libs/rolebinding_utils.bash" | ||
|
||
setup() { | ||
create_tenant oil alice User | ||
create_namespace alice oil-dev | ||
create_namespace alice oil-staging | ||
create_namespace alice oil-production | ||
kubectl patch tenants.capsule.clastix.io oil --type=json -p '[{"op": "add", "path": "/spec/owners/1", "value": {"kind": "ServiceAccount", "name": "system:serviceaccount:default:sa"}}]' | ||
create_serviceaccount sa default | ||
token=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.users[?(@.name == "sa")].user.token}') | ||
endpoint=$(KUBECONFIG=${HACK_DIR}/sa.kubeconfig kubectl config view -o json --raw -o jsonpath='{.clusters[?(@.name == "kind-capsule")].cluster.server}') | ||
} | ||
|
||
teardown() { | ||
delete_tenant oil | ||
} | ||
|
||
@test "List allowed namespaces" { | ||
local sa="oil-dev | ||
oil-production | ||
oil-staging" | ||
echo "Endpoint List allowed namespaces $endpoint" >&3 | ||
poll_until_equals "SA" "$sa" "curl -s -H "Authorization: Bearer $token" $endpoint/api/v1/namespaces | jq -r '.items[].metadata.name'" 3 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../libs/poll.bash" | ||
|
||
@test "Checking kubectl api-resources" { | ||
run sh -c "KUBECONFIG=${HACK_DIR}/alice.kubeconfig kubectl api-resources" | ||
[ $status -ne 0 ] | ||
} | ||
|
||
@test "Checking kubectl version" { | ||
run sh -c "KUBECONFIG=${HACK_DIR}/alice.kubeconfig kubectl version" | ||
[ $status -ne 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_TEST_DIRNAME/../../libs/poll.bash" | ||
|
||
@test "List namespaces" { | ||
namespaces=$(kubectl get ns -o name) | ||
poll_until_different "User" "$namespaces" "kubectl --kubeconfig=${HACK_DIR}/alice.kubeconfig get namespaces --output=name" 3 5 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.