(t *testing.T)
| 431 | } |
| 432 | |
| 433 | func TestRebuildUserChannelsNamedCollection(t *testing.T) { |
| 434 | ctx := base.TestCtx(t) |
| 435 | bucket := base.GetTestBucket(t) |
| 436 | defer bucket.Close(ctx) |
| 437 | dataStore := bucket.GetSingleDataStore() |
| 438 | computer := mockComputer{} |
| 439 | computer.AddChannelsForCollection("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "derived3", "derived4"), 1)) |
| 440 | |
| 441 | options := DefaultAuthenticatorOptions(ctx) |
| 442 | options.Collections = map[string]map[string]struct{}{ |
| 443 | "scope1": {"collection1": struct{}{}}, |
| 444 | } |
| 445 | auth := NewTestAuthenticator(t, dataStore, &computer, options) |
| 446 | user, err := auth.NewUser("testUser", "password", nil) |
| 447 | require.NoError(t, err) |
| 448 | user.SetCollectionExplicitChannels("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "explicit2"), 1), 0) |
| 449 | require.NoError(t, auth.Save(user)) |
| 450 | |
| 451 | err = auth.InvalidateChannels("testUser", true, base.ScopeAndCollectionNames{base.NewScopeAndCollectionName("scope1", "collection1")}, 2) |
| 452 | assert.NoError(t, err) |
| 453 | |
| 454 | user2, err := auth.GetUser("testUser") |
| 455 | assert.NoError(t, err) |
| 456 | assert.Equal(t, ch.TimedSet(nil), user2.Channels()) |
| 457 | assert.Equal(t, ch.AtSequence(ch.BaseSetOf(t, "explicit2", "derived3", "derived4", "!"), 1), user2.CollectionChannels("scope1", "collection1")) |
| 458 | } |
| 459 | |
| 460 | // Test cases |
| 461 | // multiple collections |
nothing calls this directly
no test coverage detected