clmtest

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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}/foldersearchtasks             — SearchFolders (create task; resolves inline)
GET   /v2/{accountId}/foldersearchtasks/{id}        — SearchFolders (poll a task — see PendingFolderSearchPolls)
GET   /v2/{accountId}/foldersearchtasks/{id}/result — SearchFolders (continuation pages)
GET   /v2/{accountId}/folders/{id}                  — GetFolder (supports ?expand=Security)
POST  /v2/{accountId}/changesecuritytasks           — PatchFolderSecurity (create task; resolves inline)
GET   /v2/{accountId}/changesecuritytasks/{id}      — PatchFolderSecurity (poll a task — see PendingChangeSecurityPolls)
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
GET   /v2/{accountId}/members/{id}/workflowqueues    — GetMemberWorkflowQueues (paginated)

Index

Constants

View Source
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

func RunStandalone(addr string) error

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

func NewServer(t testing.TB) (*Server, *client.Client)

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) AddBulkWorkflowQueueMember added in v0.1.9

func (s *Server) AddBulkWorkflowQueueMember(memberID string, queueCount int)

AddBulkWorkflowQueueMember adds a new member (not part of the default seed) who belongs to queueCount newly created, distinct workflow queues — for pagination tests that need a member with more workflow-queue memberships than fit on one page, without perturbing the default seed's member count or distinct-queue count that other tests (both here and in pkg/connector) assert on. Call after NewServer returns.

func (*Server) AddMemberWithoutHref added in v0.1.9

func (s *Server) AddMemberWithoutHref(memberID string)

AddMemberWithoutHref seeds a member with an empty Href — clmIDFromHref then reports an empty ID for it, exercising List()'s empty-memberID guard (a malformed record CLM's own API could plausibly return; this connector's endpoint shapes are documented-but-unexercised against a live tenant) without the scan ever reaching GetMemberWorkflowQueues for this member. Call after NewServer returns.

func (*Server) AddMemberWorkflowQueueWithEmptyHref added in v0.1.9

func (s *Server) AddMemberWorkflowQueueWithEmptyHref(memberID string)

AddMemberWorkflowQueueWithEmptyHref seeds a new member (not part of the default seed) with a single workflow-queue membership whose Href is empty — clmIDFromHref then reports an empty ID for it, exercising clm_workflow_queue.List()'s skip-unusable-ID guard for one queue within an otherwise normal member scan. Mirrors AddMemberWithoutHref's equivalent case at the member level. Call after NewServer returns.

func (*Server) FolderHref

func (s *Server) FolderHref(id string) string

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) ForceMemberWorkflowQueuesStatus added in v0.1.9

func (s *Server) ForceMemberWorkflowQueuesStatus(memberID string, status int)

ForceMemberWorkflowQueuesStatus makes GET .../members/{id}/workflowqueues fail with the given HTTP status for exactly this memberID — for tests that need a specific gRPC code (e.g. PermissionDenied/Unauthenticated) out of one particular member's call, distinct from the unknown-member 404 handleMemberWorkflowQueues already produces for an ID absent from the seed. Call after NewServer returns.

func (*Server) GroupHref

func (s *Server) GroupHref(id string) string

func (*Server) LastPatchedMemberGroupHrefs added in v0.1.9

func (s *Server) LastPatchedMemberGroupHrefs(memberID string) []string

LastPatchedMemberGroupHrefs returns the raw Href strings the most recent PATCH .../members/{id} request body carried for memberID — unlike MemberGroups (which reduces everything to the trailing ID via idFromHref, the same as the real API's own comparison semantics), this exposes the exact Href the connector sent, so a test can tell a sample-derived Href from a base-URL-derived one even when the two mock helpers that build them happen to produce byte-identical strings.

func (*Server) MemberGroups

func (s *Server) MemberGroups(memberID string) []string

MemberGroups returns the current (test-visible) group membership for a member, for assertions after a Grant/Revoke round trip.

func (*Server) MemberGroupsRequestCount

func (s *Server) MemberGroupsRequestCount() int

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 (s *Server) MemberHref(id string) string

func (*Server) MemberWorkflowQueuesRequestCount added in v0.1.9

func (s *Server) MemberWorkflowQueuesRequestCount() int

MemberWorkflowQueuesRequestCount is MemberGroupsRequestCount's equivalent for GET .../members/{id}/workflowqueues.

func (*Server) NewClientWithToken

func (s *Server) NewClientWithToken(token string) *client.Client

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.

func (*Server) SetFolderGroupSecurityHref added in v0.1.9

func (s *Server) SetFolderGroupSecurityHref(folderID, groupID, href string)

SetFolderGroupSecurityHref and SetFolderUserSecurityHref override the Href of an existing group/user security entry on a seeded folder (matched by ID via idFromHref), letting a test make it observably different from what client.GroupHref/MemberHref's fallback would produce for a different, derived ID — the same lever SetGroupHref gives GetMemberGroups-based tests, needed here because folder security entries carry no separate ID field of their own.

func (*Server) SetFolderSearchTaskHrefOverride added in v0.1.9

func (s *Server) SetFolderSearchTaskHrefOverride(href string)

SetFolderSearchTaskHrefOverride makes the next folder search task response carry the given Href instead of this server's own — used to pin the client's host-validation guard (Client.validateClmURL) against a task Href pointing at an unexpected host.

func (*Server) SetFolderUserSecurityHref added in v0.1.9

func (s *Server) SetFolderUserSecurityHref(folderID, memberID, href string)

func (*Server) SetGroupHref added in v0.1.9

func (s *Server) SetGroupHref(id, href string)

SetGroupHref overrides the Href a seeded group reports on GetMemberGroups, letting a test make it observably different from what GroupHref (and so client.GroupHref's fallback derivation, which builds the same shape from the discovered base URL) would produce — needed to distinguish a sample-derived Href from a fallback-derived one when both would otherwise be byte-identical.

func (*Server) SetOmitFolderSearchResultHref added in v0.1.9

func (s *Server) SetOmitFolderSearchResultHref(omit bool)

SetOmitFolderSearchResultHref makes the next successful FolderSearchTasks response leave Result.Href empty. Used to pin SearchFolders' guard against minting a continuation token that would re-POST a new search (page-1 loop).

func (*Server) SetPendingChangeSecurityPolls added in v0.1.9

func (s *Server) SetPendingChangeSecurityPolls(n int)

SetPendingChangeSecurityPolls makes the next change-security task created by this server require n polls of GET .../changesecuritytasks/{id} before resolving to "success" — exercises PatchFolderSecurity's awaitClmChangeSecurityTask polling loop, unverified against a live tenant (see PatchFolderSecurity's doc in clm_client.go).

func (*Server) SetPendingFolderSearchPolls added in v0.1.9

func (s *Server) SetPendingFolderSearchPolls(n int)

SetPendingFolderSearchPolls makes the next folder search task created by this server require n polls of GET .../foldersearchtasks/{id} before resolving to "Success" — exercises SearchFolders' awaitClmFolderSearchTask polling loop, which every live test against a real CLM tenant resolved past on the first try (inline in the POST response), leaving that branch otherwise untested.

func (*Server) URL

func (s *Server) URL() string

URL returns the mock server's base URL — also what handleClmAccountDiscovery returns as the CLM API base URL.

func (*Server) WorkflowQueueHref added in v0.1.9

func (s *Server) WorkflowQueueHref(id string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL