Skip to content

Commit

Permalink
put scripts inside workflows
Browse files Browse the repository at this point in the history
Signed-off-by: PrimalPimmy <[email protected]>

put scripts inside workflows-2

Signed-off-by: PrimalPimmy <[email protected]>

testing with kind cluster

Signed-off-by: PrimalPimmy <[email protected]>

Updated tmp path

Signed-off-by: PrimalPimmy <[email protected]>

setup-go to v4

Signed-off-by: PrimalPimmy <[email protected]>

fixed tmp paths

Signed-off-by: PrimalPimmy <[email protected]>

test improvements

Signed-off-by: PrimalPimmy <[email protected]>

checking CI

Signed-off-by: PrimalPimmy <[email protected]>

checking CI-2

Signed-off-by: PrimalPimmy <[email protected]>

checking CI-3

Signed-off-by: PrimalPimmy <[email protected]>

checking if /tmp can be read

Signed-off-by: PrimalPimmy <[email protected]>

test

Signed-off-by: PrimalPimmy <[email protected]>

test

Signed-off-by: PrimalPimmy <[email protected]>

test-3

Signed-off-by: PrimalPimmy <[email protected]>

Possible success

Signed-off-by: PrimalPimmy <[email protected]>

Possible success-2

Signed-off-by: PrimalPimmy <[email protected]>

Possible success-2

Signed-off-by: PrimalPimmy <[email protected]>

checking docker

Signed-off-by: PrimalPimmy <[email protected]>

checking docker

Signed-off-by: PrimalPimmy <[email protected]>

Kind cluster stuff

Signed-off-by: PrimalPimmy <[email protected]>

Kind cluster stuff

Signed-off-by: PrimalPimmy <[email protected]>

test

Signed-off-by: PrimalPimmy <[email protected]>

back to k3s

Signed-off-by: PrimalPimmy <[email protected]>

back to k3s

Signed-off-by: PrimalPimmy <[email protected]>

back to k3s-3

Signed-off-by: PrimalPimmy <[email protected]>

runtime containerd

Signed-off-by: PrimalPimmy <[email protected]>
  • Loading branch information
PrimalPimmy committed Aug 16, 2023
1 parent d763739 commit f92c422
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/ci-test-ginkgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,47 @@ jobs:
build:
name: Auto-testing Framework
runs-on: ubuntu-latest


env:
RUNTIME: containerd
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: "v1.20"

- name: Setup a Kubernetes environment
run: ./.github/workflows/script/install_k3s.sh
- name: Create k3s cluster
run: ./.github/workflows/scripts/install_k3s.sh

- name: Test connectivity
run: kubectl get pods -A

- name: Deploy wordpress-mysql
run: kubectl apply -f ./tests/res/wordpress-mysql-dep.yaml

- name: Building k8tls
run: make build

- name: Prepare to Deploy k8tls
- name: check for docker
run: docker images

- name: Deploy k8tls
run: |
mkdir /tmp/k8tls
docker save kubearmor/k8tls:latest | sudo k3s ctr images import -
kubectl apply -f ./tests/res/test-k8tls.yaml
sleep 10
- name: Checking if /tmp can be read
run: ls /tmp

- name: Check k8tls is completed
run: kubectl get pods -A
- name: Checking if /tmp can be read
run: ls /tmp
- name: Test k8tls using Ginkgo
run: |
# mkdir /tmp/k8tls
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo
make
working-directory: ./tests
Expand Down
File renamed without changes.
26 changes: 21 additions & 5 deletions tests/kubetls-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/csv"
"os"

. "github.com/kubearmor/KubeArmor/tests/util"
// . "github.com/kubearmor/KubeArmor/tests/util"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -14,15 +14,16 @@ var _ = BeforeSuite(func() {
// err := K8sApply([]string{"res/test-k8tls.yaml"})
// Expect(err).To(BeNil())
// install wordpress-mysql app
err := K8sApply([]string{"res/test-k8tls.yaml", "res/wordpress-mysql-dep.yaml"})
Expect(err).To(BeNil())
// err := K8sApply([]string{"res/test-k8tls.yaml"})
// Expect(err).To(BeNil())
// time.Sleep(5 * time.Second)

})

var _ = AfterSuite(func() {

err := K8sDelete([]string{"res/test-k8tls.yaml", "res/wordpress-mysql-dep.yaml"})
Expect(err).To(BeNil())
// err := K8sDelete([]string{"res/test-k8tls.yaml"})
// Expect(err).To(BeNil())

})

Expand All @@ -45,10 +46,22 @@ func matchCSV(file1 string, file2 string) {
file2Records, err := reader2.ReadAll()
Expect(err).NotTo(HaveOccurred())

// Determine the index of the "Address" column
addressColumnIndex := -1
for i, header := range file1Records[0] {
if header == "Address" {
addressColumnIndex = i
break
}
}

// Compare headers
Expect(len(file1Records[0])).To(Equal(len(file2Records[0])))

for i := 0; i < len(file1Records[0]); i++ {
if i == addressColumnIndex {
continue // Skip comparing the "Address" column
}
Expect(file1Records[0][i]).To(Equal(file2Records[0][i]))
}

Expand All @@ -57,6 +70,9 @@ func matchCSV(file1 string, file2 string) {

for i := 0; i < len(file1Records); i++ {
for j := 0; j < len(file1Records[i]); j++ {
if j == addressColumnIndex {
continue // Skip comparing the "Address" column
}
Expect(file1Records[i][j]).To(Equal(file2Records[i][j]))
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/res/test-k8tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
serviceAccountName: k8tls-serviceact
containers:
- name: k8tls
image: localhost/kubearmor/k8tls:latest
image: kubearmor/k8tls:latest
imagePullPolicy: Never
command: ["./k8s_tlsscan"]
volumeMounts:
Expand All @@ -51,6 +51,6 @@ spec:
volumes:
- name: hostpath-volume
hostPath:
path: /tmp/k8tls
path: /tmp
restartPolicy: Never
backoffLimit: 4
4 changes: 2 additions & 2 deletions tests/table-test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Name,Address,Status,Version,Ciphersuite,Hash,Signature,Verification
"kube-system/kube-dns[dns-tcp]","10.43.0.10:53","PLAIN_TEXT","","","","",""
"kube-system/kube-dns[metrics]","10.43.0.10:9153","PLAIN_TEXT","","","","",""
"kube-system/metrics-server[https]","10.43.215.100:443","TLS","TLSv1.3","TLS_AES_128_GCM_SHA256","SHA256","RSA-PSS","self-signed certificate in certificate chain"
"wordpress-mysql/wordpress","10.43.230.131:80","PLAIN_TEXT","","","","",""
"wordpress-mysql/mysql","10.43.5.5:3306","PLAIN_TEXT","","","","",""
"wordpress-mysql/wordpress","10.43.185.224:80","PLAIN_TEXT","","","","",""
"wordpress-mysql/mysql","10.43.169.33:3306","PLAIN_TEXT","","","","",""

0 comments on commit f92c422

Please sign in to comment.