(t *testing.T)
| 138 | } |
| 139 | |
| 140 | func TestGuestReadOnly(t *testing.T) { |
| 141 | rt := NewRestTester(t, &RestTesterConfig{ |
| 142 | GuestEnabled: true, |
| 143 | DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{ |
| 144 | Unsupported: &db.UnsupportedOptions{ |
| 145 | GuestReadOnly: true, |
| 146 | }, |
| 147 | }, |
| 148 | }}, |
| 149 | ) |
| 150 | defer rt.Close() |
| 151 | |
| 152 | const docID = "doc" |
| 153 | |
| 154 | // Write a document as admin |
| 155 | response := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+docID, `{"val": "test"}`) |
| 156 | RequireStatus(t, response, http.StatusCreated) |
| 157 | |
| 158 | // Attempt to read as guest |
| 159 | body := rt.GetDocBody(docID) |
| 160 | assert.Equal(t, "test", body["val"].(string)) |
| 161 | rev := body["_rev"].(string) |
| 162 | |
| 163 | // Attempt to write as guest |
| 164 | response = rt.SendRequest(http.MethodPut, "/{{.keyspace}}/doc?rev="+rev, `{"val": "newval"}`) |
| 165 | RequireStatus(t, response, http.StatusForbidden) |
| 166 | |
| 167 | // Attempt to access _blipsync as guest - blip sync handling for read-only GUEST is applied at replication level (to allow pull-only replications). |
| 168 | // Should succeed permission check, and only fail on websocket upgrade |
| 169 | response = rt.SendRequest(http.MethodGet, "/{{.db}}/_blipsync", "") |
| 170 | RequireStatus(t, response, http.StatusUpgradeRequired) |
| 171 | |
| 172 | // Verify matching on _blipsync path doesn't incorrectly match docs, attachments |
| 173 | response = rt.SendRequest(http.MethodPut, "/{{.keyspace}}/doc_named_blipsync", "") |
| 174 | RequireStatus(t, response, http.StatusForbidden) |
| 175 | response = rt.SendRequest(http.MethodPut, "/{{.keyspace}}/doc/_blipsync", "") |
| 176 | RequireStatus(t, response, http.StatusForbidden) |
| 177 | |
| 178 | } |
| 179 | |
| 180 | func TestGetDocWithCV(t *testing.T) { |
| 181 | rt := NewRestTesterPersistentConfig(t) |
nothing calls this directly
no test coverage detected