mirror of
https://github.com/jessfraz/dockerfiles.git
synced 2025-12-10 06:52:40 +01:00
add ports flag to k8scan
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestARINResponse(t *testing.T) {
|
||||
info, err := getIPInfo("104.40.92.107")
|
||||
@@ -18,3 +21,41 @@ func TestARINResponse(t *testing.T) {
|
||||
t.Fatalf("expected reference to be https://whois.arin.net/rest/org/MSFT, got %s", info.Net.Organization.Reference)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePortRange(t *testing.T) {
|
||||
testFuncs := []struct {
|
||||
given string
|
||||
expected intSlice
|
||||
}{
|
||||
{
|
||||
given: "",
|
||||
expected: intSlice{80, 443, 8001, 9001},
|
||||
},
|
||||
{
|
||||
given: "80,443,9090",
|
||||
expected: intSlice{80, 443, 9090},
|
||||
},
|
||||
{
|
||||
given: "80-90",
|
||||
expected: intSlice{80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90},
|
||||
},
|
||||
{
|
||||
given: "22-24,80,8080-8083",
|
||||
expected: intSlice{22, 23, 24, 80, 8080, 8081, 8082, 8083},
|
||||
},
|
||||
{
|
||||
given: "80",
|
||||
expected: intSlice{80},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testFunc := range testFuncs {
|
||||
i := intSlice{}
|
||||
if err := i.Set(testFunc.given); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reflect.DeepEqual(testFunc.expected, i) {
|
||||
t.Fatalf("expected: %#v\ngot: %#v", testFunc.expected, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user