Skip to content

Commit

Permalink
add windows serviceName tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Aug 14, 2024
1 parent a226fbc commit 0cdd0e9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions ee/debug/shipper/shipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func enrollSecret(k types.Knapsack) string {
return k.EnrollSecret()
}

// TODO this will need to respect the identifier when determining the secret file location for dual-launcher installations
b, err := os.ReadFile(launcher.DefaultPath(launcher.SecretFile))
if err != nil {
return ""
Expand Down
49 changes: 49 additions & 0 deletions pkg/launcher/pkg_utils_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//go:build windows
// +build windows

package launcher

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_ServiceName(t *testing.T) {
t.Parallel()

for _, tt := range []struct {
testCaseName string
identifier string
expectedServiceName string
}{
{
testCaseName: "empty identifier expecting default service name",
identifier: " ",
expectedServiceName: "LauncherKolideK2Svc",
},
{
testCaseName: "default identifier expecting default service name",
identifier: "kolide-k2",
expectedServiceName: "LauncherKolideK2Svc",
},
{
testCaseName: "preprod identifier expecting preprod service name",
identifier: "kolide-preprod-k2",
expectedServiceName: "LauncherKolidePreprodK2Svc",
},
{
testCaseName: "mangled identifier expecting default service name",
identifier: "kolide-!@_k2",
expectedServiceName: "LauncherKolideK2Svc",
},
} {
tt := tt
t.Run(tt.testCaseName, func(t *testing.T) {
t.Parallel()

serviceName := ServiceName(tt.identifier)
require.Equal(t, tt.expectedServiceName, serviceName, "expected sanitized service name value to match")
})
}
}

0 comments on commit 0cdd0e9

Please sign in to comment.