Skip to content

Commit

Permalink
issue #134 - wip
Browse files Browse the repository at this point in the history
Signed-off-by: adisos <[email protected]>
  • Loading branch information
adisos committed Jan 10, 2024
1 parent 5b290b1 commit c71d608
Show file tree
Hide file tree
Showing 7 changed files with 367 additions and 475 deletions.
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.

10 changes: 3 additions & 7 deletions pkg/ibmvpc/analysis_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ var tests = []*vpcGeneralTest{
format: vpcmodel.Text,
},
// multi-vpc config examples
{
/*{
name: "experiments_env",
useCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints},
format: vpcmodel.Text,
Expand All @@ -347,7 +347,7 @@ var tests = []*vpcGeneralTest{
name: "experiments_env",
useCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints},
format: vpcmodel.JSON,
},
},*/
{
name: "multiple_vpcs",
useCases: []vpcmodel.OutputUseCase{vpcmodel.AllSubnets},
Expand Down Expand Up @@ -508,11 +508,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
27 changes: 27 additions & 0 deletions pkg/ibmvpc/collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ibmvpc

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"testing"

"github.com/np-guard/cloud-resource-collector/pkg/ibm/datamodel"
)

func TestCollector(t *testing.T) {
inputConfig := "input_experiments_env.json"
inputConfigFile := filepath.Join(getTestsDir(), inputConfig)
inputConfigContent, err := os.ReadFile(inputConfigFile)
if err != nil {
t.Fatalf("err: %s", err)
}

config := datamodel.ResourcesContainerModel{}
err = json.Unmarshal(inputConfigContent, &config)
if err != nil {
t.Errorf("Unmarshal failed with error message: %v", err)
}
fmt.Println("done")
}
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

0 comments on commit c71d608

Please sign in to comment.