Adds a user "alice" to the database, with role "hero" and access to channels "wonderland" and "lookingglass".
(t *testing.T, db *db.Database)
| 151 | // Adds a user "alice" to the database, with role "hero" |
| 152 | // and access to channels "wonderland" and "lookingglass". |
| 153 | func addUserAlice(t *testing.T, db *db.Database) auth.User { |
| 154 | authenticator := db.Authenticator(base.TestCtx(t)) |
| 155 | hero, err := authenticator.NewRole("hero", base.SetOf("heroes")) |
| 156 | require.NoError(t, err) |
| 157 | require.NoError(t, authenticator.Save(hero)) |
| 158 | |
| 159 | villain, err := authenticator.NewRole("villain", base.SetOf("villains")) |
| 160 | require.NoError(t, err) |
| 161 | require.NoError(t, authenticator.Save(villain)) |
| 162 | |
| 163 | user, err := authenticator.NewUser("alice", "pass", base.SetOf("wonderland", "lookingglass", "city-London", "user-alice")) |
| 164 | require.NoError(t, err) |
| 165 | user.SetExplicitRoles(channels.TimedSet{"hero": channels.NewVbSimpleSequence(1)}, 1) |
| 166 | require.NoError(t, authenticator.Save(user), "Save") |
| 167 | |
| 168 | // Have to call GetUser to get a user object that's properly configured: |
| 169 | user, err = authenticator.GetUser("alice") |
| 170 | require.NoError(t, err) |
| 171 | return user |
| 172 | } |
| 173 | |
| 174 | // Unit test for JS user functions. |
| 175 | func TestUserFunctions(t *testing.T) { |
no test coverage detected