Skip to content

Commit d73504d

Browse files
fix: apply consistency policy to ReadRelationships and supply permissions in integration tests
- RouteSpiceDBQuery.loadRelations() now sets the configured consistency policy on the ReadRelationshipsRequest; previously no consistency was set, causing the route relationship written in @BeforeAll to be invisible under FULLY_CONSISTENT tests. - SpiceDBIntegrationTest permission check tests now pass the expected permission key in UserSubjectContext so the client-side short-circuit in PermissionSpiceDBQuery passes before hitting SpiceDB. Fixes 3 failing integration tests on the Java 21 CI job.
1 parent 1730809 commit d73504d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/frontegg/sdk/entitlements/internal/RouteSpiceDBQuery.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ private List<RouteRule> loadRelations() {
282282
}
283283

284284
ReadRelationshipsRequest request = ReadRelationshipsRequest.newBuilder()
285+
.setConsistency(consistencySupplier.get())
285286
.setRelationshipFilter(RelationshipFilter.newBuilder()
286287
.setResourceType(TYPE_ROUTE)
287288
.build())

src/test/java/com/frontegg/sdk/entitlements/integration/SpiceDBIntegrationTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import com.frontegg.sdk.entitlements.model.UserSubjectContext;
1717

1818
import java.time.Instant;
19+
import java.util.List;
20+
import java.util.Map;
1921
import org.junit.jupiter.api.AfterAll;
2022
import org.junit.jupiter.api.BeforeAll;
2123
import org.junit.jupiter.api.MethodOrderer;
@@ -138,8 +140,9 @@ void featureCheck_nonExistentFeature_returnsDenied() {
138140
@Test
139141
@Order(10)
140142
void permissionCheck_singlePermission_entitled_returnsAllowed() {
143+
// Supply the user's permission list so the client-side short-circuit passes.
141144
EntitlementsResult result = client.isEntitledTo(
142-
new UserSubjectContext("user-1", "tenant-1"),
145+
new UserSubjectContext("user-1", "tenant-1", List.of("reports:read"), Map.of()),
143146
new PermissionRequestContext("reports:read"));
144147
assertTrue(result.result(), "user-1 should be entitled to 'reports:read'");
145148
}
@@ -148,9 +151,10 @@ void permissionCheck_singlePermission_entitled_returnsAllowed() {
148151
@Order(11)
149152
void permissionCheck_singlePermission_notLinkedToFeature_returnsAllowed() {
150153
// 'admin:write' has no parent feature link in SpiceDB — self-sufficient permission
151-
// → SDK short-circuits to allowed without a CheckBulkPermissions call (JS SDK parity)
154+
// → SDK short-circuits to allowed without a CheckBulkPermissions call (JS SDK parity).
155+
// Still requires the permission to be in the user's list to pass the client-side check.
152156
EntitlementsResult result = client.isEntitledTo(
153-
new UserSubjectContext("user-1", "tenant-1"),
157+
new UserSubjectContext("user-1", "tenant-1", List.of("admin:write"), Map.of()),
154158
new PermissionRequestContext("admin:write"));
155159
assertTrue(result.result(), "permission not linked to any feature should be self-sufficient → allowed");
156160
}

0 commit comments

Comments
 (0)