(t *testing.T)
| 827 | } |
| 828 | |
| 829 | func 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}, |
nothing calls this directly
no test coverage detected