mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Add tests for no hash given or available
This commit is contained in:
parent
ebd96011fc
commit
9dd4b7fc8d
6 changed files with 711 additions and 44 deletions
|
|
@ -18,9 +18,10 @@ import (
|
|||
|
||||
// ProviderParams configures the test provider.
|
||||
type ProviderParams struct {
|
||||
URL string
|
||||
EnableSha256 bool
|
||||
EnableSha512 bool
|
||||
URL string
|
||||
EnableSha256 bool
|
||||
EnableSha512 bool
|
||||
ForbidHashFetching bool
|
||||
}
|
||||
|
||||
// ProviderHandler returns a test provider handler with the specified configuration.
|
||||
|
|
@ -49,6 +50,9 @@ func ProviderHandler(params *ProviderParams, directoryProvider bool) http.Handle
|
|||
w.Header().Add("Content-Type", "text/html")
|
||||
case strings.HasSuffix(path, ".json"):
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
case (strings.HasSuffix(path, ".sha256") || strings.HasSuffix(path, ".sha512")) && params.ForbidHashFetching:
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
case strings.HasSuffix(path, ".sha256") && directoryProvider && !params.EnableSha256:
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue