workos 7.1.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/docs.yml +46 -0
- data/.gitignore +2 -0
- data/.last-synced-sha +1 -1
- data/.oagen-manifest.json +61 -40
- data/.release-please-manifest.json +1 -1
- data/.yardopts +6 -0
- data/CHANGELOG.md +38 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +33 -2
- data/lib/workos/api_keys/api_key.rb +1 -1
- data/lib/workos/api_keys/api_key_created_data.rb +1 -1
- data/lib/workos/api_keys/organization_api_key.rb +43 -0
- data/lib/workos/{types/events_order.rb → api_keys/organization_api_key_owner.rb} +1 -3
- data/lib/workos/api_keys/organization_api_key_with_value.rb +46 -0
- data/lib/workos/{types/audit_logs_order.rb → api_keys/organization_api_key_with_value_owner.rb} +1 -3
- data/lib/workos/api_keys.rb +46 -46
- data/lib/workos/audit_logs.rb +6 -6
- data/lib/workos/authorization/user_organization_membership_base_list_data.rb +5 -2
- data/lib/workos/authorization/{role_assignment.rb → user_role_assignment.rb} +5 -2
- data/lib/workos/authorization/{role_assignment_resource.rb → user_role_assignment_resource.rb} +1 -1
- data/lib/workos/authorization.rb +250 -138
- data/lib/workos/base_client.rb +6 -1
- data/lib/workos/client.rb +4 -4
- data/lib/workos/connect.rb +2 -2
- data/lib/workos/directory_sync/directory_user.rb +3 -0
- data/lib/workos/directory_sync/directory_user_with_groups.rb +4 -1
- data/lib/workos/directory_sync/dsync_user_updated_data.rb +3 -0
- data/lib/workos/directory_sync.rb +6 -6
- data/lib/workos/encryptors/aes_gcm.rb +35 -3
- data/lib/workos/events.rb +2 -2
- data/lib/workos/feature_flags.rb +6 -6
- data/lib/workos/groups.rb +5 -5
- data/lib/workos/multi_factor_auth.rb +3 -3
- data/lib/workos/organization_domains.rb +1 -1
- data/lib/workos/organizations.rb +2 -2
- data/lib/workos/radar.rb +2 -2
- data/lib/workos/sso/profile.rb +3 -0
- data/lib/workos/sso.rb +4 -4
- data/lib/workos/types/event_context_actor_source.rb +2 -1
- data/lib/workos/types/{applications_order.rb → pagination_order.rb} +1 -1
- data/lib/workos/types/{vault_byok_key_verification_completed_data_key_provider.rb → vault_byok_key_provider.rb} +1 -1
- data/lib/workos/user_management/create_user_api_key.rb +25 -0
- data/lib/workos/user_management/organization_membership.rb +5 -2
- data/lib/workos/user_management/user_api_key.rb +43 -0
- data/lib/workos/user_management/user_api_key_created_data_owner.rb +25 -0
- data/lib/workos/{api_keys/api_key_with_value_owner.rb → user_management/user_api_key_owner.rb} +1 -1
- data/lib/workos/{types/webhooks_order.rb → user_management/user_api_key_revoked_data_owner.rb} +1 -3
- data/lib/workos/{api_keys/api_key_with_value.rb → user_management/user_api_key_with_value.rb} +2 -2
- data/lib/workos/{types/groups_order.rb → user_management/user_api_key_with_value_owner.rb} +1 -3
- data/lib/workos/user_management/user_organization_membership.rb +5 -2
- data/lib/workos/user_management.rb +181 -75
- data/lib/workos/user_management_organization_membership_groups.rb +2 -2
- data/lib/workos/vault/vault_byok_key_deleted.rb +34 -0
- data/lib/workos/vault/vault_byok_key_deleted_data.rb +22 -0
- data/lib/workos/version.rb +1 -1
- data/lib/workos/webhooks.rb +3 -3
- data/rbi/workos/api_key.rbi +2 -2
- data/rbi/workos/api_key_created_data.rbi +2 -2
- data/rbi/workos/api_key_revoked_data.rbi +2 -2
- data/rbi/workos/api_keys.rbi +17 -17
- data/rbi/workos/authorization.rbi +127 -27
- data/rbi/workos/client.rbi +3 -3
- data/rbi/workos/create_user_api_key.rbi +36 -0
- data/rbi/workos/directory_user.rbi +6 -0
- data/rbi/workos/directory_user_with_groups.rbi +6 -0
- data/rbi/workos/dsync_user_updated_data.rbi +6 -0
- data/rbi/workos/organization_api_key.rbi +72 -0
- data/rbi/workos/{api_key_with_value_owner.rbi → organization_api_key_owner.rbi} +1 -1
- data/rbi/workos/organization_api_key_with_value.rbi +78 -0
- data/rbi/workos/organization_api_key_with_value_owner.rbi +30 -0
- data/rbi/workos/organization_membership.rbi +6 -0
- data/rbi/workos/profile.rbi +6 -0
- data/rbi/workos/user_api_key.rbi +72 -0
- data/rbi/workos/user_api_key_created_data_owner.rbi +36 -0
- data/rbi/workos/user_api_key_owner.rbi +36 -0
- data/rbi/workos/user_api_key_revoked_data_owner.rbi +36 -0
- data/rbi/workos/{api_key_with_value.rbi → user_api_key_with_value.rbi} +3 -3
- data/rbi/workos/user_api_key_with_value_owner.rbi +36 -0
- data/rbi/workos/user_management.rbi +91 -14
- data/rbi/workos/user_organization_membership.rbi +6 -0
- data/rbi/workos/user_organization_membership_base_list_data.rbi +6 -0
- data/rbi/workos/{role_assignment.rbi → user_role_assignment.rbi} +9 -3
- data/rbi/workos/{role_assignment_resource.rbi → user_role_assignment_resource.rbi} +1 -1
- data/rbi/workos/vault_byok_key_deleted.rbi +54 -0
- data/rbi/workos/vault_byok_key_deleted_data.rbi +30 -0
- data/script/docs +16 -0
- data/script/docs-serve +12 -0
- data/script/llms-txt +37 -0
- data/test/workos/test_api_keys.rb +17 -17
- data/test/workos/test_audit_logs.rb +2 -2
- data/test/workos/test_authorization.rb +102 -20
- data/test/workos/test_encryptors_aes_gcm.rb +21 -0
- data/test/workos/test_model_round_trip.rb +278 -83
- data/test/workos/test_session.rb +68 -0
- data/test/workos/test_user_management.rb +69 -9
- data/test/workos/test_webhooks.rb +2 -2
- metadata +39 -33
- data/lib/workos/types/authorization_order.rb +0 -9
- data/lib/workos/types/connections_order.rb +0 -9
- data/lib/workos/types/directories_order.rb +0 -9
- data/lib/workos/types/directory_groups_order.rb +0 -9
- data/lib/workos/types/directory_users_order.rb +0 -9
- data/lib/workos/types/feature_flags_order.rb +0 -9
- data/lib/workos/types/organizations_api_keys_order.rb +0 -9
- data/lib/workos/types/organizations_feature_flags_order.rb +0 -9
- data/lib/workos/types/organizations_order.rb +0 -9
- data/lib/workos/types/permissions_order.rb +0 -9
- data/lib/workos/types/user_management_invitations_order.rb +0 -9
- data/lib/workos/types/user_management_multi_factor_authentication_order.rb +0 -9
- data/lib/workos/types/user_management_organization_membership_groups_order.rb +0 -9
- data/lib/workos/types/user_management_organization_membership_order.rb +0 -9
- data/lib/workos/types/user_management_users_authorized_applications_order.rb +0 -9
- data/lib/workos/types/user_management_users_feature_flags_order.rb +0 -9
- data/lib/workos/types/user_management_users_order.rb +0 -9
|
@@ -42,7 +42,7 @@ class AuditLogsTest < Minitest::Test
|
|
|
42
42
|
def test_create_schema_returns_expected_result
|
|
43
43
|
stub_request(:post, %r{\Ahttps://api\.workos\.com/audit_logs/actions/stub/schemas(\?|\z)})
|
|
44
44
|
.to_return(body: "{}", status: 200)
|
|
45
|
-
result = @client.audit_logs.create_schema(action_name: "stub", targets: [])
|
|
45
|
+
result = @client.audit_logs.create_schema(action_name: "stub", targets: [{}])
|
|
46
46
|
refute_nil result
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -73,7 +73,7 @@ class AuditLogsTest < Minitest::Test
|
|
|
73
73
|
{name: :update_organization_audit_logs_retention, verb: :put, url: %r{\Ahttps://api\.workos\.com/organizations/stub/audit_logs_retention(\?|\z)}, args: {id: "stub", retention_period_in_days: 1}},
|
|
74
74
|
{name: :list_actions, verb: :get, url: %r{\Ahttps://api\.workos\.com/audit_logs/actions(\?|\z)}},
|
|
75
75
|
{name: :list_action_schemas, verb: :get, url: %r{\Ahttps://api\.workos\.com/audit_logs/actions/stub/schemas(\?|\z)}, args: {action_name: "stub"}},
|
|
76
|
-
{name: :create_schema, verb: :post, url: %r{\Ahttps://api\.workos\.com/audit_logs/actions/stub/schemas(\?|\z)}, args: {action_name: "stub", targets: []}},
|
|
76
|
+
{name: :create_schema, verb: :post, url: %r{\Ahttps://api\.workos\.com/audit_logs/actions/stub/schemas(\?|\z)}, args: {action_name: "stub", targets: [{}]}},
|
|
77
77
|
{name: :create_event, verb: :post, url: %r{\Ahttps://api\.workos\.com/audit_logs/events(\?|\z)}, args: {organization_id: "stub", event: {}}},
|
|
78
78
|
{name: :create_export, verb: :post, url: %r{\Ahttps://api\.workos\.com/audit_logs/exports(\?|\z)}, args: {organization_id: "stub", range_start: "stub", range_end: "stub"}},
|
|
79
79
|
{name: :get_export, verb: :get, url: %r{\Ahttps://api\.workos\.com/audit_logs/exports/stub(\?|\z)}, args: {audit_log_export_id: "stub"}}
|
|
@@ -13,15 +13,31 @@ class AuthorizationTest < Minitest::Test
|
|
|
13
13
|
|
|
14
14
|
def test_check_returns_expected_result
|
|
15
15
|
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/check(\?|\z)})
|
|
16
|
+
.with(body: hash_including("permission_slug" => "stub", "resource_id" => "stub"))
|
|
16
17
|
.to_return(body: "{}", status: 200)
|
|
17
|
-
result = @client.authorization.check(organization_membership_id: "stub", permission_slug: "stub", resource_target:
|
|
18
|
+
result = @client.authorization.check(organization_membership_id: "stub", permission_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub"))
|
|
19
|
+
refute_nil result
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_check_with_resource_target_by_external_id_returns_expected_result
|
|
23
|
+
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/check(\?|\z)})
|
|
24
|
+
.with(body: hash_including("permission_slug" => "stub", "resource_external_id" => "stub", "resource_type_slug" => "stub"))
|
|
25
|
+
.to_return(body: "{}", status: 200)
|
|
26
|
+
result = @client.authorization.check(organization_membership_id: "stub", permission_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetByExternalId.new(resource_external_id: "stub", resource_type_slug: "stub"))
|
|
18
27
|
refute_nil result
|
|
19
28
|
end
|
|
20
29
|
|
|
21
30
|
def test_list_resources_for_membership_returns_expected_result
|
|
22
31
|
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources(\?|\z)})
|
|
23
32
|
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
24
|
-
result = @client.authorization.list_resources_for_membership(organization_membership_id: "stub", permission_slug: "stub", parent_resource:
|
|
33
|
+
result = @client.authorization.list_resources_for_membership(organization_membership_id: "stub", permission_slug: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub"))
|
|
34
|
+
assert_kind_of WorkOS::Types::ListStruct, result
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_list_resources_for_membership_with_parent_resource_by_external_id_returns_expected_result
|
|
38
|
+
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources(\?|\z)})
|
|
39
|
+
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
40
|
+
result = @client.authorization.list_resources_for_membership(organization_membership_id: "stub", permission_slug: "stub", parent_resource: WorkOS::Authorization::ParentResourceByExternalId.new(parent_resource_type_slug: "stub", parent_resource_external_id: "stub"))
|
|
25
41
|
assert_kind_of WorkOS::Types::ListStruct, result
|
|
26
42
|
end
|
|
27
43
|
|
|
@@ -48,15 +64,31 @@ class AuthorizationTest < Minitest::Test
|
|
|
48
64
|
|
|
49
65
|
def test_assign_role_returns_expected_result
|
|
50
66
|
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)})
|
|
67
|
+
.with(body: hash_including("role_slug" => "stub", "resource_id" => "stub"))
|
|
68
|
+
.to_return(body: "{}", status: 200)
|
|
69
|
+
result = @client.authorization.assign_role(organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub"))
|
|
70
|
+
refute_nil result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_assign_role_with_resource_target_by_external_id_returns_expected_result
|
|
74
|
+
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)})
|
|
75
|
+
.with(body: hash_including("role_slug" => "stub", "resource_external_id" => "stub", "resource_type_slug" => "stub"))
|
|
51
76
|
.to_return(body: "{}", status: 200)
|
|
52
|
-
result = @client.authorization.assign_role(organization_membership_id: "stub", role_slug: "stub", resource_target:
|
|
77
|
+
result = @client.authorization.assign_role(organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetByExternalId.new(resource_external_id: "stub", resource_type_slug: "stub"))
|
|
53
78
|
refute_nil result
|
|
54
79
|
end
|
|
55
80
|
|
|
56
81
|
def test_remove_role_returns_expected_result
|
|
57
82
|
stub_request(:delete, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)})
|
|
58
83
|
.to_return(body: "{}", status: 200)
|
|
59
|
-
result = @client.authorization.remove_role(organization_membership_id: "stub", role_slug: "stub", resource_target:
|
|
84
|
+
result = @client.authorization.remove_role(organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub"))
|
|
85
|
+
assert_nil result
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_remove_role_with_resource_target_by_external_id_returns_expected_result
|
|
89
|
+
stub_request(:delete, %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)})
|
|
90
|
+
.to_return(body: "{}", status: 200)
|
|
91
|
+
result = @client.authorization.remove_role(organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetByExternalId.new(resource_external_id: "stub", resource_type_slug: "stub"))
|
|
60
92
|
assert_nil result
|
|
61
93
|
end
|
|
62
94
|
|
|
@@ -112,7 +144,7 @@ class AuthorizationTest < Minitest::Test
|
|
|
112
144
|
def test_set_organization_role_permissions_returns_expected_result
|
|
113
145
|
stub_request(:put, %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub/permissions(\?|\z)})
|
|
114
146
|
.to_return(body: "{}", status: 200)
|
|
115
|
-
result = @client.authorization.set_organization_role_permissions(organization_id: "stub", slug: "stub", permissions: [])
|
|
147
|
+
result = @client.authorization.set_organization_role_permissions(organization_id: "stub", slug: "stub", permissions: ["stub"])
|
|
116
148
|
refute_nil result
|
|
117
149
|
end
|
|
118
150
|
|
|
@@ -132,8 +164,17 @@ class AuthorizationTest < Minitest::Test
|
|
|
132
164
|
|
|
133
165
|
def test_update_resource_by_external_id_returns_expected_result
|
|
134
166
|
stub_request(:patch, %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)})
|
|
167
|
+
.with(body: hash_including("parent_resource_id" => "stub"))
|
|
168
|
+
.to_return(body: "{}", status: 200)
|
|
169
|
+
result = @client.authorization.update_resource_by_external_id(organization_id: "stub", resource_type_slug: "stub", external_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub"))
|
|
170
|
+
refute_nil result
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_update_resource_by_external_id_with_parent_resource_by_external_id_returns_expected_result
|
|
174
|
+
stub_request(:patch, %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)})
|
|
175
|
+
.with(body: hash_including("parent_resource_external_id" => "stub", "parent_resource_type_slug" => "stub"))
|
|
135
176
|
.to_return(body: "{}", status: 200)
|
|
136
|
-
result = @client.authorization.update_resource_by_external_id(organization_id: "stub", resource_type_slug: "stub", external_id: "stub")
|
|
177
|
+
result = @client.authorization.update_resource_by_external_id(organization_id: "stub", resource_type_slug: "stub", external_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceByExternalId.new(parent_resource_external_id: "stub", parent_resource_type_slug: "stub"))
|
|
137
178
|
refute_nil result
|
|
138
179
|
end
|
|
139
180
|
|
|
@@ -151,17 +192,40 @@ class AuthorizationTest < Minitest::Test
|
|
|
151
192
|
assert_kind_of WorkOS::Types::ListStruct, result
|
|
152
193
|
end
|
|
153
194
|
|
|
195
|
+
def test_list_role_assignments_for_resource_by_external_id_returns_expected_result
|
|
196
|
+
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub/role_assignments(\?|\z)})
|
|
197
|
+
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
198
|
+
result = @client.authorization.list_role_assignments_for_resource_by_external_id(organization_id: "stub", resource_type_slug: "stub", external_id: "stub")
|
|
199
|
+
assert_kind_of WorkOS::Types::ListStruct, result
|
|
200
|
+
end
|
|
201
|
+
|
|
154
202
|
def test_list_resources_returns_expected_result
|
|
155
203
|
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)})
|
|
156
204
|
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
157
|
-
result = @client.authorization.list_resources
|
|
205
|
+
result = @client.authorization.list_resources(parent: WorkOS::Authorization::ParentById.new(parent_resource_id: "stub"))
|
|
206
|
+
assert_kind_of WorkOS::Types::ListStruct, result
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_list_resources_with_parent_by_external_id_returns_expected_result
|
|
210
|
+
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)})
|
|
211
|
+
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
212
|
+
result = @client.authorization.list_resources(parent: WorkOS::Authorization::ParentByExternalId.new(parent_resource_type_slug: "stub", parent_external_id: "stub"))
|
|
158
213
|
assert_kind_of WorkOS::Types::ListStruct, result
|
|
159
214
|
end
|
|
160
215
|
|
|
161
216
|
def test_create_resource_returns_expected_result
|
|
162
217
|
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)})
|
|
218
|
+
.with(body: hash_including("external_id" => "stub", "name" => "stub", "resource_type_slug" => "stub", "organization_id" => "stub", "parent_resource_id" => "stub"))
|
|
219
|
+
.to_return(body: "{}", status: 200)
|
|
220
|
+
result = @client.authorization.create_resource(external_id: "stub", name: "stub", resource_type_slug: "stub", organization_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub"))
|
|
221
|
+
refute_nil result
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def test_create_resource_with_parent_resource_by_external_id_returns_expected_result
|
|
225
|
+
stub_request(:post, %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)})
|
|
226
|
+
.with(body: hash_including("external_id" => "stub", "name" => "stub", "resource_type_slug" => "stub", "organization_id" => "stub", "parent_resource_external_id" => "stub", "parent_resource_type_slug" => "stub"))
|
|
163
227
|
.to_return(body: "{}", status: 200)
|
|
164
|
-
result = @client.authorization.create_resource(external_id: "stub", name: "stub", resource_type_slug: "stub", organization_id: "stub")
|
|
228
|
+
result = @client.authorization.create_resource(external_id: "stub", name: "stub", resource_type_slug: "stub", organization_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceByExternalId.new(parent_resource_external_id: "stub", parent_resource_type_slug: "stub"))
|
|
165
229
|
refute_nil result
|
|
166
230
|
end
|
|
167
231
|
|
|
@@ -174,8 +238,17 @@ class AuthorizationTest < Minitest::Test
|
|
|
174
238
|
|
|
175
239
|
def test_update_resource_returns_expected_result
|
|
176
240
|
stub_request(:patch, %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)})
|
|
241
|
+
.with(body: hash_including("parent_resource_id" => "stub"))
|
|
242
|
+
.to_return(body: "{}", status: 200)
|
|
243
|
+
result = @client.authorization.update_resource(resource_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub"))
|
|
244
|
+
refute_nil result
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def test_update_resource_with_parent_resource_by_external_id_returns_expected_result
|
|
248
|
+
stub_request(:patch, %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)})
|
|
249
|
+
.with(body: hash_including("parent_resource_external_id" => "stub", "parent_resource_type_slug" => "stub"))
|
|
177
250
|
.to_return(body: "{}", status: 200)
|
|
178
|
-
result = @client.authorization.update_resource(resource_id: "stub")
|
|
251
|
+
result = @client.authorization.update_resource(resource_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceByExternalId.new(parent_resource_external_id: "stub", parent_resource_type_slug: "stub"))
|
|
179
252
|
refute_nil result
|
|
180
253
|
end
|
|
181
254
|
|
|
@@ -193,6 +266,13 @@ class AuthorizationTest < Minitest::Test
|
|
|
193
266
|
assert_kind_of WorkOS::Types::ListStruct, result
|
|
194
267
|
end
|
|
195
268
|
|
|
269
|
+
def test_list_role_assignments_for_resource_returns_expected_result
|
|
270
|
+
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/resources/stub/role_assignments(\?|\z)})
|
|
271
|
+
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
|
|
272
|
+
result = @client.authorization.list_role_assignments_for_resource(resource_id: "stub")
|
|
273
|
+
assert_kind_of WorkOS::Types::ListStruct, result
|
|
274
|
+
end
|
|
275
|
+
|
|
196
276
|
def test_list_environment_roles_returns_expected_result
|
|
197
277
|
stub_request(:get, %r{\Ahttps://api\.workos\.com/authorization/roles(\?|\z)})
|
|
198
278
|
.to_return(body: "{}", status: 200)
|
|
@@ -231,7 +311,7 @@ class AuthorizationTest < Minitest::Test
|
|
|
231
311
|
def test_set_environment_role_permissions_returns_expected_result
|
|
232
312
|
stub_request(:put, %r{\Ahttps://api\.workos\.com/authorization/roles/stub/permissions(\?|\z)})
|
|
233
313
|
.to_return(body: "{}", status: 200)
|
|
234
|
-
result = @client.authorization.set_environment_role_permissions(slug: "stub", permissions: [])
|
|
314
|
+
result = @client.authorization.set_environment_role_permissions(slug: "stub", permissions: ["stub"])
|
|
235
315
|
refute_nil result
|
|
236
316
|
end
|
|
237
317
|
|
|
@@ -272,13 +352,13 @@ class AuthorizationTest < Minitest::Test
|
|
|
272
352
|
|
|
273
353
|
# Parameterized authentication error tests (one per endpoint).
|
|
274
354
|
[
|
|
275
|
-
{name: :check, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/check(\?|\z)}, args: {organization_membership_id: "stub", permission_slug: "stub", resource_target:
|
|
276
|
-
{name: :list_resources_for_membership, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources(\?|\z)}, args: {organization_membership_id: "stub", permission_slug: "stub", parent_resource:
|
|
355
|
+
{name: :check, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/check(\?|\z)}, args: {organization_membership_id: "stub", permission_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub")}},
|
|
356
|
+
{name: :list_resources_for_membership, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources(\?|\z)}, args: {organization_membership_id: "stub", permission_slug: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub")}},
|
|
277
357
|
{name: :list_effective_permissions, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources/stub/permissions(\?|\z)}, args: {organization_membership_id: "stub", resource_id: "stub"}},
|
|
278
358
|
{name: :list_effective_permissions_by_external_id, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/resources/stub/stub/permissions(\?|\z)}, args: {organization_membership_id: "stub", resource_type_slug: "stub", external_id: "stub"}},
|
|
279
359
|
{name: :list_role_assignments, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)}, args: {organization_membership_id: "stub"}},
|
|
280
|
-
{name: :assign_role, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)}, args: {organization_membership_id: "stub", role_slug: "stub", resource_target:
|
|
281
|
-
{name: :remove_role, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)}, args: {organization_membership_id: "stub", role_slug: "stub", resource_target:
|
|
360
|
+
{name: :assign_role, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)}, args: {organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub")}},
|
|
361
|
+
{name: :remove_role, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments(\?|\z)}, args: {organization_membership_id: "stub", role_slug: "stub", resource_target: WorkOS::Authorization::ResourceTargetById.new(resource_id: "stub")}},
|
|
282
362
|
{name: :remove_role_assignment, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organization_memberships/stub/role_assignments/stub(\?|\z)}, args: {organization_membership_id: "stub", role_assignment_id: "stub"}},
|
|
283
363
|
{name: :list_organization_roles, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles(\?|\z)}, args: {organization_id: "stub"}},
|
|
284
364
|
{name: :create_organization_role, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles(\?|\z)}, args: {organization_id: "stub", name: "stub"}},
|
|
@@ -286,24 +366,26 @@ class AuthorizationTest < Minitest::Test
|
|
|
286
366
|
{name: :update_organization_role, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub(\?|\z)}, args: {organization_id: "stub", slug: "stub"}},
|
|
287
367
|
{name: :delete_organization_role, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub(\?|\z)}, args: {organization_id: "stub", slug: "stub"}},
|
|
288
368
|
{name: :add_organization_role_permission, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub/permissions(\?|\z)}, args: {organization_id: "stub", slug: "stub", body_slug: "stub"}},
|
|
289
|
-
{name: :set_organization_role_permissions, verb: :put, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub/permissions(\?|\z)}, args: {organization_id: "stub", slug: "stub", permissions: []}},
|
|
369
|
+
{name: :set_organization_role_permissions, verb: :put, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub/permissions(\?|\z)}, args: {organization_id: "stub", slug: "stub", permissions: ["stub"]}},
|
|
290
370
|
{name: :remove_organization_role_permission, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/roles/stub/permissions/stub(\?|\z)}, args: {organization_id: "stub", slug: "stub", permission_slug: "stub"}},
|
|
291
371
|
{name: :get_resource_by_external_id, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub"}},
|
|
292
|
-
{name: :update_resource_by_external_id, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub"}},
|
|
372
|
+
{name: :update_resource_by_external_id, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub")}},
|
|
293
373
|
{name: :delete_resource_by_external_id, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub"}},
|
|
294
374
|
{name: :list_memberships_for_resource_by_external_id, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub/organization_memberships(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub", permission_slug: "stub"}},
|
|
295
|
-
{name: :
|
|
296
|
-
{name: :
|
|
375
|
+
{name: :list_role_assignments_for_resource_by_external_id, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/organizations/stub/resources/stub/stub/role_assignments(\?|\z)}, args: {organization_id: "stub", resource_type_slug: "stub", external_id: "stub"}},
|
|
376
|
+
{name: :list_resources, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)}, args: {parent: WorkOS::Authorization::ParentById.new(parent_resource_id: "stub")}},
|
|
377
|
+
{name: :create_resource, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/resources(\?|\z)}, args: {external_id: "stub", name: "stub", resource_type_slug: "stub", organization_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub")}},
|
|
297
378
|
{name: :get_resource, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)}, args: {resource_id: "stub"}},
|
|
298
|
-
{name: :update_resource, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)}, args: {resource_id: "stub"}},
|
|
379
|
+
{name: :update_resource, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)}, args: {resource_id: "stub", parent_resource: WorkOS::Authorization::ParentResourceById.new(parent_resource_id: "stub")}},
|
|
299
380
|
{name: :delete_resource, verb: :delete, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub(\?|\z)}, args: {resource_id: "stub"}},
|
|
300
381
|
{name: :list_memberships_for_resource, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub/organization_memberships(\?|\z)}, args: {resource_id: "stub", permission_slug: "stub"}},
|
|
382
|
+
{name: :list_role_assignments_for_resource, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/resources/stub/role_assignments(\?|\z)}, args: {resource_id: "stub"}},
|
|
301
383
|
{name: :list_environment_roles, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/roles(\?|\z)}},
|
|
302
384
|
{name: :create_environment_role, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/roles(\?|\z)}, args: {slug: "stub", name: "stub"}},
|
|
303
385
|
{name: :get_environment_role, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/roles/stub(\?|\z)}, args: {slug: "stub"}},
|
|
304
386
|
{name: :update_environment_role, verb: :patch, url: %r{\Ahttps://api\.workos\.com/authorization/roles/stub(\?|\z)}, args: {slug: "stub"}},
|
|
305
387
|
{name: :add_environment_role_permission, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/roles/stub/permissions(\?|\z)}, args: {slug: "stub", body_slug: "stub"}},
|
|
306
|
-
{name: :set_environment_role_permissions, verb: :put, url: %r{\Ahttps://api\.workos\.com/authorization/roles/stub/permissions(\?|\z)}, args: {slug: "stub", permissions: []}},
|
|
388
|
+
{name: :set_environment_role_permissions, verb: :put, url: %r{\Ahttps://api\.workos\.com/authorization/roles/stub/permissions(\?|\z)}, args: {slug: "stub", permissions: ["stub"]}},
|
|
307
389
|
{name: :list_permissions, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/permissions(\?|\z)}},
|
|
308
390
|
{name: :create_permission, verb: :post, url: %r{\Ahttps://api\.workos\.com/authorization/permissions(\?|\z)}, args: {slug: "stub", name: "stub"}},
|
|
309
391
|
{name: :get_permission, verb: :get, url: %r{\Ahttps://api\.workos\.com/authorization/permissions/stub(\?|\z)}, args: {slug: "stub"}},
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
# @oagen-ignore-file
|
|
4
4
|
require "test_helper"
|
|
5
5
|
require "base64"
|
|
6
|
+
require "json"
|
|
7
|
+
require "openssl"
|
|
8
|
+
require "securerandom"
|
|
6
9
|
|
|
7
10
|
class EncryptorsAesGcmTest < Minitest::Test
|
|
8
11
|
PASSWORD = "test-cookie-password-at-least-32"
|
|
@@ -51,4 +54,22 @@ class EncryptorsAesGcmTest < Minitest::Test
|
|
|
51
54
|
sealed2 = @enc.seal(data, PASSWORD)
|
|
52
55
|
refute_equal sealed1, sealed2
|
|
53
56
|
end
|
|
57
|
+
|
|
58
|
+
def test_unseal_reads_legacy_v6_payload
|
|
59
|
+
data = {"access_token" => "tok_abc", "refresh_token" => "ref_xyz"}
|
|
60
|
+
sealed = legacy_v6_seal(data, PASSWORD)
|
|
61
|
+
assert_equal data, @enc.unseal(sealed, PASSWORD)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def legacy_v6_seal(data, key)
|
|
67
|
+
cipher = OpenSSL::Cipher.new("aes-256-gcm").encrypt
|
|
68
|
+
iv = SecureRandom.random_bytes(12)
|
|
69
|
+
cipher.key = key
|
|
70
|
+
cipher.iv = iv
|
|
71
|
+
ciphertext = cipher.update(JSON.generate(data)) + cipher.final
|
|
72
|
+
|
|
73
|
+
Base64.encode64(iv + ciphertext + cipher.auth_tag)
|
|
74
|
+
end
|
|
54
75
|
end
|