Documentation
¶
Overview ¶
Package clmtest provides an in-memory mock of the DocuSign eSignature /oauth/userinfo endpoint, CLM's account discovery endpoint, and the DocuSign CLM Object API, for use by tests in pkg/client and pkg/connector. It exists because no CLM production/sandbox tenant was available to validate this integration directly — this is how the CLM sync/provisioning code paths get exercised instead.
Anti-drift note ¶
This mock replicates the endpoint paths, query params, and response/request shapes documented for the real CLM API — not whatever the connector happens to call. If the connector and this mock ever disagree, treat that as a bug in the connector to fix, not something to paper over here.
Auth ¶
NewServer (used by this package's own Go tests) mocks no real OAuth flow: it returns a *client.Client already wired with a static token, and every endpoint handler requires "Authorization: Bearer <token>" matching that exact token — mirroring the strictness of the real API without needing a token endpoint.
RunStandalone (see cmd/test-server) is for manually pointing a real baton-docusign binary at this mock via --clm-base-url, while the connector still authenticates for real against DocuSign. Its bearer check only requires *a* token, not an exact value, since this mock has no way to independently validate a real DocuSign-issued token.
Endpoints ¶
GET /oauth/userinfo — eSignature account discovery (ensureInitialized)
GET /api/v2/{accountId}/account — CLM account discovery (ensureClmInitialized)
POST /v2/{accountId}/folders/search — SearchFolders
GET /v2/{accountId}/folders/{id} — GetFolder (supports ?expand=Security)
PATCH /v2/{accountId}/folders/{id} — PatchFolderSecurity
GET /v2/{accountId}/groups — ListGroups
GET /v2/{accountId}/groups/{id}/groupmembers — GetGroupMembers
GET /v2/{accountId}/members — ListMembers
GET /v2/{accountId}/members/{id}/groups — GetMemberGroups (paginated)
PATCH /v2/{accountId}/members/{id} — PatchMemberGroups (additive)
PUT /v2/{accountId}/members/{id} — PutMemberGroups (full-replace)
GET /v2/{accountId}/permissionsets — ListPermissionSets
Index ¶
- Constants
- func RunStandalone(addr string) error
- type Server
- func (s *Server) FolderHref(id string) string
- func (s *Server) FolderSecurity(folderID string) client.ClmFolderSecurity
- func (s *Server) GroupHref(id string) string
- func (s *Server) MemberGroups(memberID string) []string
- func (s *Server) MemberGroupsRequestCount() int
- func (s *Server) MemberHref(id string) string
- func (s *Server) NewClientWithToken(token string) *client.Client
- func (s *Server) URL() string
Constants ¶
const AccountID = "acct-clm-test"
AccountID is the fixed eSignature/CLM account ID used by every seeded fixture.
Variables ¶
This section is empty.
Functions ¶
func RunStandalone ¶
RunStandalone starts the same CLM mock as NewServer, but as a real, long-lived HTTP server on addr (e.g. "localhost:8765") instead of an ephemeral in-process httptest.Server — for manually pointing a real baton-docusign binary at it via --clm-base-url to exercise the CLM sync/provisioning paths against an account that has no CLM subscription of its own. Blocks until the server errors or is shut down.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the mock CLM (+ eSignature account discovery) API.
func NewServer ¶
NewServer starts the mock server, seeds it (see seed.go), and returns both the raw Server (for direct state assertions) and a *client.Client wired to talk to it exactly as it would talk to the real DocuSign/CLM hosts.
func (*Server) FolderHref ¶
FolderHref, GroupHref, MemberHref build the Href a real CLM response would use for a given ID — tests use these to seed Security entries / assert on parsed IDs.
func (*Server) FolderSecurity ¶
func (s *Server) FolderSecurity(folderID string) client.ClmFolderSecurity
FolderSecurity returns a defensive copy of the current (test-visible) Security state for a folder — three separate collections by principal type, see client.ClmFolderSecurity's doc — for assertions after a Grant/Revoke round trip.
func (*Server) MemberGroups ¶
MemberGroups returns the current (test-visible) group membership for a member, for assertions after a Grant/Revoke round trip.
func (*Server) MemberGroupsRequestCount ¶
MemberGroupsRequestCount returns how many times GET .../members/{id}/groups has been called, across all members — used to assert that GetMemberGroups actually issues multiple requests when a member has more groups than fit on one page, rather than silently returning a truncated single page.
func (*Server) MemberHref ¶
func (*Server) NewClientWithToken ¶
NewClientWithToken builds another *client.Client wired to this same running server (via the identical rewriteTransport, so it reaches the mock regardless of which real host it thinks it's talking to) but presenting an arbitrary bearer token instead of the fixed testBearerToken NewServer uses. Used to simulate an account/token that can't use CLM (wrong OAuth scope, no subscription) — requireAuth's strict mode rejects anything but the exact testBearerToken, so any other value exercises the connector's handling of a 401 from CLM.