diff --git a/src/main/java/io/permit/sdk/enforcement/User.java b/src/main/java/io/permit/sdk/enforcement/User.java index c611fa2..c8a4b96 100644 --- a/src/main/java/io/permit/sdk/enforcement/User.java +++ b/src/main/java/io/permit/sdk/enforcement/User.java @@ -1,7 +1,9 @@ package io.permit.sdk.enforcement; - import java.util.ArrayList; import java.util.HashMap; +import java.util.List; + +import io.permit.sdk.openapi.models.UserRoleCreate; public class User { private String key; @@ -9,6 +11,7 @@ public class User { private String lastName = null; private String email = null; private HashMap attributes = null; + private List roleAssignments = null; public User(Builder builder) { this.key = builder.key; @@ -16,6 +19,7 @@ public User(Builder builder) { this.lastName = builder.lastName; this.email = builder.email; this.attributes = builder.attributes; + this.roleAssignments = builder.roleAssignments; } public String getKey() { @@ -52,6 +56,7 @@ public static class Builder { private String lastName = null; private String email = null; private HashMap attributes = null; + private List roleAssignments; public Builder(String userKey) { this.key = userKey; @@ -77,6 +82,11 @@ public Builder withAttributes(HashMap attributes) { return this; } + public Builder withRoleAssignments(List roleAssignments) { + this.roleAssignments = roleAssignments; + return this; + } + public User build() { return new User(this); } diff --git a/src/main/java/io/permit/sdk/openapi/models/UserCreate.java b/src/main/java/io/permit/sdk/openapi/models/UserCreate.java index 9fd43c9..4fac4f0 100644 --- a/src/main/java/io/permit/sdk/openapi/models/UserCreate.java +++ b/src/main/java/io/permit/sdk/openapi/models/UserCreate.java @@ -2,7 +2,10 @@ package io.permit.sdk.openapi.models; import java.util.HashMap; +import java.util.List; + import javax.annotation.Generated; + import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -62,7 +65,16 @@ public class UserCreate { @SerializedName("attributes") @Expose public HashMap attributes; - + /** + * Role Assignments + *

+ * List of roles to assign to the user in the environment. + * + */ + @SerializedName("role_assignments") + @Expose + public List roleAssignments; + /** * No args constructor for use in serialization * @@ -104,4 +116,9 @@ public UserCreate withAttributes(HashMap attributes) { return this; } + public UserCreate withRoleAssignments(List roleAssignments) { + this.roleAssignments = roleAssignments; + return this; + } + } diff --git a/src/test/java/io/permit/sdk/e2e/RebacE2ETest.java b/src/test/java/io/permit/sdk/e2e/RebacE2ETest.java index 7053255..8124d06 100644 --- a/src/test/java/io/permit/sdk/e2e/RebacE2ETest.java +++ b/src/test/java/io/permit/sdk/e2e/RebacE2ETest.java @@ -179,14 +179,21 @@ public class RebacE2ETest extends PermitE2ETestBase { new ShortDerivation("folder#commenter", "document#commenter", "parent"), new ShortDerivation("folder#editor", "document#editor", "parent") ); + + final List roleAssignments = Arrays.asList( + new UserRoleCreate("editor", "default") + ); + final UserCreate USER_PERMIT = new UserCreate() .withKey("asaf@permit.io") .withEmail("asaf@permit.io") .withFirstName("Asaf") .withLastName("Cohen") + .withRoleAssignments(roleAssignments) .withAttributes(new HashMap() {{ put("age", 35); }}); + final UserCreate USER_CC = new UserCreate() .withKey("auth0|john") .withEmail("john@cocacola.com")