From ecd10dadf634f7e165e98d5ff65b87568a01cb17 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Tue, 5 Nov 2024 12:28:56 +0000 Subject: [PATCH 1/3] chore: update openfga/api sha ref This updates to the latest version of openfga/api that is included in OpenFGA v1.7.0, with the following interesting changes included. These are mostly changes to the underlying models and will not require any changes to the individual codebases aside from potential test changes. - Adds support for contextual tuples on the assertions API, needs OpenFGAClient updating to support this - Changes min/max page size for read api, should not impact any SDK other than Python - Adds a new response type for 403 responses and changes the existing cancelled response - Changes min/max for contextual_tuples, should not impact any SDK other than Python - Bumps contextual tuples to 100, , should not impact any SDK other than Python --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8aede1a7..1c6fdae9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Main config -OPENFGA_DOCKER_TAG = v1.5.3 -OPEN_API_REF ?= 7e5be7b65c273bdcbddb7b88e98a9b7495effa05 +OPENFGA_DOCKER_TAG = v1.7.0 +OPEN_API_REF ?= 30477608a587fbebea8940129703c11238530f71 OPEN_API_URL = https://raw.githubusercontent.com/openfga/api/${OPEN_API_REF}/docs/openapiv2/apidocs.swagger.json OPENAPI_GENERATOR_CLI_DOCKER_TAG = v6.4.0 NODE_DOCKER_TAG = 20-alpine From 06f724b58d0a8fbc0abdf98011a2292ecd709140 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Wed, 6 Nov 2024 11:46:45 +0000 Subject: [PATCH 2/3] test(java-sdk): update expect body with new data --- .../java/template/OpenFgaApiIntegrationTest.java.mustache | 2 +- config/clients/java/template/OpenFgaApiTest.java.mustache | 2 +- .../template/client-OpenFgaClientIntegrationTest.java.mustache | 2 +- .../java/template/client-OpenFgaClientTest.java.mustache | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache b/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache index 30c8b1ea..70a74bc8 100644 --- a/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache +++ b/config/clients/java/template/OpenFgaApiIntegrationTest.java.mustache @@ -305,7 +305,7 @@ public class OpenFgaApiIntegrationTest { // Then String responseJson = mapper.writeValueAsString(response.getAssertions()); assertEquals( - "[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true}]", + "[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true,\"contextual_tuples\":[],\"context\":null}]", responseJson); } diff --git a/config/clients/java/template/OpenFgaApiTest.java.mustache b/config/clients/java/template/OpenFgaApiTest.java.mustache index 7ae22e58..55c31a47 100644 --- a/config/clients/java/template/OpenFgaApiTest.java.mustache +++ b/config/clients/java/template/OpenFgaApiTest.java.mustache @@ -1782,7 +1782,7 @@ public class OpenFgaApiTest { String putUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; String expectedBody = String.format( - "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}", + "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true,\"contextual_tuples\":[],\"context\":null}]}", DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); mockHttpClient.onPut(putUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); WriteAssertionsRequest request = new WriteAssertionsRequest() diff --git a/config/clients/java/template/client-OpenFgaClientIntegrationTest.java.mustache b/config/clients/java/template/client-OpenFgaClientIntegrationTest.java.mustache index a72b4e51..7f2eb3d4 100644 --- a/config/clients/java/template/client-OpenFgaClientIntegrationTest.java.mustache +++ b/config/clients/java/template/client-OpenFgaClientIntegrationTest.java.mustache @@ -320,7 +320,7 @@ public class OpenFgaClientIntegrationTest { // Then String responseJson = mapper.writeValueAsString(response.getAssertions()); assertEquals( - "[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true}]", + "[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true,\"contextual_tuples\":[],\"context\":null}]", responseJson); } diff --git a/config/clients/java/template/client-OpenFgaClientTest.java.mustache b/config/clients/java/template/client-OpenFgaClientTest.java.mustache index 4b92894b..ab5f61aa 100644 --- a/config/clients/java/template/client-OpenFgaClientTest.java.mustache +++ b/config/clients/java/template/client-OpenFgaClientTest.java.mustache @@ -2516,7 +2516,7 @@ public class OpenFgaClientTest { String putUrl = String.format( "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); String expectedBody = String.format( - "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}", + "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true,\"contextual_tuples\":[],\"context\":null}]}", DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); mockHttpClient.onPut(putUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); List assertions = List.of(new ClientAssertion() From f5fd92e2ae1a0ffc7eadb0c374768d8f68784d7e Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Wed, 6 Nov 2024 11:47:06 +0000 Subject: [PATCH 3/3] test(python-sdk): update test to pass validation --- config/clients/python/template/test/api_test.py.mustache | 2 -- config/clients/python/template/test/sync/api_test.py.mustache | 2 -- 2 files changed, 4 deletions(-) diff --git a/config/clients/python/template/test/api_test.py.mustache b/config/clients/python/template/test/api_test.py.mustache index 5b956649..3fcd3023 100644 --- a/config/clients/python/template/test/api_test.py.mustache +++ b/config/clients/python/template/test/api_test.py.mustache @@ -423,7 +423,6 @@ class {{#operations}}Test{{classname}}(IsolatedAsyncioTestCase): relation="can_read", user_filters=[ {"type": "user"}, - {"type": "team", "relation": "member"}, ], context={}, contextual_tuples=[ @@ -478,7 +477,6 @@ class {{#operations}}Test{{classname}}(IsolatedAsyncioTestCase): "relation": "can_read", "user_filters": [ {"type": "user"}, - {"type": "team", "relation": "member"}, ], "context": {}, "contextual_tuples": [ diff --git a/config/clients/python/template/test/sync/api_test.py.mustache b/config/clients/python/template/test/sync/api_test.py.mustache index 89202e3e..5f1616bd 100644 --- a/config/clients/python/template/test/sync/api_test.py.mustache +++ b/config/clients/python/template/test/sync/api_test.py.mustache @@ -430,7 +430,6 @@ class TestOpenFgaApiSync(IsolatedAsyncioTestCase): request.relation = "can_read" request.user_filters = [ {"type": "user"}, - {"type": "team", "relation": "member"}, ] request.context = {} request.contextual_tuples = [ @@ -484,7 +483,6 @@ class TestOpenFgaApiSync(IsolatedAsyncioTestCase): "relation": "can_read", "user_filters": [ {"type": "user"}, - {"type": "team", "relation": "member"}, ], "context": {}, "contextual_tuples": [