(t *testing.T)
| 402 | } |
| 403 | |
| 404 | func TestRebuildUserChannelsMultiCollection(t *testing.T) { |
| 405 | ctx := base.TestCtx(t) |
| 406 | bucket := base.GetTestBucket(t) |
| 407 | defer bucket.Close(ctx) |
| 408 | dataStore := bucket.GetSingleDataStore() |
| 409 | computer := mockComputer{} |
| 410 | computer.AddChannelsForCollection(base.DefaultScope, base.DefaultCollection, ch.AtSequence(ch.BaseSetOf(t, "derived1", "derived2"), 1)) |
| 411 | computer.AddChannelsForCollection("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "derived3", "derived4"), 1)) |
| 412 | |
| 413 | options := DefaultAuthenticatorOptions(ctx) |
| 414 | options.Collections = map[string]map[string]struct{}{ |
| 415 | base.DefaultScope: {base.DefaultCollection: struct{}{}}, |
| 416 | "scope1": {"collection1": struct{}{}}, |
| 417 | } |
| 418 | auth := NewTestAuthenticator(t, dataStore, &computer, options) |
| 419 | user, _ := auth.NewUser("testUser", "password", ch.BaseSetOf(t, "explicit1")) |
| 420 | user.SetCollectionExplicitChannels("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "explicit2"), 1), 0) |
| 421 | err := auth.Save(user) |
| 422 | assert.NoError(t, err) |
| 423 | |
| 424 | err = auth.InvalidateChannels("testUser", true, base.ScopeAndCollectionNames{base.NewScopeAndCollectionName("scope1", "collection1")}, 2) |
| 425 | assert.NoError(t, err) |
| 426 | |
| 427 | user2, err := auth.GetUser("testUser") |
| 428 | assert.NoError(t, err) |
| 429 | assert.Equal(t, ch.AtSequence(ch.BaseSetOf(t, "explicit1", "derived1", "derived2", "!"), 1), user2.Channels()) |
| 430 | assert.Equal(t, ch.AtSequence(ch.BaseSetOf(t, "explicit2", "derived3", "derived4", "!"), 1), user2.CollectionChannels("scope1", "collection1")) |
| 431 | } |
| 432 | |
| 433 | func TestRebuildUserChannelsNamedCollection(t *testing.T) { |
| 434 | ctx := base.TestCtx(t) |
nothing calls this directly
no test coverage detected