-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Roberto Scolaro <[email protected]>
- Loading branch information
1 parent
63b6bf3
commit 3554a49
Showing
16 changed files
with
1,889 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package install_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/distribution/distribution/v3/configuration" | ||
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/spf13/cobra" | ||
"oras.land/oras-go/v2/registry/remote" | ||
|
||
"github.com/falcosecurity/falcoctl/cmd" | ||
commonoptions "github.com/falcosecurity/falcoctl/pkg/options" | ||
testutils "github.com/falcosecurity/falcoctl/pkg/test" | ||
) | ||
|
||
const ( | ||
rulesfiletgz = "../../../pkg/test/data/rules.tar.gz" | ||
rulesfileyaml = "../../../pkg/test/data/rules.yaml" | ||
plugintgz = "../../../pkg/test/data/plugin.tar.gz" | ||
) | ||
|
||
var ( | ||
registry string | ||
ctx = context.Background() | ||
output = gbytes.NewBuffer() | ||
rootCmd *cobra.Command | ||
opt *commonoptions.CommonOptions | ||
port int | ||
orasRegistry *remote.Registry | ||
configFile string | ||
err error | ||
args []string | ||
) | ||
|
||
func TestInstall(t *testing.T) { | ||
var err error | ||
RegisterFailHandler(Fail) | ||
port, err = testutils.FreePort() | ||
Expect(err).ToNot(HaveOccurred()) | ||
registry = fmt.Sprintf("localhost:%d", port) | ||
RunSpecs(t, "root suite") | ||
} | ||
|
||
var _ = BeforeSuite(func() { | ||
config := &configuration.Configuration{} | ||
config.HTTP.Addr = fmt.Sprintf("localhost:%d", port) | ||
// Create and configure the common options. | ||
opt = commonoptions.NewOptions() | ||
opt.Initialize(commonoptions.WithWriter(output)) | ||
opt.Printer.DisableStylingf() | ||
|
||
// Create the oras registry. | ||
orasRegistry, err = testutils.NewOrasRegistry(registry, true) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
// Start the local registry. | ||
go func() { | ||
err := testutils.StartRegistry(context.Background(), config) | ||
Expect(err).ToNot(BeNil()) | ||
}() | ||
|
||
// Create temporary directory used to save the configuration file. | ||
configFile, err = testutils.CreateEmptyFile("falcoctl.yaml") | ||
Expect(err).Should(Succeed()) | ||
|
||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
configDir := filepath.Dir(configFile) | ||
Expect(os.RemoveAll(configDir)).Should(Succeed()) | ||
}) | ||
|
||
func executeRoot(args []string) error { | ||
rootCmd.SetArgs(args) | ||
rootCmd.SetOut(output) | ||
return cmd.Execute(rootCmd, opt.Printer) | ||
} |
Oops, something went wrong.