File: webhook_test.go

package info (click to toggle)
golang-github-smallstep-certificates 0.28.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,684 kB
  • sloc: sh: 367; makefile: 129
file content (29 lines) | stat: -rw-r--r-- 656 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package authority

import (
	"context"

	"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{}

func (wc *mockWebhookController) Enrich(context.Context, *webhook.RequestBody) error {
	for key, data := range wc.respData {
		wc.templateData.SetWebhook(key, data)
	}

	return wc.enrichErr
}

func (wc *mockWebhookController) Authorize(context.Context, *webhook.RequestBody) error {
	return wc.authorizeErr
}