Unit test for user N1QL queries.
(t *testing.T)
| 94 | |
| 95 | // Unit test for user N1QL queries. |
| 96 | func TestUserN1QLQueries(t *testing.T) { |
| 97 | if base.UnitTestUrlIsWalrus() { |
| 98 | t.Skip("This test is Couchbase Server only (requires N1QL)") |
| 99 | } |
| 100 | |
| 101 | if base.TestsUseNamedCollections() { |
| 102 | t.Skip("Requires collection-aware function security (CBG-2597)") |
| 103 | } |
| 104 | |
| 105 | // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) |
| 106 | db, ctx := setupTestDBWithFunctions(t, &kUserN1QLFunctionsConfig) |
| 107 | defer db.Close(ctx) |
| 108 | |
| 109 | // First run the tests as an admin: |
| 110 | t.Run("AsAdmin", func(t *testing.T) { testUserQueriesAsAdmin(t, ctx, db) }) |
| 111 | |
| 112 | // Now create a user and make it current: |
| 113 | db.SetUser(addUserAlice(t, db)) |
| 114 | assert.True(t, db.User().RoleNames().Contains("hero")) |
| 115 | |
| 116 | // Repeat the tests as user "alice": |
| 117 | t.Run("AsUser", func(t *testing.T) { testUserQueriesAsUser(t, ctx, db) }) |
| 118 | } |
| 119 | |
| 120 | func testUserQueriesCommon(t *testing.T, ctx context.Context, db *db.Database) { |
| 121 | // dynamic channel list |
nothing calls this directly
no test coverage detected