(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestChangesAccessNotifyInteger(t *testing.T) { |
| 29 | |
| 30 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyChanges, base.KeyHTTP) |
| 31 | |
| 32 | rt := NewRestTester(t, |
| 33 | &RestTesterConfig{SyncFn: `function(doc) {channel(doc.channel); access(doc.accessUser, doc.accessChannel);}`}) |
| 34 | defer rt.Close() |
| 35 | |
| 36 | // Create user: |
| 37 | ctx := rt.Context() |
| 38 | a := rt.ServerContext().Database(ctx, "db").Authenticator(ctx) |
| 39 | bernard, err := a.NewUser("bernard", "letmein", channels.BaseSetOf(t, "ABC")) |
| 40 | assert.NoError(t, err) |
| 41 | assert.NoError(t, a.Save(bernard)) |
| 42 | |
| 43 | // Put several documents in channel PBS |
| 44 | response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs1", `{"value":1, "channel":["PBS"]}`) |
| 45 | RequireStatus(t, response, 201) |
| 46 | response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs2", `{"value":2, "channel":["PBS"]}`) |
| 47 | RequireStatus(t, response, 201) |
| 48 | response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs3", `{"value":3, "channel":["PBS"]}`) |
| 49 | RequireStatus(t, response, 201) |
| 50 | |
| 51 | // make sure docs are written to change cache |
| 52 | rt.WaitForPendingChanges() |
| 53 | caughtUpWaiter := rt.GetDatabase().NewPullReplicationCaughtUpWaiter(t) |
| 54 | // Start longpoll changes request |
| 55 | var wg sync.WaitGroup |
| 56 | wg.Add(1) |
| 57 | go func() { |
| 58 | defer wg.Done() |
| 59 | changesJSON := `{"style":"all_docs", "heartbeat":300000, "feed":"longpoll", "limit":50, "since":"0"}` |
| 60 | changes := rt.PostChanges("/{{.keyspace}}/_changes", changesJSON, "bernard") |
| 61 | assert.Len(t, changes.Results, 3) |
| 62 | }() |
| 63 | |
| 64 | // Wait for changes to get into wait mode |
| 65 | caughtUpWaiter.AddAndWait(1) |
| 66 | |
| 67 | // Put document that triggers access grant for user, PBS |
| 68 | response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/access1", `{"accessUser":"bernard", "accessChannel":["PBS"]}`) |
| 69 | RequireStatus(t, response, 201) |
| 70 | |
| 71 | wg.Wait() |
| 72 | } |
| 73 | |
| 74 | // Test for SG issue #1999. Verify that the notify handling works as expected when the user specifies a channel filter that includes channels |
| 75 | // the user doesn't have access to, where those channels have been updated more recently than the user and/or the valid channels. Non-granted |
nothing calls this directly
no test coverage detected