mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** The entire ACME feature branch merge # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters. - [x] Timeouts are implemented and retries are limited to avoid infinite loops ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually --------- Co-authored-by: Jordan Montgomery <elijah.jordan.montgomery@gmail.com> Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
25 lines
762 B
Go
25 lines
762 B
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
// MockACMEService is a mock implementation of fleet.ACMEWriteService
|
|
// for unit tests that use mock.Store instead of real MySQL connections.
|
|
type MockACMEService struct {
|
|
NewACMEEnrollmentFunc func(ctx context.Context, hostIdentifier string) (string, error)
|
|
NewACMEEnrollmentFuncInvoked bool
|
|
}
|
|
|
|
// Ensure MockACMEService implements fleet.ACMEWriteService.
|
|
var _ fleet.ACMEWriteService = (*MockACMEService)(nil)
|
|
|
|
func (m *MockACMEService) NewACMEEnrollment(ctx context.Context, hostIdentifier string) (string, error) {
|
|
m.NewACMEEnrollmentFuncInvoked = true
|
|
if m.NewACMEEnrollmentFunc != nil {
|
|
return m.NewACMEEnrollmentFunc(ctx, hostIdentifier)
|
|
}
|
|
return "", nil
|
|
}
|