Skip to content

Commit

Permalink
WIP: Removed test
Browse files Browse the repository at this point in the history
  • Loading branch information
afek854 committed Oct 7, 2024
1 parent db381e6 commit 6842e56
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
4 changes: 1 addition & 3 deletions pkg/registry/file/dynamicpathdetector/analyze_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ func AnalyzeURL(urlString string, analyzer *PathAnalyzer) (string, error) {
}

func MergeDuplicateEndpoints(endpoints []*types.HTTPEndpoint) []*types.HTTPEndpoint {
fmt.Println("Merging duplicate endpoints")
fmt.Println("Before", endpoints)
seen := make(map[string]*types.HTTPEndpoint)
var newEndpoints []*types.HTTPEndpoint
for _, endpoint := range endpoints {
Expand All @@ -102,7 +100,7 @@ func MergeDuplicateEndpoints(endpoints []*types.HTTPEndpoint) []*types.HTTPEndpo
newEndpoints = append(newEndpoints, endpoint)
}
}
fmt.Println("After", newEndpoints)

return newEndpoints
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,30 +213,3 @@ func TestAnalyzeEndpointsWithInvalidURL(t *testing.T) {
result := dynamicpathdetector.AnalyzeEndpoints(&input, analyzer)
assert.Equal(t, 0, len(result))
}

func TestAnalyzeEndpointsBug(t *testing.T) {
analyzer := dynamicpathdetector.NewPathAnalyzer(100)

endpoints := []types.HTTPEndpoint{
types.HTTPEndpoint{Endpoint: ":8000/", Methods: []string{"GET"}, Internal: false, Direction: "inbound", Headers: json.RawMessage{0x7b, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x5b, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x5d, 0x2c, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x5b, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x30, 0x30, 0x22, 0x5d, 0x7d}},
types.HTTPEndpoint{Endpoint: ":8000/", Methods: []string{"GET"}, Internal: false, Direction: "inbound", Headers: json.RawMessage{0x7b, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x5b, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x5d, 0x2c, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x5b, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x30, 0x30, 0x22, 0x5d, 0x7d}},

types.HTTPEndpoint{Endpoint: ":8000/", Methods: []string{"GET"}, Internal: false, Direction: "inbound", Headers: json.RawMessage{0x7b, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x5b, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x5d, 0x2c, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x5b, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x30, 0x30, 0x22, 0x5d, 0x7d}},
}

for i := 0; i < 120; i++ {
e := types.HTTPEndpoint{Endpoint: fmt.Sprintf(":8000/users/%d", i), Methods: []string{"GET"}, Internal: false, Direction: "inbound", Headers: json.RawMessage{0x7b, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x5b, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x5d, 0x2c, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x5b, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x30, 0x30, 0x22, 0x5d, 0x7d}}
endpoints = append(endpoints, e)
}

fmt.Println(endpoints)

result := dynamicpathdetector.AnalyzeEndpoints(&endpoints, analyzer)

endpoints = result
c := types.HTTPEndpoint{Endpoint: ":8000/", Methods: []string{"POST"}, Internal: false, Direction: "inbound", Headers: json.RawMessage{0x7b, 0x22, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x5b, 0x22, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x22, 0x5d, 0x2c, 0x22, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x5b, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x38, 0x30, 0x30, 0x30, 0x22, 0x5d, 0x7d}}
endpoints = append(endpoints, c)
result = dynamicpathdetector.AnalyzeEndpoints(&endpoints, analyzer)
fmt.Println(result)

}

0 comments on commit 6842e56

Please sign in to comment.