Skip to content

Commit 8bcf3d5

Browse files
committed
update: add more test cases for scan parameters and fix failling CIs
Signed-off-by: freedisch <freeproduc@gmail.com>
1 parent 5149507 commit 8bcf3d5

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ jobs:
894894
go-version: ${{ env.GO_VERSION }}
895895

896896
- name: Run tests
897-
run: |
898-
cd sbctcl
899-
go test -v ./...
897+
working-directory: scbtcl
898+
run: go test -v ./...
900899

scbctl/cmd/scans.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727

2828
func init() {
2929
utilruntime.Must(v1.AddToScheme(scheme))
30+
ScanCmd.Flags().StringP("namespace", "n", "", "Namespace in which to create the scan")
3031
}
3132

3233
var ScanCmd = &cobra.Command{
@@ -61,7 +62,7 @@ var ScanCmd = &cobra.Command{
6162
namespace = namespaceFlag
6263
}
6364

64-
fmt.Printf("🆕 Creating a new scan with name '%s' and target '%s'\n", scanName, strings.Join(parameters, " "))
65+
fmt.Printf("🆕 Creating a new scan with name '%s' and parameters '%s'\n", scanName, strings.Join(parameters, " "))
6566

6667
scan := &v1.Scan{
6768
TypeMeta: metav1.TypeMeta{

scbctl/cmd/scans_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ func TestScanCommand(t *testing.T) {
4040
args: []string{"nmap", "--", "scanme.nmap.org"},
4141
expectedError: nil,
4242
},
43+
{
44+
name: "Valid entry with multiple parameters",
45+
args: []string{"nmap", "--", "scanme.nmap.org", "-p", "90"},
46+
expectedError: nil,
47+
},
4348
{
4449
name: "Valid entry with namespace",
45-
args: []string{"nmap", "--", "scanme.nmap.org"},
50+
args: []string{"scan", "--namespace", "foobar", "nmap", "--", "scanme.nmap.org"},
4651
expectedError: nil,
4752
},
4853
{
@@ -69,7 +74,10 @@ func TestScanCommand(t *testing.T) {
6974
RunE: ScanCmd.RunE,
7075
}
7176

77+
cmd.Flags().AddFlagSet(ScanCmd.Flags())
78+
7279
cmd.SetArgs(tc.args)
80+
cmd.SilenceUsage = true
7381

7482
err := cmd.Execute()
7583
if tc.expectedError != nil {

scbctl/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// SPDX-FileCopyrightText: the secureCodeBox authors
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
14
module github.com/secureCodeBox/secureCodeBox/scbctl
25

36
go 1.22.0

0 commit comments

Comments
 (0)