From a66bf1bc6f0ff6e06197ee6c2d8c3ab3d0fab134 Mon Sep 17 00:00:00 2001 From: gideonsmila Date: Sun, 22 Dec 2024 11:27:20 +0200 Subject: [PATCH] change name for new get user permissions using opa --- src/main/java/io/permit/sdk/Permit.java | 26 ++++++++++++------- .../io/permit/sdk/enforcement/Enforcer.java | 2 +- .../permit/sdk/enforcement/IEnforcerApi.java | 8 +++--- .../java/io/permit/sdk/e2e/RbacE2ETest.java | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/permit/sdk/Permit.java b/src/main/java/io/permit/sdk/Permit.java index 4c7ef98..daa0838 100644 --- a/src/main/java/io/permit/sdk/Permit.java +++ b/src/main/java/io/permit/sdk/Permit.java @@ -1,19 +1,27 @@ package io.permit.sdk; +import java.io.IOException; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; + import io.permit.sdk.api.ApiClient; import io.permit.sdk.api.ElementsApi; import io.permit.sdk.api.PermitApiError; -import io.permit.sdk.enforcement.*; +import io.permit.sdk.enforcement.CheckQuery; +import io.permit.sdk.enforcement.Enforcer; +import io.permit.sdk.enforcement.GetUserPermissionsQuery; +import io.permit.sdk.enforcement.IEnforcerApi; +import io.permit.sdk.enforcement.Resource; +import io.permit.sdk.enforcement.TenantDetails; +import io.permit.sdk.enforcement.User; +import io.permit.sdk.enforcement.UserPermissions; import io.permit.sdk.util.Context; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.List; - /** * The {@code Permit} class represents the main entry point for interacting with the Permit.io SDK. * @@ -160,8 +168,8 @@ public UserPermissions getUserPermissions(GetUserPermissionsQuery input) throws } @Override - public UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError { - return this.enforcer.getUserPermissionsWithOPA(input); + public UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError { + return this.enforcer.getUserPermissionsFromOPA(input); } @Override diff --git a/src/main/java/io/permit/sdk/enforcement/Enforcer.java b/src/main/java/io/permit/sdk/enforcement/Enforcer.java index b755f5d..88e3398 100644 --- a/src/main/java/io/permit/sdk/enforcement/Enforcer.java +++ b/src/main/java/io/permit/sdk/enforcement/Enforcer.java @@ -451,7 +451,7 @@ public UserPermissions getUserPermissions(GetUserPermissionsQuery input) throws @Override - public UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError { + public UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError { // request body Gson gson = new Gson(); diff --git a/src/main/java/io/permit/sdk/enforcement/IEnforcerApi.java b/src/main/java/io/permit/sdk/enforcement/IEnforcerApi.java index 79b7b3c..3fb65a4 100644 --- a/src/main/java/io/permit/sdk/enforcement/IEnforcerApi.java +++ b/src/main/java/io/permit/sdk/enforcement/IEnforcerApi.java @@ -1,11 +1,11 @@ package io.permit.sdk.enforcement; -import io.permit.sdk.api.PermitApiError; -import io.permit.sdk.util.Context; - import java.io.IOException; import java.util.List; +import io.permit.sdk.api.PermitApiError; +import io.permit.sdk.util.Context; + public interface IEnforcerApi { /** * Checks if a `user` is authorized to perform an `action` on a `resource` within the specified context. @@ -120,7 +120,7 @@ public interface IEnforcerApi { * @throws PermitApiError if an error occurs while sending the authorization request to the PDP. * @throws IOException if could not read the content of the returned http response. */ - UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError; + UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError; /** * list all the tenants the user is associated with. diff --git a/src/test/java/io/permit/sdk/e2e/RbacE2ETest.java b/src/test/java/io/permit/sdk/e2e/RbacE2ETest.java index 15865f2..d68b1ca 100644 --- a/src/test/java/io/permit/sdk/e2e/RbacE2ETest.java +++ b/src/test/java/io/permit/sdk/e2e/RbacE2ETest.java @@ -251,7 +251,7 @@ void testPermissionCheckRBAC() { ) ); - UserPermissions permissions_2 = permitOpa.getUserPermissionsWithOPA( + UserPermissions permissions_2 = permitOpa.getUserPermissionsFromOPA( new GetUserPermissionsQuery( User.fromString("auth0|elon") )