(t *testing.T)
| 33 | } |
| 34 | |
| 35 | func TestAuthIdentity(t *testing.T) { |
| 36 | authConfig := testAuthConfig() |
| 37 | core, conn := newCoreWithConfig(t, service.Config{ |
| 38 | Auth: authConfig, |
| 39 | }) |
| 40 | _, err := conn.Query(t.Context(), srcfiles.Plain("from [pools]")) |
| 41 | require.Error(t, err) |
| 42 | require.Equal(t, 1.0, promCounterValue(core.Registry(), "request_errors_unauthorized_total")) |
| 43 | |
| 44 | var poolErr *client.ErrorResponse |
| 45 | require.True(t, errors.As(err, &poolErr)) |
| 46 | require.Equal(t, http.StatusUnauthorized, poolErr.StatusCode) |
| 47 | |
| 48 | var identErr *client.ErrorResponse |
| 49 | _, err = conn.AuthIdentity(t.Context()) |
| 50 | require.Error(t, err) |
| 51 | require.True(t, errors.As(err, &identErr)) |
| 52 | require.Equal(t, http.StatusUnauthorized, identErr.StatusCode) |
| 53 | |
| 54 | token := genToken(t, "test_tenant_id", "test_user_id") |
| 55 | conn.SetAuthToken(token) |
| 56 | res := conn.TestAuthIdentity() |
| 57 | require.Equal(t, api.AuthIdentityResponse{ |
| 58 | TenantID: "test_tenant_id", |
| 59 | UserID: "test_user_id", |
| 60 | }, res) |
| 61 | |
| 62 | _, err = conn.Query(t.Context(), srcfiles.Plain("from :pools")) |
| 63 | require.NoError(t, err) |
| 64 | } |
| 65 | |
| 66 | func TestAuthMethodGet(t *testing.T) { |
| 67 | t.Run("none", func(t *testing.T) { |
nothing calls this directly
no test coverage detected