From 997ded2250e0a8ade4dca3332499298ae036e3e5 Mon Sep 17 00:00:00 2001 From: Ambhrin Dhar Date: Wed, 24 Apr 2024 12:14:50 -0500 Subject: [PATCH] tests for language detection --- .../test-data/Csharp_Sample/src/Program.cs | 9 +++ .../test-data/Go_Sample/src/main.go | 7 +++ .../JavaScript_Sample/public/index.html | 11 ++++ .../test-data/JavaScript_Sample/src/index.js | 1 + .../test-data/Kotlin_Sample/src/Main.kt | 1 + .../test-data/Python_Sample/main.py | 1 + .../test-data/Swift_Sample/Sources/main.swift | 1 + .../test-data/Terraform_Sample/main.tf | 1 + .../test-data/TypeScript_Sample/src/index.ts | 1 + tests/end-to-end/test-language-detect.bats | 61 +++++++++++++++++++ 10 files changed, 94 insertions(+) create mode 100644 tests/end-to-end/test-data/Csharp_Sample/src/Program.cs create mode 100644 tests/end-to-end/test-data/Go_Sample/src/main.go create mode 100644 tests/end-to-end/test-data/JavaScript_Sample/public/index.html create mode 100644 tests/end-to-end/test-data/JavaScript_Sample/src/index.js create mode 100644 tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt create mode 100644 tests/end-to-end/test-data/Python_Sample/main.py create mode 100644 tests/end-to-end/test-data/Swift_Sample/Sources/main.swift create mode 100644 tests/end-to-end/test-data/Terraform_Sample/main.tf create mode 100644 tests/end-to-end/test-data/TypeScript_Sample/src/index.ts create mode 100644 tests/end-to-end/test-language-detect.bats diff --git a/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs b/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs new file mode 100644 index 00000000..6e1130f5 --- /dev/null +++ b/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs @@ -0,0 +1,9 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello, world!"); + } +} diff --git a/tests/end-to-end/test-data/Go_Sample/src/main.go b/tests/end-to-end/test-data/Go_Sample/src/main.go new file mode 100644 index 00000000..ef25884d --- /dev/null +++ b/tests/end-to-end/test-data/Go_Sample/src/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, world!") +} diff --git a/tests/end-to-end/test-data/JavaScript_Sample/public/index.html b/tests/end-to-end/test-data/JavaScript_Sample/public/index.html new file mode 100644 index 00000000..080cb0eb --- /dev/null +++ b/tests/end-to-end/test-data/JavaScript_Sample/public/index.html @@ -0,0 +1,11 @@ + + + + + + JavaScript_Sample + + + + + diff --git a/tests/end-to-end/test-data/JavaScript_Sample/src/index.js b/tests/end-to-end/test-data/JavaScript_Sample/src/index.js new file mode 100644 index 00000000..a8141d3b --- /dev/null +++ b/tests/end-to-end/test-data/JavaScript_Sample/src/index.js @@ -0,0 +1 @@ +console.log("Hello, world!"); diff --git a/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt b/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt new file mode 100644 index 00000000..d113eced --- /dev/null +++ b/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt @@ -0,0 +1 @@ +fun main() { println("Hello, world!") } diff --git a/tests/end-to-end/test-data/Python_Sample/main.py b/tests/end-to-end/test-data/Python_Sample/main.py new file mode 100644 index 00000000..f7cf60e1 --- /dev/null +++ b/tests/end-to-end/test-data/Python_Sample/main.py @@ -0,0 +1 @@ +print("Hello, world!") diff --git a/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift b/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift new file mode 100644 index 00000000..f7cf60e1 --- /dev/null +++ b/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift @@ -0,0 +1 @@ +print("Hello, world!") diff --git a/tests/end-to-end/test-data/Terraform_Sample/main.tf b/tests/end-to-end/test-data/Terraform_Sample/main.tf new file mode 100644 index 00000000..69b152ca --- /dev/null +++ b/tests/end-to-end/test-data/Terraform_Sample/main.tf @@ -0,0 +1 @@ +output "hello_world" { value = "Hello, world!" } diff --git a/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts b/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts new file mode 100644 index 00000000..a8141d3b --- /dev/null +++ b/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts @@ -0,0 +1 @@ +console.log("Hello, world!"); diff --git a/tests/end-to-end/test-language-detect.bats b/tests/end-to-end/test-language-detect.bats new file mode 100644 index 00000000..edb7ae52 --- /dev/null +++ b/tests/end-to-end/test-language-detect.bats @@ -0,0 +1,61 @@ +setup() { + load "${BATS_LIBS_ROOT}/bats-support/load" + load "${BATS_LIBS_ROOT}/bats-assert/load" +} + +@test "can detect C# language" { + #cd tests/end-to-end/test-data/Csharp_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] The following language(s) support secrets detection: C#' + assert_output --partial '[seCureLI] - C#: 100%' +} + +@test "can detect Go language" { + #cd tests/end-to-end/test-data/Go_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Go: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Go.' +} + +@test "can detect Javascript language" { + #cd tests/end-to-end/test-data/JavaScript_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - JavaScript: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): JavaScript.' +} + +@test "can detect Kotlin language" { + #cd tests/end-to-end/test-data/Kotlin_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Kotlin: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Kotlin.' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Kotlin.' +} + +@test "can detect Python language" { + #cd tests/end-to-end/test-data/Python_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Python: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Python.' +} + +@test "can detect Swift language" { + #cd tests/end-to-end/test-data/Swift_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Swift.' + assert_output --partial '[seCureLI] - Swift: 100%' +} + +@test "can detect Terraform language" { + #cd tests/end-to-end/test-data/Terraform_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Terraform: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Terraform.' +} + +@test "can detect Typescript language" { + #cd tests/end-to-end/test-data/Typescript_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - TypeScript: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): TypeScript.cd ..' +} \ No newline at end of file