2022-09-30 00:16:26 +00:00
|
|
|
package authority
|
|
|
|
|
|
|
|
import (
|
2023-09-19 14:17:36 +00:00
|
|
|
"context"
|
|
|
|
|
2022-09-30 00:16:26 +00:00
|
|
|
"github.com/smallstep/certificates/authority/provisioner"
|
|
|
|
"github.com/smallstep/certificates/webhook"
|
|
|
|
)
|
|
|
|
|
|
|
|
type mockWebhookController struct {
|
|
|
|
enrichErr error
|
|
|
|
authorizeErr error
|
|
|
|
templateData provisioner.WebhookSetter
|
|
|
|
respData map[string]any
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ webhookController = &mockWebhookController{}
|
|
|
|
|
2023-09-19 14:17:36 +00:00
|
|
|
func (wc *mockWebhookController) Enrich(context.Context, *webhook.RequestBody) error {
|
2022-09-30 00:16:26 +00:00
|
|
|
for key, data := range wc.respData {
|
|
|
|
wc.templateData.SetWebhook(key, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
return wc.enrichErr
|
|
|
|
}
|
|
|
|
|
2023-09-19 14:17:36 +00:00
|
|
|
func (wc *mockWebhookController) Authorize(context.Context, *webhook.RequestBody) error {
|
2022-09-30 00:16:26 +00:00
|
|
|
return wc.authorizeErr
|
|
|
|
}
|