Skip to content

Commit

Permalink
Add role to directory user (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallstrautman authored Oct 21, 2024
1 parent 4387a81 commit ea230b8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.workos.directorysync.models

import com.workos.common.models.Role

typealias DirectoryUserRole = Role
5 changes: 5 additions & 0 deletions src/main/kotlin/com/workos/directorysync/models/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param emails The emails of the user.
* @param groups The groups that the user is a member of.
* @param state The state of the user.
* @param role The user's role based on group memberships.
* @param customAttributes An object containing the custom attribute mapping for the Directory Provider.
* @param rawAttributes An object containing the data returned from the Directory Provider.
*/
Expand Down Expand Up @@ -76,6 +77,10 @@ open class User
@JvmField
open val state: UserState,

@JvmField
@JsonProperty("role")
val role: DirectoryUserRole,

@JvmField
@JsonProperty("custom_attributes")
open val customAttributes: Map<String, Any?>,
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/workos/webhooks/models/UserUpdated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.workos.webhooks.models

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.workos.directorysync.models.DirectoryUserRole
import com.workos.directorysync.models.Email
import com.workos.directorysync.models.UserState

Expand Down Expand Up @@ -67,6 +68,10 @@ open class UserUpdated
@JsonProperty("raw_attributes")
val rawAttributes: Map<String, Any?>,

@JvmField
@JsonProperty("role")
val role: DirectoryUserRole,

/**
* Object containing the names and values of attributes and their previous values.
* New attributes that do not appear in the previous snapshot are indicated with a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class DirectorySyncApiTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"admin"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down Expand Up @@ -528,6 +529,7 @@ class DirectorySyncApiTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"admin"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down Expand Up @@ -559,6 +561,7 @@ class DirectorySyncApiTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"member"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down Expand Up @@ -629,6 +632,7 @@ class DirectorySyncApiTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"admin"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down Expand Up @@ -659,6 +663,7 @@ class DirectorySyncApiTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"member"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down Expand Up @@ -734,6 +739,7 @@ class DirectorySyncApiTest : TestBase() {
"state": "active",
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"role":{"slug":"admin"},
"custom_attributes": {
"department": "Engineering"
},
Expand Down Expand Up @@ -765,6 +771,7 @@ class DirectorySyncApiTest : TestBase() {
"state": "active",
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"role":{"slug":"member"},
"custom_attributes": {
"department": "Engineering"
},
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/workos/test/directorysync/UserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class UserTest : TestBase() {
"raw_attributes": {}
}],
"state": "active",
"role":{"slug":"admin"},
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"custom_attributes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DirectoryGroupWebhookTests : TestBase() {
"first_name": "Michael",
"job_title": "Software Engineer",
"directory_id": "$directoryId",
"role": { "slug": "member" },
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"raw_attributes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DirectoryUserWebhookTests : TestBase() {
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"directory_id": "$directoryId",
"role": { "slug": "member" },
"raw_attributes": {
"id": "105777651754615852813",
"etag": "\"nqbsbhvoIENh0WbZEZYWTG7mnk2phHz4rrCEo-rHT2k/E5jQHrdS88NS4ACUhZ4m9CYVR30\"",
Expand Down Expand Up @@ -102,6 +103,7 @@ class DirectoryUserWebhookTests : TestBase() {
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"directory_id": "$directoryId",
"role": { "slug": "admin" },
"raw_attributes": {
"id": "105777651754615852813",
"etag": "\"nqbsbhvoIENh0WbZEZYWTG7mnk2phHz4rrCEo-rHT2k/E5jQHrdS88NS4ACUhZ4m9CYVR30\"",
Expand Down Expand Up @@ -140,6 +142,7 @@ class DirectoryUserWebhookTests : TestBase() {
},
"custom_attributes": {},
"previous_attributes": {
"role": { "slug": "member" },
"raw_attributes": {
"emails": [
{
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/workos/test/webhooks/WebhooksApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class WebhooksApiTest : TestBase() {
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"directory_id": "directory_01F9M7F68PZP8QXP8G7X5QRHS7",
"role": { "slug": "member" },
"custom_attributes": {},
"raw_attributes": {
"name": {
Expand Down Expand Up @@ -95,6 +96,7 @@ class WebhooksApiTest : TestBase() {
"created_at": "2021-06-25T19:07:33.155Z",
"updated_at": "2021-06-25T19:08:33.155Z",
"directory_id": "directory_01F9M7F68PZP8QXP8G7X5QRHS7",
"role": { "slug": "member" },
"custom_attributes": {},
"raw_attributes": {},
"new_unknown_property": {},
Expand Down

0 comments on commit ea230b8

Please sign in to comment.