fleet/cmd/fleetctl/package_test.go
Benjamin Edwards 823775844e
added package command from orbit as fleetctl command (#1802)
* added package command from orbit as fleetctl command

* update deployment docs

* add changes file

* added tests for package command, run go mod tidy & go mod verify

* validate that package files exist

* comment out msi packaging test until we can investigate github runner permission issues
2021-09-09 01:34:12 -04:00

41 lines
1.8 KiB
Go

package main
import (
"github.com/stretchr/testify/require"
"os"
"testing"
)
func TestPackage(t *testing.T) {
// --type is required
runAppCheckErr(t, []string{"package", "deb"}, "Required flag \"type\" not set")
// if you provide -fleet-url & --enroll-secret are required together
runAppCheckErr(t, []string{"package", "--type=deb", "--fleet-url=https://localhost:8080"}, "--enroll-secret and --fleet-url must be provided together")
runAppCheckErr(t, []string{"package", "--type=deb", "--enroll-secret=foobar"}, "--enroll-secret and --fleet-url must be provided together")
// --insecure and --fleet-certificate are mutually exclusive
runAppCheckErr(t, []string{"package", "--type=deb", "--insecure", "--fleet-certificate=test123"}, "--insecure and --fleet-certificate may not be provided together")
// run package tests, each should output their respective package type
// orbit-osquery_0.0.3_amd64.deb
runAppForTest(t, []string{"package", "--type=deb", "--insecure"})
info, err := os.Stat("orbit-osquery_0.0.3_amd64.deb")
require.NoError(t, err)
require.Greater(t, info.Size(), int64(0)) // TODO verify contents
// orbit-osquery-0.0.3.x86_64.rpm
runAppForTest(t, []string{"package", "--type=rpm", "--insecure"})
info, err = os.Stat("orbit-osquery-0.0.3.x86_64.rpm")
require.NoError(t, err)
require.Greater(t, info.Size(), int64(0)) // TODO verify contents
// orbit-osquery_0.0.3.msi
//runAppForTest(t, []string{"package", "--type=msi", "--insecure"}) TODO: this is currently failing on Github runners due to permission issues
//info, err = os.Stat("orbit-osquery_0.0.3.msi")
//require.NoError(t, err)
//require.Greater(t, info.Size(), int64(0))
//runAppForTest(t, []string{"package", "--type=pkg", "--insecure"}) TODO: had a hard time getting xar installed on Ubuntu
}