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

Add specs that UI is disabled with ENV

Oliver Günther9400b52ed448
diff --git a/modules/ldap_groups/spec/features/filter_administration_spec.rb b/modules/ldap_groups/spec/features/filter_administration_spec.rb
new file mode 100644
index 00000000000..e5022d4d8db
--- /dev/null
+++ b/modules/ldap_groups/spec/features/filter_administration_spec.rb
@@ -0,0 +1,48 @@
+require_relative '../spec_helper'
+
+RSpec.describe 'LDAP group filter administration spec', js: true do
+ let(:admin) { create(:admin) }
+
+ before do
+ login_as admin
+ end
+
+ context 'with EE', with_ee: %i[ldap_groups] do
+ context 'when providing seed variables',
+ :settings_reset,
+ with_env: {
+ OPENPROJECT_SEED_LDAP_FOO_HOST: "localhost",
+ OPENPROJECT_SEED_LDAP_FOO_PORT: "12389",
+ OPENPROJECT_SEED_LDAP_FOO_SECURITY: "plain_ldap",
+ OPENPROJECT_SEED_LDAP_FOO_TLSVERIFY: "false",
+ OPENPROJECT_SEED_LDAP_FOO_BINDUSER: "uid=admin,ou=system",
+ OPENPROJECT_SEED_LDAP_FOO_BINDPASSWORD: "secret",
+ OPENPROJECT_SEED_LDAP_FOO_BASEDN: "dc=example,dc=com",
+ OPENPROJECT_SEED_LDAP_FOO_FILTER: "(uid=*)",
+ OPENPROJECT_SEED_LDAP_FOO_SYNC__USERS: "true",
+ OPENPROJECT_SEED_LDAP_FOO_LOGIN__MAPPING: "uid",
+ OPENPROJECT_SEED_LDAP_FOO_FIRSTNAME__MAPPING: "givenName",
+ OPENPROJECT_SEED_LDAP_FOO_LASTNAME__MAPPING: "sn",
+ OPENPROJECT_SEED_LDAP_FOO_MAIL__MAPPING: "mail",
+ OPENPROJECT_SEED_LDAP_FOO_ADMIN__MAPPING: "",
+ OPENPROJECT_SEED_LDAP_FOO_GROUPFILTER_BAR_BASE: "ou=groups,dc=example,dc=com",
+ OPENPROJECT_SEED_LDAP_FOO_GROUPFILTER_BAR_FILTER: "(cn=*)",
+ OPENPROJECT_SEED_LDAP_FOO_GROUPFILTER_BAR_SYNC__USERS: "true",
+ OPENPROJECT_SEED_LDAP_FOO_GROUPFILTER_BAR_GROUP__ATTRIBUTE: "dn"
+ } do
+ it 'blocks editing of the filter' do
+ reset(:seed_ldap)
+ allow(LdapGroups::SynchronizationJob).to receive(:perform_now)
+ EnvData::LdapSeeder.new({}).seed_data!
+
+ visit ldap_groups_synchronized_groups_path
+ expect(page).to have_text 'bar'
+ page.find('td.name a', text: 'bar').click
+
+ expect(page).to have_text I18n.t(:label_seeded_from_env_warning)
+ expect(page).not_to have_link 'Edit'
+ expect(page).not_to have_link 'Delete'
+ end
+ end
+ end
+end
diff --git a/spec/features/ldap_auth_sources/crud_spec.rb b/spec/features/ldap_auth_sources/crud_spec.rb
index 3c1125456ab..f5ca3d7ac61 100644
--- a/spec/features/ldap_auth_sources/crud_spec.rb
+++ b/spec/features/ldap_auth_sources/crud_spec.rb
@@ -95,4 +95,27 @@ RSpec.describe 'CRUD LDAP connections',
ldap_page.expect_and_dismiss_toaster message: 'Successful update.'
expect(page).to have_selector('td.name', text: 'Updated Admin connection')
end
+
+ context 'when providing seed variables',
+ :settings_reset,
+ with_env: {
+ OPENPROJECT_SEED_LDAP_FOOBAR_HOST: "localhost"
+ } do
+ let!(:ldap_auth_source) { create(:ldap_auth_source, name: 'foobar') }
+
+ it 'blocks editing of that connection by name' do
+ reset(:seed_ldap)
+
+ ldap_page.visit!
+ expect(page).to have_text 'foobar'
+
+ page.within("#ldap-auth-source-#{ldap_auth_source.id}") do
+ click_on 'foobar'
+ end
+
+ expect(page).to have_text(I18n.t(:label_seeded_from_env_warning))
+ expect(page).to have_field('ldap_auth_source_name', with: 'foobar', disabled: true)
+ expect(page).not_to have_button 'Save'
+ end
+ end
end