Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#62107] Fix specs.

Pavel Balashou004a71bb0cf3
diff --git a/app/controllers/scim_v2/groups_controller.rb b/app/controllers/scim_v2/groups_controller.rb
index a48d765c141..95ec8584601 100644
--- a/app/controllers/scim_v2/groups_controller.rb
+++ b/app/controllers/scim_v2/groups_controller.rb
@@ -77,6 +77,7 @@ module ScimV2
.new(user: User.system, model: group)
.call
.on_failure { |call| raise call.message }
+ group.reload
group.to_scim(location: url_for(action: :show, id: group.id))
end
end
diff --git a/app/services/authentication/omniauth_service.rb b/app/services/authentication/omniauth_service.rb
index 5faf0209595..a59214962d9 100644
--- a/app/services/authentication/omniauth_service.rb
+++ b/app/services/authentication/omniauth_service.rb
@@ -168,7 +168,7 @@ module Authentication
if developer_provider?
User.find_by(mail: auth_hash[:uid])
else
- UserAuthProviderLink.with_identity_url(user_attributes[:identity_url]).first&.user
+ UserAuthProviderLink.with_identity_url(user_attributes[:identity_url]).first&.principal
end
end
diff --git a/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb b/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb
index 1088aa1c0c6..35ebbb5a130 100644
--- a/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb
+++ b/lib_static/open_project/authentication/strategies/warden/jwt_oidc.rb
@@ -30,7 +30,7 @@ module OpenProject
error_description: "Requires scope #{scope} to access this resource."
end
- user = provider.user_auth_provider_links.find_by(external_id: payload["sub"])&.user
+ user = provider.user_auth_provider_links.find_by(external_id: payload["sub"])&.principal
authentication_result(user)
end,
->(error) { fail_with_header!(error: "invalid_token", error_description: error) }
diff --git a/spec/controllers/omni_auth_login_controller_spec.rb b/spec/controllers/omni_auth_login_controller_spec.rb
index 5da888deb82..5f3628730f8 100644
--- a/spec/controllers/omni_auth_login_controller_spec.rb
+++ b/spec/controllers/omni_auth_login_controller_spec.rb
@@ -387,7 +387,7 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do
# The authorization is successful which results in the registration
# of a new user in this case because we changed the provider
# and there isn't a user with that identity URL yet.
- new_user = UserAuthProviderLink.with_identity_url("some other:123545").first.user
+ new_user = UserAuthProviderLink.with_identity_url("some other:123545").first.principal
expect(OpenProject::OmniAuth::Authorization)
.to have_received(:after_login!).with(new_user, any_args)
end
diff --git a/spec/requests/scim_v2/groups_spec.rb b/spec/requests/scim_v2/groups_spec.rb
index 885f6f37e04..effa2973a09 100644
--- a/spec/requests/scim_v2/groups_spec.rb
+++ b/spec/requests/scim_v2/groups_spec.rb
@@ -246,18 +246,18 @@ RSpec.describe "SCIM API Groups" do
response_body = JSON.parse(last_response.body)
group.reload
- expect(response_body).to eq({ "displayName" => group.name,
- "externalId" => new_external_group_id,
- "id" => group.id.to_s,
- "members" => [
- { "value" => user.id.to_s },
- { "value" => admin.id.to_s }
- ],
- "meta" => { "location" => "http://test.host/scim_v2/Groups/#{group.id}",
- "created" => group.created_at.iso8601,
- "lastModified" => group.updated_at.iso8601,
- "resourceType" => "Group" },
- "schemas" => ["urn:ietf:params:scim:schemas:core:2.0:Group"] })
+ expect(response_body).to match({ "displayName" => group.name,
+ "externalId" => new_external_group_id,
+ "id" => group.id.to_s,
+ "meta" => { "location" => "http://test.host/scim_v2/Groups/#{group.id}",
+ "created" => group.created_at.iso8601,
+ "lastModified" => group.updated_at.iso8601,
+ "resourceType" => "Group" },
+ "members" => match_array([
+ { "value" => user.id.to_s },
+ { "value" => admin.id.to_s }
+ ]),
+ "schemas" => ["urn:ietf:params:scim:schemas:core:2.0:Group"] })
end
end