Skip to content

Commit

Permalink
WIP: Added tests for extra
Browse files Browse the repository at this point in the history
  • Loading branch information
afek854 committed Sep 9, 2024
1 parent ee792eb commit 08d18d2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/registry/file/applicationprofile_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ func deflateApplicationProfileContainer(container softwarecomposition.Applicatio
Syscalls: mapset.Sorted(mapset.NewThreadUnsafeSet(container.Syscalls...)),
SeccompProfile: container.SeccompProfile,
Endpoints: endpoints,
Extra: container.Extra,
}
}
22 changes: 21 additions & 1 deletion pkg/registry/file/applicationprofile_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ func TestApplicationProfileProcessor_PreSave(t *testing.T) {
Headers: map[string][]string{},
},
},
Extra: map[string][]map[string]string{
"metadata": {
{"version": "v1"},
{"environment": "production"},
},
"security": {
{"encryption": "AES-256"},
{"audit": "enabled"},
},
},
},
},
},
Expand Down Expand Up @@ -127,13 +137,23 @@ func TestApplicationProfileProcessor_PreSave(t *testing.T) {
Syscalls: []string{},
Endpoints: []softwarecomposition.HTTPEndpoint{
{
Endpoint: "http://localhost:8080",
Endpoint: "localhost/",
Methods: []string{"GET"},
Internal: consts.False,
Direction: consts.Inbound,
Headers: map[string][]string{},
},
},
Extra: map[string][]map[string]string{
"metadata": {
{"version": "v1"},
{"environment": "production"},
},
"security": {
{"encryption": "AES-256"},
{"audit": "enabled"},
},
},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/registry/file/dynamicpathdetector/analyze_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func AnalyzeURL(urlString string, analyzer *PathAnalyzer) (string, error) {
hostname := parsedURL.Hostname()

path, _ := analyzer.AnalyzePath(parsedURL.Path, hostname)
if path == "/." {
path = "/"
}
return hostname + path, nil
}

Expand Down

0 comments on commit 08d18d2

Please sign in to comment.