Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 134 - consume from the collector the ResourcesContainter #283

Merged
merged 6 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions cmd/analyzer/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
package main

import (
"errors"
"os"
"path/filepath"
"strings"
"testing"
)

// //////////////////////////////////
// this file need to be rewritten, no need to code review it
// ///////////////////////////////////////
func Test_main(t *testing.T) {
// TODO: this file need to be rewritten
func TestMain(t *testing.T) {
tests := []struct {
name string
args string
Expand All @@ -28,4 +29,18 @@ func Test_main(t *testing.T) {
}
})
}
removeGeneratedFiles()
}

func removeGeneratedFiles() {
files1, err1 := filepath.Glob("*.txt")
files2, err2 := filepath.Glob("*.drawio")
if err1 != nil || err2 != nil {
panic(errors.Join(err1, err2))
}
for _, f := range append(files1, files2...) {
if err := os.Remove(f); err != nil {
panic(err)
}
}
}
17 changes: 11 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,34 @@ go 1.21

require (
github.com/IBM/vpc-go-sdk v0.47.0
github.com/np-guard/cloud-resource-collector v0.4.0
github.com/np-guard/vpc-network-config-synthesis v0.1.0
github.com/stretchr/testify v1.8.4
)

require (
github.com/IBM/go-sdk-core/v5 v5.14.1 // indirect
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037 // indirect
github.com/IBM/go-sdk-core/v5 v5.15.0 // indirect
github.com/IBM/networking-go-sdk v0.44.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.13.0 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.11.4 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
221 changes: 203 additions & 18 deletions go.sum

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions pkg/ibmvpc/analysis_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,7 @@ func getVPCConfigs(t *testing.T, tt *vpcGeneralTest, firstCfg bool) map[string]*
inputConfig = tt.inputConfig2nd
}
inputConfigFile := filepath.Join(getTestsDir(), inputConfig)
inputConfigContent, err := os.ReadFile(inputConfigFile)
if err != nil {
t.Fatalf("err: %s", err)
}
rc, err := ParseResources(inputConfigContent)
rc, err := ParseResourcesFromFile(inputConfigFile)
if err != nil {
t.Fatalf("err: %s", err)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/ibmvpc/explainability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ibmvpc

import (
"fmt"
"os"
"testing"

"path/filepath"
Expand All @@ -16,11 +15,7 @@ import (
// getConfigs returns map[string]*vpcmodel.VPCConfig obj for the input test (config json file)
func getConfig(t *testing.T) *vpcmodel.VPCConfig {
inputConfigFile := filepath.Join(getTestsDir(), "input_sg_testing1_new.json")
inputConfigContent, err := os.ReadFile(inputConfigFile)
if err != nil {
t.Fatalf("err: %s", err)
}
rc, err := ParseResources(inputConfigContent)
rc, err := ParseResourcesFromFile(inputConfigFile)
if err != nil {
t.Fatalf("err: %s", err)
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/ibmvpc/naclAnalysis_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package ibmvpc

import (
_ "embed"
"fmt"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"

"github.com/np-guard/vpc-network-config-analyzer/pkg/common"
)

//go:embed examples/input_acl_testing3.json
var acl3Input []byte

func TestGetRules(t *testing.T) {
inputResourcesJSON := acl3Input
rc, err := ParseResources(inputResourcesJSON)
rc, err := ParseResourcesFromFile(filepath.Join(getTestsDir(), "input_acl_testing3.json"))
require.Nilf(t, err, "err: %s", err)
vpcConfigs, err := VPCConfigsFromResources(rc, "", false)
require.Nilf(t, err, "err: %s", err)
Expand Down
Loading