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

Function TestAuditDocumentRead

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

Source from the content-addressed store, hash-verified

827}
828
829func TestAuditDocumentRead(t *testing.T) {
830 rt := createAuditLoggingRestTester(t)
831 defer rt.Close()
832
833 dbConfig := rt.NewDbConfig()
834 dbConfig.Logging = &DbLoggingConfig{
835 Audit: &DbAuditLoggingConfig{
836 Enabled: base.Ptr(true),
837 EnabledEvents: base.Ptr([]uint{
838 uint(base.AuditIDDocumentRead),
839 uint(base.AuditIDDocumentMetadataRead),
840 }),
841 },
842 }
843
844 RequireStatus(t, rt.CreateDatabase("db", dbConfig), http.StatusCreated)
845
846 const docID = "doc1"
847 docVersion := rt.CreateTestDoc(docID)
848
849 type testCase struct {
850 name string
851 method string
852 path string
853 requestBody string
854 docID string
855 docReadVersions []string
856 docMetadataReadCount int
857 }
858 testCases := []testCase{
859 {
860 name: "get doc",
861 method: http.MethodGet,
862 path: "/{{.keyspace}}/doc1",
863 docID: "doc1",
864 docReadVersions: []string{docVersion.RevTreeID},
865 },
866 {
867 name: "get doc with rev",
868 method: http.MethodGet,
869 path: "/{{.keyspace}}/doc1?rev=" + docVersion.RevTreeID,
870 docID: "doc1",
871 docReadVersions: []string{docVersion.RevTreeID},
872 },
873 {
874 name: "get doc with openrevs",
875 method: http.MethodGet,
876 path: "/{{.keyspace}}/doc1?open_revs=all",
877 docID: "doc1",
878 docReadVersions: []string{docVersion.RevTreeID},
879 },
880 {
881 name: "_bulk_get",
882 method: http.MethodPost,
883 path: "/{{.keyspace}}/_bulk_get",
884 requestBody: string(base.MustJSONMarshal(t, db.Body{
885 "docs": []db.Body{
886 {"id": "doc1", "rev": docVersion.RevTreeID},

Callers

nothing calls this directly

Calls 14

PtrFunction · 0.92
MustJSONMarshalFunction · 0.92
IsEnterpriseEditionFunction · 0.92
AuditLogContentsFunction · 0.92
RequireStatusFunction · 0.85
NewDbConfigMethod · 0.80
CreateDatabaseMethod · 0.80
CreateTestDocMethod · 0.80
SendAdminRequestMethod · 0.80

Tested by

no test coverage detected