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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Feature spec
Oliver Günther005c949b9838
diff --git a/frontend/src/stimulus/setup.ts b/frontend/src/stimulus/setup.tsindex eb160bfe694..e1789326e07 100644--- a/frontend/src/stimulus/setup.ts+++ b/frontend/src/stimulus/setup.ts@@ -8,8 +8,8 @@ import RefreshOnFormChangesController from './controllers/refresh-on-form-changeimport AsyncDialogController from './controllers/async-dialog.controller';import PollForChangesController from './controllers/poll-for-changes.controller';import TableHighlightingController from './controllers/table-highlighting.controller';-import OpShowWhenCheckedController from "./controllers/show-when-checked.controller";-import OpShowWhenValueSelectedController from "./controllers/show-when-value-selected.controller";+import OpShowWhenCheckedController from './controllers/show-when-checked.controller';+import OpShowWhenValueSelectedController from './controllers/show-when-value-selected.controller';declare global {interface Window {diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erbindex 0e6ef653deb..aeb532f046b 100644--- a/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_form_component.html.erb@@ -48,6 +48,7 @@form,provider:,submit_button_options: { label: button_label },+ cancel_button_options: { hidden: edit_mode },state: :metadata))endenddiff --git a/modules/auth_saml/app/components/saml/providers/sections/show_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/show_component.html.erbindex ceb8ae5e22f..f2777b1de59 100644--- a/modules/auth_saml/app/components/saml/providers/sections/show_component.html.erb+++ b/modules/auth_saml/app/components/saml/providers/sections/show_component.html.erb@@ -1,5 +1,8 @@<%=- grid_layout('op-saml-view-row', tag: :div, align_items: :center) do |grid|+ grid_layout('op-saml-view-row',+ tag: :div,+ test_selector: "saml_provider_#{@target_state}",+ align_items: :center) do |grid|grid.with_area(:title, mr: 3) doconcat render(Primer::Beta::Text.new(font_weight: :bold)) { @heading }if @labeldiff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rbindex 0429fe71250..15889b734b0 100644--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb@@ -152,6 +152,12 @@ module Samlendend+ def default_breadcrumb; end++ def show_local_breadcrumb+ false+ end+def update_provider_metadata_callSaml::Providers::UpdateService.new(model: @provider, user: User.current)diff --git a/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb b/modules/auth_saml/app/services/saml/providers/set_attributes_service.rbindex 322072a72ba..180c3e61c8d 100644--- a/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb+++ b/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb@@ -95,12 +95,7 @@ module Samlenddef update_idp_cert(cert)- model.idp_cert =- if cert.include?("BEGIN CERTIFICATE")- cert- else- OneLogin::RubySaml::Utils.format_cert(cert)- end+ model.idp_cert = certenddef update_certificate(cert)diff --git a/modules/auth_saml/spec/factories/saml_provider_factory.rb b/modules/auth_saml/spec/factories/saml_provider_factory.rbindex 848da24df12..4b9e5d4be6c 100644--- a/modules/auth_saml/spec/factories/saml_provider_factory.rb+++ b/modules/auth_saml/spec/factories/saml_provider_factory.rb@@ -31,6 +31,7 @@ require_relative "../support/certificate_helper"FactoryBot.define dofactory(:saml_provider, class: "Saml::Provider") dosequence(:display_name) { |n| "Saml Provider #{n}" }+ sequence(:slug) { |n| "saml-#{n}" }creator factory: :useravailable { true }diff --git a/modules/auth_saml/spec/features/administration/saml_crud_spec.rb b/modules/auth_saml/spec/features/administration/saml_crud_spec.rbnew file mode 100644index 00000000000..8ab02e14eda--- /dev/null+++ b/modules/auth_saml/spec/features/administration/saml_crud_spec.rb@@ -0,0 +1,177 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"+require_module_spec_helper++RSpec.describe "SAML administration CRUD",+ :js,+ :with_cuprite do+ shared_let(:user) { create(:admin) }++ before do+ login_as(user)+ end++ context "with EE", with_ee: %i[sso_auth_providers] do+ it "can manage SAML providers through the UI" do+ visit "/admin/saml/providers"+ expect(page).to have_text "No SAML providers configured yet."+ click_link_or_button "SAML identity provider"++ fill_in "Name", with: "My provider"+ click_link_or_button "Continue"++ expect(page).to have_css("h1", text: "My provider")++ # Skip metadata+ click_link_or_button "Continue"++ # Fill out configuration+ fill_in "Identity provider login endpoint", with: "https://example.com/sso"+ fill_in "Identity provider logout endpoint", with: "https://example.com/slo"+ fill_in "Public certificate of identity provider", with: CertificateHelper.valid_certificate.to_pem++ click_link_or_button "Continue"++ # Encryption form+ check "Sign SAML AuthnRequests"+ fill_in "Certificate used by OpenProject for SAML requests", with: CertificateHelper.valid_certificate.to_pem+ fill_in "Corresponding private key for OpenProject SAML requests", with: CertificateHelper.private_key.private_to_pem++ click_link_or_button "Continue"++ # Mapping form+ fill_in "Mapping for: Username", with: "login\nmail", fill_options: { clear: :backspace }+ fill_in "Mapping for: Email", with: "mail", fill_options: { clear: :backspace }+ fill_in "Mapping for: First name", with: "myName", fill_options: { clear: :backspace }+ fill_in "Mapping for: Last name", with: "myLastName", fill_options: { clear: :backspace }+ fill_in "Mapping for: Internal user id", with: "uid", fill_options: { clear: :backspace }++ click_link_or_button "Continue"++ # Skip requested attributes form+ click_link_or_button "Finish setup"++ # We're now on the show page+ within_test_selector("saml_provider_metadata") do+ expect(page).to have_text "Not configured"+ end++ within_test_selector("saml_provider_mapping") do+ expect(page).to have_text "Completed"+ end++ # Back to index+ visit "/admin/saml/providers"+ expect(page).to have_text "My provider"+ expect(page).to have_css(".users", text: 0)+ expect(page).to have_css(".creator", text: user.name)++ click_link_or_button "My provider"++ provider = Saml::Provider.find_by!(display_name: "My provider")+ expect(provider.slug).to eq "saml-my-provider"+ expect(provider.idp_cert.strip.gsub("\r\n", "\n")).to eq CertificateHelper.valid_certificate.to_pem.strip+ expect(provider.certificate.strip.gsub("\r\n", "\n")).to eq CertificateHelper.valid_certificate.to_pem.strip+ expect(provider.private_key.strip.gsub("\r\n", "\n")).to eq CertificateHelper.private_key.private_to_pem.strip+ expect(provider.idp_sso_service_url).to eq "https://example.com/sso"+ expect(provider.idp_slo_service_url).to eq "https://example.com/slo"+ expect(provider.mapping_login).to eq "login\nmail"+ expect(provider.mapping_mail).to eq "mail"+ expect(provider.mapping_firstname).to eq "myName"+ expect(provider.mapping_lastname).to eq "myLastName"+ expect(provider.mapping_uid).to eq "uid"+ expect(provider.authn_requests_signed).to be true++ accept_confirm do+ click_link_or_button "Delete"+ end++ expect(page).to have_text "No SAML providers configured yet."+ end++ it "can import metadata from XML" do+ visit "/admin/saml/providers/new"+ fill_in "Name", with: "My provider"+ click_link_or_button "Continue"++ choose "Metadata XML"++ metadata = Rails.root.join("modules/auth_saml/spec/fixtures/idp_metadata.xml").read+ fill_in "saml_provider_metadata_xml", with: metadata++ click_link_or_button "Continue"+ expect(page).to have_text "This information has been pre-filled using the supplied metadata."+ expect(page).to have_field "Service entity ID", with: "http://#{Setting.host_name}/"+ expect(page).to have_field "Identity provider login endpoint", with: "https://example.com/login"+ expect(page).to have_field "Identity provider logout endpoint", with: "https://example.com/logout"+ end++ it "can import metadata from URL", :webmock do+ visit "/admin/saml/providers/new"+ fill_in "Name", with: "My provider"+ click_link_or_button "Continue"++ url = "https://example.com/metadata"+ metadata = Rails.root.join("modules/auth_saml/spec/fixtures/idp_metadata.xml").read+ stub_request(:get, url).to_return(status: 200, body: metadata)++ choose "Metadata URL"++ fill_in "saml_provider_metadata_url", with: url++ click_link_or_button "Continue"+ expect(page).to have_text "This information has been pre-filled using the supplied metadata."+ expect(page).to have_field "Service entity ID", with: "http://#{Setting.host_name}/"+ expect(page).to have_field "Identity provider login endpoint", with: "https://example.com/login"+ expect(page).to have_field "Identity provider logout endpoint", with: "https://example.com/logout"++ expect(WebMock).to have_requested(:get, url)+ end++ context "when provider exists already" do+ let!(:provider) { create(:saml_provider, display_name: "My provider") }++ it "shows an error trying to use the same name" do+ visit "/admin/saml/providers/new"+ fill_in "Name", with: "My provider"+ click_link_or_button "Continue"++ expect(page).to have_text "Display name has already been taken."+ end+ end+ end++ context "without EE", without_ee: %i[sso_auth_providers] do+ it "renders the upsale page" do+ visit "/admin/saml/providers"+ expect(page).to have_text "SAML identity providers is an Enterprise add-on"+ end+ end+enddiff --git a/modules/auth_saml/spec/fixtures/idp_metadata.xml b/modules/auth_saml/spec/fixtures/idp_metadata.xmlnew file mode 100644index 00000000000..9ccda10771d--- /dev/null+++ b/modules/auth_saml/spec/fixtures/idp_metadata.xml@@ -0,0 +1,23 @@+<EntityDescriptor entityID="urn:dev-example.com" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">+ <IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">+ <KeyDescriptor use="signing">+ <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">+ <X509Data>+ <X509Certificate>MIIDHTCCAgWgAwIB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KeyInfo>+ </KeyDescriptor>+ <SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://example.com/logout"/>+ <SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://example.com/logout"/>+ <NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>+ <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</NameIDFormat>+ <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</NameIDFormat>+ <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://example.com/login"/>+ <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://example.com/login"/>+ <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="E-Mail Address" xmlns="urn:oasis:names:tc:SAML:2.0:assertion"/>+ <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="Given Name" xmlns="urn:oasis:names:tc:SAML:2.0:assertion"/>+ <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="Name" xmlns="urn:oasis:names:tc:SAML:2.0:assertion"/>+ <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="Surname" xmlns="urn:oasis:names:tc:SAML:2.0:assertion"/>+ <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="Name ID" xmlns="urn:oasis:names:tc:SAML:2.0:assertion"/>+ </IDPSSODescriptor>+</EntityDescriptor>diff --git a/modules/auth_saml/spec/support/certificate_helper.rb b/modules/auth_saml/spec/support/certificate_helper.rbindex 1574c8e5cdb..8fcc4aa1daf 100644--- a/modules/auth_saml/spec/support/certificate_helper.rb+++ b/modules/auth_saml/spec/support/certificate_helper.rb@@ -12,8 +12,8 @@ module CertificateHelpercert.version = 2cert.serial = 1234- cert.not_before = Time.now- cert.not_after = Time.now + 606024364.251+ cert.not_before = Time.current+ cert.not_after = Time.current + 606024364.251cert.public_key = private_key.public_keycert.subject = namecert.issuer = name@@ -28,8 +28,8 @@ module CertificateHelpercert.version = 2cert.serial = 1234- cert.not_before = Time.now - 2.years- cert.not_after = Time.now - 30.days+ cert.not_before = 2.years.ago+ cert.not_after = 30.days.agocert.public_key = private_key.public_keycert.subject = namecert.issuer = name@@ -45,8 +45,8 @@ module CertificateHelpercert.serial = 1234key = OpenSSL::PKey::RSA.new(1024)- cert.not_before = Time.now- cert.not_after = Time.now + 606024364.251+ cert.not_before = Time.current+ cert.not_after = Time.current + 606024364.251cert.public_key = key.public_keycert.subject = namecert.issuer = name