Skip to content

Commit b442180

Browse files
committed
CBG-2551: re-enable skipped test
1 parent 0a76af5 commit b442180

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

rest/api_collections_test.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,11 @@ func TestMultiCollectionDynamicChannelAccess(t *testing.T) {
479479
// TestCollectionsSGIndexQuery is more of an end-to-end test to ensure SG indexes are built correctly,
480480
// and the channel access query is able to run when pulling a document as a user, and backfill the channel cache.
481481
func TestCollectionsSGIndexQuery(t *testing.T) {
482-
t.Skip("Requires config-based collection channel assignment (pending CBG-2551)")
483482
base.TestRequiresCollections(t)
484483

485-
// force GSI for this one test
486-
useViews := base.Ptr(false)
487-
488484
const (
489485
username = "alice"
490-
password = "letmein"
486+
password = RestTesterDefaultUserPassword
491487
validChannel = "valid"
492488
invalidChannel = "invalid"
493489

@@ -496,26 +492,18 @@ func TestCollectionsSGIndexQuery(t *testing.T) {
496492
)
497493

498494
rt := NewRestTester(t, &RestTesterConfig{
499-
DatabaseConfig: &DatabaseConfig{
500-
DbConfig: DbConfig{
501-
UseViews: useViews,
502-
Users: map[string]*auth.PrincipalConfig{
503-
username: {
504-
ExplicitChannels: base.SetOf(validChannel),
505-
Password: base.Ptr(password),
506-
},
507-
},
508-
},
509-
},
495+
SyncFn: channels.DocChannelsSyncFunction,
510496
})
511497
defer rt.Close()
512498

499+
rt.CreateUser(username, []string{validChannel})
500+
513501
resp := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+validDocID, `{"test": true, "channels": ["`+validChannel+`"]}`)
514502
RequireStatus(t, resp, http.StatusCreated)
515503
resp = rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+invalidDocID, `{"test": true, "channels": ["`+invalidChannel+`"]}`)
516504
RequireStatus(t, resp, http.StatusCreated)
517505

518-
resp = rt.SendUserRequestWithHeaders(http.MethodGet, "/db/_all_docs", ``, nil, username, password)
506+
resp = rt.SendUserRequestWithHeaders(http.MethodGet, "/{{.keyspace}}/_all_docs", ``, nil, username, password)
519507
RequireStatus(t, resp, http.StatusOK)
520508
var allDocsResponse struct {
521509
TotalRows int `json:"total_rows"`
@@ -533,7 +521,9 @@ func TestCollectionsSGIndexQuery(t *testing.T) {
533521
resp = rt.SendUserRequestWithHeaders(http.MethodGet, "/{{.keyspace}}/"+invalidDocID, ``, nil, username, password)
534522
RequireStatus(t, resp, http.StatusForbidden)
535523

536-
rt.WaitForChanges(1, "/{{.keyspace}}/_changes", username, false)
524+
rt.WaitForPendingChanges()
525+
changes := rt.GetChanges("/{{.keyspace}}/_changes", username)
526+
changes.RequireDocIDs(t, []string{"_user/" + username, validDocID})
537527
}
538528

539529
func TestCollectionsPutDBInexistentCollection(t *testing.T) {

0 commit comments

Comments
 (0)