diff --git a/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java b/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java index 7ab7cab..dd8427d 100644 --- a/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java +++ b/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java @@ -66,7 +66,7 @@ public void beforeEachTest() throws Exception { when(mockHttpClientBuilder.build()).thenReturn(mockHttpClient); mockConfiguration = mock(Configuration.class); - when(mockConfiguration.getApiUrl()).thenReturn("https://localhost"); + when(mockConfiguration.getApiUrl()).thenReturn("https://api.fga.example"); when(mockConfiguration.getReadTimeout()).thenReturn(Duration.ofMillis(250)); when(mockConfiguration.getCredentials()).thenReturn(new Credentials()); when(mockConfiguration.getMaxRetries()).thenReturn(DEFAULT_MAX_RETRIES); @@ -88,7 +88,7 @@ public void listStoresTest() throws Exception { // Given String responseBody = String.format("{\"stores\":[{\"id\":\"%s\",\"name\":\"%s\"}]}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); - mockHttpClient.onGet("https://localhost/stores").doReturn(200, responseBody); + mockHttpClient.onGet("https://api.fga.example/stores").doReturn(200, responseBody); Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional @@ -96,7 +96,7 @@ public void listStoresTest() throws Exception { var response = fga.listStores(pageSize, continuationToken).get(); // Then - mockHttpClient.verify().get("https://localhost/stores").called(1); + mockHttpClient.verify().get("https://api.fga.example/stores").called(1); assertNotNull(response.getData()); assertNotNull(response.getData().getStores()); var stores = response.getData().getStores(); @@ -109,7 +109,7 @@ public void listStoresTest() throws Exception { public void listStores_400() { // Given mockHttpClient - .onGet("https://localhost/stores") + .onGet("https://api.fga.example/stores") .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional @@ -120,7 +120,7 @@ public void listStores_400() { .get()); // Then - mockHttpClient.verify().get("https://localhost/stores").called(1); + mockHttpClient.verify().get("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiValidationError.class, execException.getCause()); assertEquals(400, exception.getStatusCode()); assertEquals( @@ -132,7 +132,7 @@ public void listStores_400() { public void listStores_404() throws Exception { // Given mockHttpClient - .onGet("https://localhost/stores") + .onGet("https://api.fga.example/stores") .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional @@ -143,7 +143,7 @@ public void listStores_404() throws Exception { .get()); // Then - mockHttpClient.verify().get("https://localhost/stores").called(1); + mockHttpClient.verify().get("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiNotFoundError.class, execException.getCause()); assertEquals(404, exception.getStatusCode()); assertEquals( @@ -154,7 +154,7 @@ public void listStores_404() throws Exception { public void listStores_500() throws Exception { // Given mockHttpClient - .onGet("https://localhost/stores") + .onGet("https://api.fga.example/stores") .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); Integer pageSize = null; // Input is optional String continuationToken = null; // Input is optional @@ -165,7 +165,7 @@ public void listStores_500() throws Exception { .get()); // Then - mockHttpClient.verify().get("https://localhost/stores").called(1 + DEFAULT_MAX_RETRIES); + mockHttpClient.verify().get("https://api.fga.example/stores").called(1 + DEFAULT_MAX_RETRIES); var exception = assertInstanceOf(FgaApiInternalError.class, execException.getCause()); assertEquals(500, exception.getStatusCode()); assertEquals( @@ -181,7 +181,7 @@ public void createStoreTest() throws Exception { String expectedBody = String.format("{\"name\":\"%s\"}", DEFAULT_STORE_NAME); String requestBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .withBody(is(expectedBody)) .doReturn(201, requestBody); CreateStoreRequest request = new CreateStoreRequest().name(DEFAULT_STORE_NAME); @@ -192,7 +192,7 @@ public void createStoreTest() throws Exception { // Then mockHttpClient .verify() - .post("https://localhost/stores") + .post("https://api.fga.example/stores") .withBody(is(expectedBody)) .called(1); assertNotNull(response.getData()); @@ -214,7 +214,7 @@ public void createStore_bodyRequired() { public void createStore_400() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); // When @@ -223,7 +223,7 @@ public void createStore_400() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiValidationError.class, execException.getCause()); assertEquals(400, exception.getStatusCode()); assertEquals( @@ -235,7 +235,7 @@ public void createStore_400() throws Exception { public void createStore_404() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); // When @@ -244,7 +244,7 @@ public void createStore_404() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiNotFoundError.class, execException.getCause()); assertEquals(404, exception.getStatusCode()); assertEquals( @@ -255,7 +255,7 @@ public void createStore_404() throws Exception { public void createStore_500() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); // When @@ -264,7 +264,7 @@ public void createStore_500() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1 + DEFAULT_MAX_RETRIES); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1 + DEFAULT_MAX_RETRIES); var exception = assertInstanceOf(FgaApiInternalError.class, execException.getCause()); assertEquals(500, exception.getStatusCode()); assertEquals( @@ -277,7 +277,7 @@ public void createStore_500() throws Exception { @Test public void getStoreTest() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; String responseBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); mockHttpClient.onGet(getUrl).doReturn(200, responseBody); @@ -304,7 +304,7 @@ public void getStore_storeIdRequired() { @Test public void getStore_400() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -325,7 +325,7 @@ public void getStore_400() throws Exception { @Test public void getStore_404() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -345,7 +345,7 @@ public void getStore_404() throws Exception { @Test public void getStore_500() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -368,7 +368,7 @@ public void getStore_500() throws Exception { @Test public void deleteStoreTest() throws Exception { // Given - String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String deleteUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient.onDelete(deleteUrl).doReturn(204, EMPTY_RESPONSE_BODY); // When @@ -391,7 +391,7 @@ public void deleteStore_storeIdRequired() { @Test public void deleteStore_400() throws Exception { // Given - String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String deleteUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onDelete(deleteUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -413,7 +413,7 @@ public void deleteStore_400() throws Exception { @Test public void deleteStore_404() throws Exception { // Given - String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String deleteUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onDelete(deleteUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -434,7 +434,7 @@ public void deleteStore_404() throws Exception { @Test public void deleteStore_500() throws Exception { // Given - String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String deleteUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; mockHttpClient .onDelete(deleteUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -458,7 +458,7 @@ public void deleteStore_500() throws Exception { @Test public void readAuthorizationModelsTest() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; String responseBody = String.format( "{\"authorization_models\":[{\"id\":\"%s\",\"schema_version\":\"%s\"}]}", DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); @@ -495,7 +495,7 @@ public void readAuthorizationModels_storeIdRequired() { @Test public void readAuthorizationModels_400() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -519,7 +519,7 @@ public void readAuthorizationModels_400() throws Exception { @Test public void readAuthorizationModels_404() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -542,7 +542,7 @@ public void readAuthorizationModels_404() throws Exception { @Test public void readAuthorizationModels_500() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -568,7 +568,7 @@ public void readAuthorizationModels_500() throws Exception { @Test public void writeAuthorizationModelTest() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; String expectedBody = "{\"type_definitions\":[{\"type\":\"document\",\"relations\":{},\"metadata\":null}],\"schema_version\":\"1.1\",\"conditions\":{}}"; String responseBody = String.format("{\"authorization_model_id\":\"%s\"}", DEFAULT_AUTH_MODEL_ID); @@ -613,7 +613,7 @@ public void writeAuthorizationModel_bodyRequired() { @Test public void writeAuthorizationModel_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -635,7 +635,7 @@ DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) @Test public void writeAuthorizationModel_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -656,7 +656,7 @@ DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) @Test public void writeAuthorizationModel_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -681,7 +681,7 @@ DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) public void readAuthorizationModelTest() throws Exception { // Given String getUrl = - "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; String getResponse = String.format( "{\"authorization_model\":{\"id\":\"%s\",\"schema_version\":\"%s\"}}", DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); @@ -727,7 +727,7 @@ public void readAuthorizationModel_idRequired() { public void readAuthorizationModel_400() throws Exception { // Given String getUrl = - "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -750,7 +750,7 @@ public void readAuthorizationModel_400() throws Exception { public void readAuthorizationModel_404() throws Exception { // Given String getUrl = - "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -772,7 +772,7 @@ public void readAuthorizationModel_404() throws Exception { public void readAuthorizationModel_500() throws Exception { // Given String getUrl = - "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -796,7 +796,7 @@ public void readAuthorizationModel_500() throws Exception { @Test public void readChangesTest() throws Exception { // Given - String getPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + String getPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; String responseBody = String.format( "{\"changes\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}}]}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -834,7 +834,7 @@ public void readChanges_storeIdRequired() throws Exception { @Test public void readChanges_400() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -859,7 +859,7 @@ public void readChanges_400() throws Exception { @Test public void readChanges_404() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -883,7 +883,7 @@ public void readChanges_404() throws Exception { @Test public void readChanges_500() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + String getUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -910,7 +910,7 @@ public void readChanges_500() throws Exception { @Test public void readTest() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"page_size\":null,\"continuation_token\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -942,7 +942,7 @@ public void readTest() throws Exception { @Test public void read_complexContext() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"page_size\":null,\"continuation_token\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1015,7 +1015,7 @@ public void read_bodyRequired() { @Test public void read_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1037,7 +1037,7 @@ public void read_400() throws Exception { @Test public void read_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1058,7 +1058,7 @@ public void read_404() throws Exception { @Test public void read_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1082,7 +1082,7 @@ public void read_500() throws Exception { @Test public void writeTest_writes() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":null}]},\"deletes\":null,\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1108,7 +1108,7 @@ public void writeTest_writes() throws Exception { @Test public void writeTest_deletes() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":null,\"deletes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}]},\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1131,7 +1131,7 @@ public void writeTest_deletes() throws Exception { @Test public void writeWithContext_map() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"conditionName\",\"context\":{\"num\":1,\"str\":\"banana\",\"list\":[],\"obj\":{}}}}]},\"deletes\":null,\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1163,7 +1163,7 @@ public void writeWithContext_map() throws Exception { public void writeWithContext_modeledObj() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"conditionName\",\"context\":{\"num\":1,\"str\":\"apple\",\"list\":[2,\"banana\",[],{\"num\":3,\"str\":\"cupcake\",\"list\":null,\"obj\":null}],\"obj\":{\"num\":4,\"str\":\"dolphin\",\"list\":null,\"obj\":null}}}}]},\"deletes\":null,\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1244,7 +1244,7 @@ public void write_bodyRequired() { @Test public void write_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1266,7 +1266,7 @@ public void write_400() throws Exception { @Test public void write_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1287,7 +1287,7 @@ public void write_404() throws Exception { @Test public void write_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1311,7 +1311,7 @@ public void write_500() throws Exception { @Test public void check() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":{\"tuple_keys\":[]},\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1358,7 +1358,7 @@ public void check_bodyRequired() { @Test public void check_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1380,7 +1380,7 @@ public void check_400() throws Exception { @Test public void check_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1401,7 +1401,7 @@ public void check_404() throws Exception { @Test public void check_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1425,7 +1425,7 @@ public void check_500() throws Exception { @Test public void expandTest() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; String expectedBody = String.format( "{\"tuple_key\":{\"relation\":\"%s\",\"object\":\"%s\"},\"authorization_model_id\":\"%s\"}", DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1483,7 +1483,7 @@ public void expand_bodyRequired() { @Test public void expand_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1505,7 +1505,7 @@ public void expand_400() throws Exception { @Test public void expand_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1526,7 +1526,7 @@ public void expand_404() throws Exception { @Test public void expand_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1550,7 +1550,7 @@ public void expand_500() throws Exception { @Test public void listObjectsTest() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; String expectedBody = String.format( "{\"authorization_model_id\":\"%s\",\"type\":null,\"relation\":\"%s\",\"user\":\"%s\",\"contextual_tuples\":null,\"context\":null}", DEFAULT_AUTH_MODEL_ID, DEFAULT_RELATION, DEFAULT_USER); @@ -1596,7 +1596,7 @@ public void listObjects_bodyRequired() { @Test public void listObjects_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1618,7 +1618,7 @@ public void listObjects_400() throws Exception { @Test public void listObjects_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1639,7 +1639,7 @@ public void listObjects_404() throws Exception { @Test public void listObjects_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1663,7 +1663,8 @@ public void listObjects_500() throws Exception { @Test public void readAssertionsTest() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String getUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; String responseBody = String.format( "{\"assertions\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"expectation\":true}]}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1714,7 +1715,8 @@ public void readAssertions_authModelIdRequired() { @Test public void readAssertions_400() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String getUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1736,7 +1738,8 @@ public void readAssertions_400() throws Exception { @Test public void readAssertions_404() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String getUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1757,7 +1760,8 @@ public void readAssertions_404() throws Exception { @Test public void readAssertions_500() throws Exception { // Given - String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String getUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1781,7 +1785,8 @@ public void readAssertions_500() throws Exception { @Test public void writeAssertionsTest() throws Exception { // Given - String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + 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}]}", DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); @@ -1839,7 +1844,8 @@ public void writeAssertions_bodyRequired() { @Test public void writeAssertions_400() throws Exception { // Given - String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String putUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onPut(putUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1861,7 +1867,8 @@ DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) @Test public void writeAssertions_404() throws Exception { // Given - String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String putUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onPut(putUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1882,7 +1889,8 @@ DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) @Test public void writeAssertions_500() throws Exception { // Given - String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String putUrl = + "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; mockHttpClient .onPut(putUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); diff --git a/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java b/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java index ca966df..92e9c72 100644 --- a/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java +++ b/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java @@ -79,7 +79,7 @@ public void beforeEachTest() throws Exception { clientConfiguration = new ClientConfiguration() .storeId(DEFAULT_STORE_ID) .authorizationModelId(DEFAULT_AUTH_MODEL_ID) - .apiUrl("https://localhost") + .apiUrl("https://api.fga.example") .credentials(new Credentials()) .readTimeout(Duration.ofMillis(250)) .maxRetries(DEFAULT_MAX_RETRIES) @@ -105,7 +105,7 @@ public void createStore_withApiToken() throws Exception { String expectedBody = String.format("{\"name\":\"%s\"}", DEFAULT_STORE_NAME); String requestBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .doReturn(201, requestBody); @@ -117,7 +117,7 @@ public void createStore_withApiToken() throws Exception { // Then mockHttpClient .verify() - .post("https://localhost/stores") + .post("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .called(1); @@ -151,7 +151,7 @@ public void createStore_withClientCredentials() throws Exception { containsString(String.format("grant_type=%s", "client_credentials")))) .doReturn(200, String.format("{\"access_token\":\"%s\",\"expires_in\":\"%s\"}", apiToken, 3600)); mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .doReturn(201, requestBody); @@ -171,7 +171,7 @@ public void createStore_withClientCredentials() throws Exception { // OpenFGA server should be called 2 times. mockHttpClient .verify() - .post("https://localhost/stores") + .post("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .called(2); @@ -207,7 +207,7 @@ public void createStore_withClientCredentialsWithRefresh() throws Exception { containsString(String.format("grant_type=%s", "client_credentials")))) .doReturn(200, String.format("{\"access_token\":\"%s\",\"expires_in\":\"%s\"}", apiToken, 1)); mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .doReturn(201, requestBody); @@ -227,7 +227,7 @@ public void createStore_withClientCredentialsWithRefresh() throws Exception { // OpenFGA server should be called 2 times. mockHttpClient .verify() - .post("https://localhost/stores") + .post("https://api.fga.example/stores") .withBody(is(expectedBody)) .withHeader("Authorization", String.format("Bearer %s", apiToken)) .called(2); @@ -245,13 +245,13 @@ public void listStoresTest() throws Exception { // Given String responseBody = String.format("{\"stores\":[{\"id\":\"%s\",\"name\":\"%s\"}]}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); - mockHttpClient.onGet("https://localhost/stores").doReturn(200, responseBody); + mockHttpClient.onGet("https://api.fga.example/stores").doReturn(200, responseBody); // When ClientListStoresResponse response = fga.listStores().get(); // Then - mockHttpClient.verify().get("https://localhost/stores").called(1); + mockHttpClient.verify().get("https://api.fga.example/stores").called(1); assertNotNull(response.getStores()); assertEquals(1, response.getStores().size()); assertEquals(DEFAULT_STORE_ID, response.getStores().get(0).getId()); @@ -266,7 +266,7 @@ public void listStoresTest_withOptions() throws Exception { int pageSize = 10; String continuationToken = "continuationToken"; String getUrl = String.format( - "https://localhost/stores?page_size=%d&continuation_token=%s", pageSize, continuationToken); + "https://api.fga.example/stores?page_size=%d&continuation_token=%s", pageSize, continuationToken); mockHttpClient.onGet(getUrl).doReturn(200, responseBody); ClientListStoresOptions options = new ClientListStoresOptions().pageSize(pageSize).continuationToken(continuationToken); @@ -291,7 +291,7 @@ public void createStoreTest() throws Exception { String expectedBody = String.format("{\"name\":\"%s\"}", DEFAULT_STORE_NAME); String requestBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .withBody(is(expectedBody)) .doReturn(201, requestBody); CreateStoreRequest request = new CreateStoreRequest().name(DEFAULT_STORE_NAME); @@ -302,7 +302,7 @@ public void createStoreTest() throws Exception { // Then mockHttpClient .verify() - .post("https://localhost/stores") + .post("https://api.fga.example/stores") .withBody(is(expectedBody)) .called(1); assertEquals(DEFAULT_STORE_ID, response.getId()); @@ -324,7 +324,7 @@ public void createStore_bodyRequired() { public void createStore_400() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); // When @@ -333,7 +333,7 @@ public void createStore_400() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiValidationError.class, execException.getCause()); assertEquals(400, exception.getStatusCode()); assertEquals( @@ -345,7 +345,7 @@ public void createStore_400() throws Exception { public void createStore_404() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); // When @@ -354,7 +354,7 @@ public void createStore_404() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1); var exception = assertInstanceOf(FgaApiNotFoundError.class, execException.getCause()); assertEquals(404, exception.getStatusCode()); assertEquals( @@ -365,7 +365,7 @@ public void createStore_404() throws Exception { public void createStore_500() throws Exception { // Given mockHttpClient - .onPost("https://localhost/stores") + .onPost("https://api.fga.example/stores") .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); // When @@ -374,7 +374,7 @@ public void createStore_500() throws Exception { .get()); // Then - mockHttpClient.verify().post("https://localhost/stores").called(1 + DEFAULT_MAX_RETRIES); + mockHttpClient.verify().post("https://api.fga.example/stores").called(1 + DEFAULT_MAX_RETRIES); var exception = assertInstanceOf(FgaApiInternalError.class, execException.getCause()); assertEquals(500, exception.getStatusCode()); assertEquals( @@ -387,7 +387,7 @@ public void createStore_500() throws Exception { @Test public void getStoreTest() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); String responseBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); mockHttpClient.onGet(getUrl).doReturn(200, responseBody); @@ -417,7 +417,7 @@ public void getStore_storeIdRequired() { @Test public void getStore_400() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -438,7 +438,7 @@ public void getStore_400() throws Exception { @Test public void getStore_404() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -458,7 +458,7 @@ public void getStore_404() throws Exception { @Test public void getStore_500() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -481,7 +481,7 @@ public void getStore_500() throws Exception { @Test public void deleteStoreTest() throws Exception { // Given - String deleteUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String deleteUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient.onDelete(deleteUrl).doReturn(204, EMPTY_RESPONSE_BODY); // When @@ -509,7 +509,7 @@ public void deleteStore_storeIdRequired() { @Test public void deleteStore_400() { // Given - String deleteUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String deleteUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onDelete(deleteUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -530,7 +530,7 @@ public void deleteStore_400() { @Test public void deleteStore_404() { // Given - String deleteUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String deleteUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onDelete(deleteUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -550,7 +550,7 @@ public void deleteStore_404() { @Test public void deleteStore_500() { // Given - String deleteUrl = String.format("https://localhost/stores/%s", DEFAULT_STORE_ID); + String deleteUrl = String.format("https://api.fga.example/stores/%s", DEFAULT_STORE_ID); mockHttpClient .onDelete(deleteUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -573,7 +573,7 @@ public void deleteStore_500() { @Test public void readAuthorizationModelsTest() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); var options = new ClientReadAuthorizationModelsOptions(); String responseBody = String.format( "{\"authorization_models\":[{\"id\":\"%s\",\"schema_version\":\"%s\"}]}", @@ -611,7 +611,7 @@ public void readAuthorizationModels_storeIdRequired() { @Test public void readAuthorizationModels_400() { // Given - String getUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); var options = new ClientReadAuthorizationModelsOptions(); mockHttpClient .onGet(getUrl) @@ -634,7 +634,7 @@ public void readAuthorizationModels_400() { @Test public void readAuthorizationModels_404() { // Given - String getUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); var options = new ClientReadAuthorizationModelsOptions(); mockHttpClient .onGet(getUrl) @@ -656,7 +656,7 @@ public void readAuthorizationModels_404() { @Test public void readAuthorizationModels_500() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String getUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); var options = new ClientReadAuthorizationModelsOptions(); mockHttpClient .onGet(getUrl) @@ -678,7 +678,8 @@ public void readAuthorizationModels_500() throws Exception { @Test public void readLatestAuthorizationModelTest() throws Exception { // Given - String getUrl = String.format("https://localhost/stores/%s/authorization-models?page_size=1", DEFAULT_STORE_ID); + String getUrl = + String.format("https://api.fga.example/stores/%s/authorization-models?page_size=1", DEFAULT_STORE_ID); String responseBody = String.format( "{\"authorization_models\":[{\"id\":\"%s\",\"schema_version\":\"%s\"}]}", DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); @@ -707,7 +708,8 @@ public void readChanges() throws Exception { "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ"; ClientReadChangesRequest request = new ClientReadChangesRequest().type(changeType); - String getUrl = String.format("https://localhost/stores/%s/changes?type=%s", DEFAULT_STORE_ID, changeType); + String getUrl = + String.format("https://api.fga.example/stores/%s/changes?type=%s", DEFAULT_STORE_ID, changeType); String responseBody = String.format( "{\"changes\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"operation\":\"TUPLE_OPERATION_WRITE\"}],\"continuation_token\":\"%s\"}", user, relation, object, continuationToken); @@ -736,7 +738,7 @@ public void readChanges() throws Exception { @Test public void writeAuthorizationModelTest() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); String expectedBody = "{\"type_definitions\":[{\"type\":\"document\",\"relations\":{},\"metadata\":null}],\"schema_version\":\"1.1\",\"conditions\":{}}"; String responseBody = String.format("{\"authorization_model_id\":\"%s\"}", DEFAULT_AUTH_MODEL_ID); @@ -785,7 +787,7 @@ public void writeAuthorizationModel_bodyRequired() { @Test public void writeAuthorizationModel_400() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -807,7 +809,7 @@ public void writeAuthorizationModel_400() throws Exception { @Test public void writeAuthorizationModel_404() { // Given - String postUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -828,7 +830,7 @@ public void writeAuthorizationModel_404() { @Test public void writeAuthorizationModel_500() { // Given - String postUrl = String.format("https://localhost/stores/%s/authorization-models", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/authorization-models", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -853,7 +855,7 @@ public void writeAuthorizationModel_500() { public void readAuthorizationModelTest() throws Exception { // Given String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + "https://api.fga.example/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); String getResponse = String.format( "{\"authorization_model\":{\"id\":\"%s\",\"schema_version\":\"%s\"}}", DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); @@ -877,7 +879,7 @@ public void readAuthorizationModelTest_withOptions() throws Exception { ClientReadAuthorizationModelOptions options = new ClientReadAuthorizationModelOptions().authorizationModelId(authorizationModelId); String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, authorizationModelId); + "https://api.fga.example/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, authorizationModelId); String getResponse = String.format( "{\"authorization_model\":{\"id\":\"%s\",\"schema_version\":\"%s\"}}", authorizationModelId, DEFAULT_SCHEMA_VERSION); @@ -927,7 +929,7 @@ public void readAuthorizationModel_idRequired() { public void readAuthorizationModel_400() { // Given String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + "https://api.fga.example/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -949,7 +951,7 @@ public void readAuthorizationModel_400() { public void readAuthorizationModel_404() throws Exception { // Given String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + "https://api.fga.example/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -970,7 +972,7 @@ public void readAuthorizationModel_404() throws Exception { public void readAuthorizationModel_500() throws Exception { // Given String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + "https://api.fga.example/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -993,7 +995,7 @@ public void readAuthorizationModel_500() throws Exception { @Test public void readTest() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/read", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"page_size\":null,\"continuation_token\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1023,7 +1025,7 @@ public void readTest() throws Exception { @Test public void read_emptyRequestSendsNoTupleKey() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/read", DEFAULT_STORE_ID); String expectedBody = "{\"tuple_key\":null,\"page_size\":null,\"continuation_token\":null}"; mockHttpClient.onPost(postUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); ClientReadRequest request = new ClientReadRequest(); @@ -1052,7 +1054,7 @@ public void read_storeIdRequired() { @Test public void read_400() { // Given - String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/read", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1074,7 +1076,7 @@ public void read_400() { @Test public void read_404() { // Given - String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/read", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1095,7 +1097,7 @@ public void read_404() { @Test public void read_500() { // Given - String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/read", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1119,7 +1121,7 @@ public void read_500() { @Test public void writeTest_writes() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":null}]},\"deletes\":null,\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1144,7 +1146,7 @@ public void writeTest_writes() throws Exception { @Test public void writeTest_deletes() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String expectedBody = String.format( "{\"writes\":null,\"deletes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}]},\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1165,7 +1167,7 @@ public void writeTest_deletes() throws Exception { @Test public void writeTest_nonTransaction() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( "{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"condition\",\"context\":{\"some\":\"context\"}}}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1239,7 +1241,7 @@ public void writeTest_nonTransaction() throws Exception { @Test public void writeTest_nonTransactionsWithFailure() { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String firstUser = "user:first"; String failedUser = "user:SECOND"; String skippedUser = "user:third"; @@ -1302,7 +1304,7 @@ public void writeTest_nonTransactionsWithFailure() { @Test public void writeTest_transaction() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( "{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"condition\",\"context\":{\"some\":\"context\"}}}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1342,7 +1344,7 @@ public void writeTest_transaction() throws Exception { @Test public void writeTest_transactionWithFailure() { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; String writeTupleBody = String.format( "{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"condition\",\"context\":{\"some\":\"context\"}}}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1387,7 +1389,7 @@ public void writeTest_transactionWithFailure() { @Test public void writeTuplesTest() throws Exception { // Given - String postPath = String.format("https://localhost/stores/%s/write", DEFAULT_STORE_ID); + String postPath = String.format("https://api.fga.example/stores/%s/write", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"writes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":{\"name\":\"condition\",\"context\":{\"some\":\"context\"}}}]}," + "\"deletes\":null,\"authorization_model_id\":\"%s\"}", @@ -1410,7 +1412,7 @@ public void writeTuplesTest() throws Exception { @Test public void deleteTuplesTest() throws Exception { // Given - String postPath = String.format("https://localhost/stores/%s/write", DEFAULT_STORE_ID); + String postPath = String.format("https://api.fga.example/stores/%s/write", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"writes\":null,\"deletes\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}]},\"authorization_model_id\":\"%s\"}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1432,7 +1434,7 @@ public void deleteTuplesTest() throws Exception { public void write_nothingSentWhenWritesAndDeletesAreEmpty() throws FgaInvalidParameterException, ExecutionException, InterruptedException { // Given - String postPath = String.format("https://localhost/stores/%s/write", DEFAULT_STORE_ID); + String postPath = String.format("https://api.fga.example/stores/%s/write", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"writes\":null,\"deletes\":null,\"authorization_model_id\":\"%s\"}", DEFAULT_AUTH_MODEL_ID); mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); @@ -1464,7 +1466,7 @@ public void write_storeIdRequired() { @Test public void write_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1491,7 +1493,7 @@ public void write_400() throws Exception { @Test public void write_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1517,7 +1519,7 @@ public void write_404() throws Exception { @Test public void write_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1546,7 +1548,7 @@ public void write_500() throws Exception { @Test public void check() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}," + "\"contextual_tuples\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"owner\",\"object\":\"%s\",\"condition\":{\"name\":\"condition\",\"context\":{\"some\":\"context\"}}}]}," @@ -1589,7 +1591,7 @@ public void check_storeIdRequired() { @Test public void check_400() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1611,7 +1613,7 @@ public void check_400() throws Exception { @Test public void check_404() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1632,7 +1634,7 @@ public void check_404() throws Exception { @Test public void check_500() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1656,7 +1658,7 @@ public void check_500() throws Exception { @Test public void batchCheck() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1690,7 +1692,7 @@ public void batchCheck() throws Exception { @Test public void batchCheck_twentyTimes() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -1739,7 +1741,7 @@ public void batchCheck_storeIdRequired() { @Test public void batchCheck_400() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1765,7 +1767,7 @@ public void batchCheck_400() throws Exception { @Test public void batchCheck_404() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1790,7 +1792,7 @@ public void batchCheck_404() throws Exception { @Test public void batchCheck_500() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1819,7 +1821,7 @@ public void batchCheck_500() throws Exception { @Test public void expandTest() throws Exception { // Given - String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postPath = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; String expectedBody = String.format( "{\"tuple_key\":{\"relation\":\"%s\",\"object\":\"%s\"},\"authorization_model_id\":\"%s\"}", DEFAULT_RELATION, DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -1867,7 +1869,7 @@ public void expand_storeIdRequired() { @Test public void expand_400() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1889,7 +1891,7 @@ public void expand_400() throws Exception { @Test public void expand_404() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -1910,7 +1912,7 @@ public void expand_404() throws Exception { @Test public void expand_500() throws Exception { // Given - String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String postUrl = "https://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -1934,7 +1936,7 @@ public void expand_500() throws Exception { @Test public void listObjectsTest() throws Exception { // Given - String postPath = String.format("https://localhost/stores/%s/list-objects", DEFAULT_STORE_ID); + String postPath = String.format("https://api.fga.example/stores/%s/list-objects", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"authorization_model_id\":\"%s\",\"type\":null,\"relation\":\"%s\",\"user\":\"%s\",\"contextual_tuples\":null,\"context\":null}", DEFAULT_AUTH_MODEL_ID, DEFAULT_RELATION, DEFAULT_USER); @@ -1971,7 +1973,7 @@ public void listObjects_storeIdRequired() { @Test public void listObjects_400() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/list-objects", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/list-objects", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -1993,7 +1995,7 @@ public void listObjects_400() throws Exception { @Test public void listObjects_404() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/list-objects", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/list-objects", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -2014,7 +2016,7 @@ public void listObjects_404() throws Exception { @Test public void listObjects_500() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/list-objects", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/list-objects", DEFAULT_STORE_ID); mockHttpClient .onPost(postUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -2035,7 +2037,7 @@ public void listObjects_500() throws Exception { @Test public void listObjectsWithContextTest() throws Exception { // Given - String postPath = String.format("https://localhost/stores/%s/list-objects", DEFAULT_STORE_ID); + String postPath = String.format("https://api.fga.example/stores/%s/list-objects", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"authorization_model_id\":\"%s\",\"type\":null,\"relation\":\"%s\",\"user\":\"%s\",\"contextual_tuples\":null,\"context\":{\"some\":\"context\"}}", DEFAULT_AUTH_MODEL_ID, DEFAULT_RELATION, DEFAULT_USER); @@ -2062,7 +2064,7 @@ public void listObjectsWithContextTest() throws Exception { @Test public void listRelations() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -2100,7 +2102,7 @@ public void listRelations() throws Exception { @Test public void listRelations_deny() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"%s\",\"trace\":null,\"context\":null}", DEFAULT_USER, "owner", DEFAULT_OBJECT, DEFAULT_AUTH_MODEL_ID); @@ -2192,7 +2194,7 @@ public void listRelations_atLeastOneRelationRequired() { @Test public void listRelations_400() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -2222,7 +2224,7 @@ public void listRelations_400() throws Exception { @Test public void listRelations_404() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -2251,7 +2253,7 @@ public void listRelations_404() throws Exception { @Test public void listRelations_500() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":null,\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null,\"context\":null}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -2280,7 +2282,7 @@ public void listRelations_500() throws Exception { @Test public void listRelations_contextAndContextualTuples() throws Exception { // Given - String postUrl = String.format("https://localhost/stores/%s/check", DEFAULT_STORE_ID); + String postUrl = String.format("https://api.fga.example/stores/%s/check", DEFAULT_STORE_ID); String expectedBody = String.format( "{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"contextual_tuples\":{\"tuple_keys\":[{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\",\"condition\":null}]},\"authorization_model_id\":\"%s\",\"trace\":null,\"context\":{\"some\":\"context\"}}", DEFAULT_USER, @@ -2331,8 +2333,8 @@ public void listRelations_contextAndContextualTuples() throws Exception { @Test public void readAssertionsTest() throws Exception { // Given - String getUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String getUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); String responseBody = String.format( "{\"assertions\":[{\"tuple_key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"},\"expectation\":true}]}", DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); @@ -2385,8 +2387,8 @@ public void readAssertions_authModelIdRequired() { @Test public void readAssertions_400() throws Exception { // Given - String getUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String getUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -2407,8 +2409,8 @@ public void readAssertions_400() throws Exception { @Test public void readAssertions_404() throws Exception { // Given - String getUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String getUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -2428,8 +2430,8 @@ public void readAssertions_404() throws Exception { @Test public void readAssertions_500() throws Exception { // Given - String getUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String getUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onGet(getUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -2452,8 +2454,8 @@ public void readAssertions_500() throws Exception { @Test public void writeAssertionsTest() throws Exception { // Given - String putUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + 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}]}", DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); @@ -2504,8 +2506,8 @@ public void writeAssertions_authModelIdRequired() { @Test public void writeAssertions_400() throws Exception { // Given - String putUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String putUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onPut(putUrl) .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); @@ -2526,8 +2528,8 @@ public void writeAssertions_400() throws Exception { @Test public void writeAssertions_404() throws Exception { // Given - String putUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String putUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onPut(putUrl) .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); @@ -2547,8 +2549,8 @@ public void writeAssertions_404() throws Exception { @Test public void writeAssertions_500() throws Exception { // Given - String putUrl = - String.format("https://localhost/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); + String putUrl = String.format( + "https://api.fga.example/stores/%s/assertions/%s", DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID); mockHttpClient .onPut(putUrl) .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); @@ -2573,7 +2575,7 @@ public void setStoreId() throws Exception { // Given String alternateStoreId = "A_UNIQUE_ID"; fga.setStoreId(alternateStoreId); - String getUrl = String.format("https://localhost/stores/%s", alternateStoreId); + String getUrl = String.format("https://api.fga.example/stores/%s", alternateStoreId); String responseBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", alternateStoreId, DEFAULT_STORE_NAME); mockHttpClient.onGet(getUrl).doReturn(200, responseBody); @@ -2597,7 +2599,8 @@ public void setAuthorizationModelId() throws Exception { String alternateAuthorizationModelId = "A_UNIQUE_ID"; fga.setAuthorizationModelId(alternateAuthorizationModelId); String getUrl = String.format( - "https://localhost/stores/%s/authorization-models/%s", DEFAULT_STORE_ID, alternateAuthorizationModelId); + "https://api.fga.example/stores/%s/authorization-models/%s", + DEFAULT_STORE_ID, alternateAuthorizationModelId); String getResponse = String.format( "{\"authorization_model\":{\"id\":\"%s\",\"schema_version\":\"%s\"}}", alternateAuthorizationModelId, DEFAULT_SCHEMA_VERSION);