MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / requireValidDatabaseUpdatedEventPayload

Function requireValidDatabaseUpdatedEventPayload

rest/audit_test.go:686–706  ·  view source on GitHub ↗

requireValidDatabaseUpdatedEventPayload checks the audit log output for at least one database updated event, and validates that each payload can be used validly

(rt *RestTester, output []byte)

Source from the content-addressed store, hash-verified

684
685// requireValidDatabaseUpdatedEventPayload checks the audit log output for at least one database updated event, and validates that each payload can be used validly
686func requireValidDatabaseUpdatedEventPayload(rt *RestTester, output []byte) {
687 events := bytes.Split(output, []byte("\n"))
688 foundEvent := false
689 for _, rawEvent := range events {
690 if bytes.TrimSpace(rawEvent) == nil {
691 continue
692 }
693 var event struct {
694 ID base.AuditID `json:"id"`
695 Payload string `json:"payload"`
696 }
697 require.NoError(rt.TB(), base.JSONUnmarshal(rawEvent, &event))
698 if event.ID != base.AuditIDUpdateDatabaseConfig {
699 continue
700 }
701 require.NotEmpty(rt.TB(), event.Payload)
702 RequireStatus(rt.TB(), rt.SendAdminRequest(http.MethodPost, "/{{.db}}/_config", event.Payload), http.StatusCreated)
703 foundEvent = true
704 }
705 require.True(rt.TB(), foundEvent, "expected audit event not found")
706}
707
708func TestRedactConfigAsStr(t *testing.T) {
709 testCases := []struct {

Callers 1

TestAuditDatabaseUpdateFunction · 0.85

Calls 4

JSONUnmarshalFunction · 0.92
RequireStatusFunction · 0.85
SendAdminRequestMethod · 0.80
TBMethod · 0.65

Tested by

no test coverage detected