Skip to content

Add caveat support and E2E test infrastructure - #13

Merged
raz-shlomo-frontegg merged 28 commits into
masterfrom
e2e-tests
Mar 15, 2026
Merged

Add caveat support and E2E test infrastructure#13
raz-shlomo-frontegg merged 28 commits into
masterfrom
e2e-tests

Conversation

@raz-shlomo-frontegg

Copy link
Copy Markdown
Contributor

Summary

  • Caveat/time-based access: Accept PERMISSIONSHIP_CONDITIONAL_PERMISSION across all query types (Feature, FGA, Permission, Route). Add optional at (Instant) parameter to EntityRequestContext, LookupResourcesRequest, and LookupSubjectsRequest for time-gated entitlement checks via SpiceDB caveats.
  • E2E test infrastructure: Docker Compose stack (CockroachDB + SpiceDB), Maven e2e profile with failsafe plugin, CI job, and convenience run-e2e.sh script.
  • Comprehensive test coverage: Unit tests for CaveatContextBuilder, conditional permission handling in all query classes, caveat context propagation in FGA/Lookup queries, integration tests with time-gated scenarios, and full E2E suite validating parity with the Node.js SDK.
  • Dependency bumps: mockito 5.22.0, slf4j 2.0.17, caffeine 3.2.3, grpc-google-common-protos 2.66.0, maven plugins, actions/checkout v6.

Test plan

  • CI unit + integration tests pass on Java 17 and 21
  • CI e2e job starts SpiceDB via Docker Compose and runs caveat-based tests
  • Verify backward compatibility — existing callers without at parameter are unaffected

🤖 Generated with Claude Code

raz-shlomo-frontegg and others added 13 commits March 15, 2026 14:33
- Add `e2e/docker-compose.yml` for SpiceDB + CockroachDB test infrastructure
- Add `e2e/run-e2e.sh` convenience script for local E2E test execution
- Add `e2e/schema-relationships.yaml` with caveat-based schema and test data
- Add `SpiceDBE2ETest` validating time-gated access, inheritance, and lookups
- Update `FgaSpiceDBQuery` to include caveat context when `at` timestamp is provided
- Treat `PERMISSIONSHIP_CONDITIONAL_PERMISSION` as allowed in check results
- Add `CaveatContextBuilder` tests for ISO-8601 timestamp serialization
- Extend `SpiceDBSchemaWriter` with `writeCaveatRelationships()` for test fixtures
- Add `at` parameter to `LookupResourcesRequest` and `LookupSubjectsRequest`
- Add E2E job to GitHub Actions CI with SpiceDB readiness checks
Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](apache/maven-source-plugin@maven-source-plugin-3.3.1...maven-source-plugin-3.4.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-source-plugin
  dependency-version: 3.4.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `mockito.version` from 5.14.2 to 5.22.0.

Updates `org.mockito:mockito-core` from 5.14.2 to 5.22.0
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.14.2...v5.22.0)

Updates `org.mockito:mockito-junit-jupiter` from 5.14.2 to 5.22.0
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v5.14.2...v5.22.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-version: 5.22.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
- dependency-name: org.mockito:mockito-junit-jupiter
  dependency-version: 5.22.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.api.grpc:grpc-google-common-protos](https://github.com/googleapis/sdk-platform-java) from 2.37.1 to 2.66.0.
- [Release notes](https://github.com/googleapis/sdk-platform-java/releases)
- [Changelog](https://github.com/googleapis/sdk-platform-java/blob/main/CHANGELOG.md)
- [Commits](googleapis/sdk-platform-java@api-common/v2.37.1...v2.66.0)

---
updated-dependencies:
- dependency-name: com.google.api.grpc:grpc-google-common-protos
  dependency-version: 2.66.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.13.0 to 3.15.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.13.0...maven-compiler-plugin-3.15.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-version: 3.15.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `slf4j.version` from 2.0.16 to 2.0.17.

Updates `org.slf4j:slf4j-api` from 2.0.16 to 2.0.17

Updates `org.slf4j:slf4j-simple` from 2.0.16 to 2.0.17

---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-api
  dependency-version: 2.0.17
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.slf4j:slf4j-simple
  dependency-version: 2.0.17
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.github.ben-manes.caffeine:caffeine](https://github.com/ben-manes/caffeine) from 3.1.8 to 3.2.3.
- [Release notes](https://github.com/ben-manes/caffeine/releases)
- [Commits](ben-manes/caffeine@v3.1.8...v3.2.3)

---
updated-dependencies:
- dependency-name: com.github.ben-manes.caffeine:caffeine
  dependency-version: 3.2.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.7 to 3.2.8.
- [Release notes](https://github.com/apache/maven-gpg-plugin/releases)
- [Commits](apache/maven-gpg-plugin@maven-gpg-plugin-3.2.7...maven-gpg-plugin-3.2.8)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-gpg-plugin
  dependency-version: 3.2.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.7.0 to 3.12.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.7.0...maven-javadoc-plugin-3.12.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-version: 3.12.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.5.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](apache/maven-surefire@surefire-3.2.5...surefire-3.5.5)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-version: 3.5.5
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `spring-boot.version` from 3.2.0 to 4.0.3.

Updates `org.springframework.boot:spring-boot-autoconfigure` from 3.2.0 to 4.0.3
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.2.0...v4.0.3)

Updates `org.springframework.boot:spring-boot-configuration-processor` from 3.2.0 to 4.0.3
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.2.0...v4.0.3)

Updates `org.springframework.boot:spring-boot-starter-test` from 3.2.0 to 4.0.3
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.2.0...v4.0.3)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-autoconfigure
  dependency-version: 4.0.3
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: org.springframework.boot:spring-boot-configuration-processor
  dependency-version: 4.0.3
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: org.springframework.boot:spring-boot-starter-test
  dependency-version: 4.0.3
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…lthcheck reliability

- Treat `PERMISSIONSHIP_CONDITIONAL_PERMISSION` as allowed in all query types
- Add conditional permission tests for FGA, Permission, Route, and Feature queries
- Upgrade actions/checkout from v5 to v6 in CI
- Replace `pgrep` with `grpc_health_probe` for more reliable SpiceDB readiness checks
- Update SpiceDB healthcheck configuration with longer start period and more retries
- Remove deprecated `version` field from docker-compose.yml
- Upgrade maven-failsafe-plugin from 3.2.5 to 3.5.5
@raz-shlomo-frontegg
raz-shlomo-frontegg enabled auto-merge (squash) March 15, 2026 13:09
raz-shlomo-frontegg and others added 13 commits March 15, 2026 15:20
SpiceDB exits with code 78 (failed to create datastore) when CockroachDB
isn't fully ready for connection pooling despite passing healthcheck.
Adding restart: on-failure lets it retry. Also removes cpus/mem_limit
constraints that can cause issues on GitHub Actions runners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rtup

docker compose --wait fails when SpiceDB restarts after an initial
connection failure to CockroachDB. Instead, start detached and let
the grpc_health_probe readiness loop (up to 120s) handle waiting.
Also dumps SpiceDB logs on timeout for easier debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CockroachDB v26.1 restricts access to crdb_internal tables by default.
SpiceDB v1.42.1 queries crdb_internal.active_version() on startup,
causing persistent "Access to crdb_internal and system is restricted"
errors. Pin to v24.2.6 which does not have this restriction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SpiceDB with CockroachDB uses quantized revisions by default, which
can cause queries immediately after schema writes to use a revision
that predates the schema. Setting quantization to 0s ensures queries
always see the latest schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CockroachDB-backed SpiceDB has revision quantization issues causing
stale schema reads in CI. The E2E tests don't need persistent storage
- they seed data in @BeforeAll. Using the memory engine eliminates
CockroachDB complexity, speeds up startup, and avoids consistency issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove temporary debug traces from FgaSpiceDBQuery and SpiceDBE2ETest
that were used to diagnose CI failures. Remove redirectTestOutputToFile
from failsafe config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add schema read-back verification and relationship dumping to
@BeforeAll setup to diagnose why E2E tests fail in CI but pass locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Log the raw permissionship from CheckPermission responses and
LookupResources results to understand why SpiceDB returns denied
when relationships exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compare direct gRPC CheckPermission (with fully_consistent) against
SDK's CheckPermission to identify if the issue is consistency,
authentication, or something else.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root cause: SpiceDB's default `minimize_latency` consistency can return
stale results on the memory datastore when relationships are written
and immediately queried. This caused all caveat-based E2E tests to fail
in CI (CheckPermission returned NO_PERMISSION despite relationships
existing).

Set `Consistency.fully_consistent=true` on all CheckPermission,
CheckBulkPermissions, LookupResources, and LookupSubjects requests.
Also remove debug diagnostic logging from E2E tests and schema writer.
Introduce `ConsistencyPolicy` enum (MINIMIZE_LATENCY, FULLY_CONSISTENT)
and wire it through ClientConfiguration. Use MINIMIZE_LATENCY by default
for best performance; E2E tests override to FULLY_CONSISTENT.

Treat CONDITIONAL_PERMISSION as denied (fail-closed) in FGA and bulk
checks, with warning logs when encountered.
…SION

SpiceDB returns CONDITIONAL_PERMISSION when caveat parameters are missing
from the context. The activeUntil param was omitted when null, preventing
SpiceDB from evaluating the `activeUntil == null` check in the caveat
expression. Now explicitly sets null values so the caveat fully resolves.
@raz-shlomo-frontegg
raz-shlomo-frontegg merged commit 6b88986 into master Mar 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant