chore: improve testing coverage on ExtractProvisionerDaemonAuthenticated middleware (#15622)

This one aims to resolve #15604 

Created some table tests for the main cases - 
also preferred to create two isolated cases for the most complicated
cases in order to keep table tests simple enough.

Give us full coverage on the middleware logic, for both optional and non
optional cases - PSK and ProvisionerKey.
This commit is contained in:
Vincent Vielle
2024-11-26 04:02:20 +01:00
committed by GitHub
parent d60b58874e
commit 60ddcf5de2
3 changed files with 298 additions and 0 deletions
+3
View File
@@ -25,6 +25,9 @@ type ExtractProvisionerAuthConfig struct {
PSK string
}
// ExtractProvisionerDaemonAuthenticated authenticates a request as a provisioner daemon.
// If the request is not authenticated, the next handler is called unless Optional is true.
// This function currently is tested inside the enterprise package.
func ExtractProvisionerDaemonAuthenticated(opts ExtractProvisionerAuthConfig) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {