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

Function TestAuditDatabaseUpdate

rest/audit_test.go:626–683  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

624}
625
626func TestAuditDatabaseUpdate(t *testing.T) {
627 rt := createAuditLoggingRestTester(t)
628 defer rt.Close()
629
630 dbConfig := rt.NewDbConfig()
631 dbConfig.Logging = &DbLoggingConfig{
632 Audit: &DbAuditLoggingConfig{
633 Enabled: base.Ptr(true),
634 EnabledEvents: base.Ptr([]uint{
635 uint(base.AuditIDUpdateDatabaseConfig),
636 }),
637 },
638 }
639
640 // initialize RestTester
641 RequireStatus(t, rt.CreateDatabase("db", dbConfig), http.StatusCreated)
642
643 testCases := []struct {
644 name string
645 method string
646 path string
647 body string
648 }{
649 {
650 name: "update sync function",
651 method: http.MethodPut,
652 path: "/{{.keyspace}}/_config/sync",
653 body: `function(doc){}`,
654 },
655 {
656 name: "update import filter",
657 method: http.MethodPut,
658 path: "/{{.keyspace}}/_config/import_filter",
659 body: `function(doc){}`,
660 },
661 {
662 name: "delete sync function",
663 method: http.MethodDelete,
664 path: "/{{.keyspace}}/_config/sync",
665 body: ``,
666 },
667 {
668 name: "delete import filter",
669 method: http.MethodDelete,
670 path: "/{{.keyspace}}/_config/import_filter",
671 body: ``,
672 },
673 }
674 for _, testCase := range testCases {
675 rt.Run(testCase.name, func(t *testing.T) {
676 output := base.AuditLogContents(t, func(t testing.TB) {
677 resp := rt.SendAdminRequest(testCase.method, testCase.path, testCase.body)
678 RequireStatus(t, resp, http.StatusOK)
679 })
680 requireValidDatabaseUpdatedEventPayload(rt, output)
681 })
682 }
683}

Callers

nothing calls this directly

Calls 10

PtrFunction · 0.92
AuditLogContentsFunction · 0.92
RequireStatusFunction · 0.85
NewDbConfigMethod · 0.80
CreateDatabaseMethod · 0.80
SendAdminRequestMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected