Skip to content

Commit 381c2c8

Browse files
committed
Merge branch 'release/15.0' into dev
2 parents c9aabcb + 9097151 commit 381c2c8

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

Diff for: modules/auth_saml/app/components/saml/providers/sections/show_component.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
tag: :a,
3434
scheme: :invisible,
3535
href: edit_saml_provider_path(provider, edit_state: @target_state),
36+
test_selector: "saml_provider_#{@target_state}_edit",
3637
data: { turbo: true, turbo_stream: true },
3738
aria: { label: I18n.t(disabled ? :label_show : :label_edit) }
3839
)

Diff for: modules/auth_saml/app/controllers/saml/providers_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def update
9292
successful_save_response
9393
else
9494
@provider = call.result
95-
render action: :edit
95+
render action: :edit, status: :unprocessable_entity
9696
end
9797
end
9898

@@ -178,7 +178,7 @@ def create_params
178178
def update_params
179179
params
180180
.require(:saml_provider)
181-
.permit(:display_name, *Saml::Provider.stored_attributes[:options])
181+
.permit(:display_name, :limit_self_registration, *Saml::Provider.stored_attributes[:options])
182182
end
183183

184184
def find_provider

Diff for: modules/auth_saml/app/services/saml/configuration_mapper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def call!
3939
{
4040
"options" => options,
4141
"slug" => options.delete("name"),
42+
"limit_self_registration" => ActiveModel::Type::Boolean.new.cast(options.delete("limit_self_registration")),
4243
"display_name" => options.delete("display_name") || "SAML"
43-
}
44+
}.compact
4445
end
4546

4647
private

Diff for: modules/auth_saml/spec/features/administration/saml_crud_spec.rb

+20-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
fill_in "Identity provider login endpoint", with: "https://example.com/sso"
5858
fill_in "Identity provider logout endpoint", with: "https://example.com/slo"
5959
fill_in "Public certificate of identity provider", with: CertificateHelper.valid_certificate.to_pem
60+
check "Limit self registration"
6061

6162
click_link_or_button "Continue"
6263

@@ -68,11 +69,11 @@
6869
click_link_or_button "Continue"
6970

7071
# Mapping form
71-
fill_in "Mapping for: Username", with: "login\nmail", fill_options: { clear: :backspace }
72-
fill_in "Mapping for: Email", with: "mail", fill_options: { clear: :backspace }
73-
fill_in "Mapping for: First name", with: "myName", fill_options: { clear: :backspace }
74-
fill_in "Mapping for: Last name", with: "myLastName", fill_options: { clear: :backspace }
75-
fill_in "Mapping for: Internal user id", with: "uid", fill_options: { clear: :backspace }
72+
fill_in "Mapping for: Username", with: "login\nmail"
73+
fill_in "Mapping for: Email", with: "mail"
74+
fill_in "Mapping for: First name", with: "myName"
75+
fill_in "Mapping for: Last name", with: "myLastName"
76+
fill_in "Mapping for: Internal user id", with: "uid"
7677

7778
click_link_or_button "Continue"
7879

@@ -105,6 +106,7 @@
105106
expect(provider.mapping_lastname).to eq "myLastName"
106107
expect(provider.mapping_uid).to eq "uid"
107108
expect(provider.authn_requests_signed).to be true
109+
expect(provider.limit_self_registration).to be true
108110

109111
click_link_or_button "Delete"
110112
# Confirm the deletion
@@ -175,6 +177,19 @@
175177

176178
expect(page).to have_text "Display name has already been taken."
177179
end
180+
181+
it "can toggle limit_self_registration (Regression #59370)" do
182+
visit "/admin/saml/providers"
183+
click_link_or_button "My provider"
184+
185+
page.find_test_selector("saml_provider_configuration_edit").click
186+
check "Limit self registration"
187+
click_link_or_button "Update"
188+
wait_for_network_idle
189+
190+
provider.reload
191+
expect(provider.limit_self_registration).to be true
192+
end
178193
end
179194
end
180195

Diff for: modules/auth_saml/spec/services/saml/configuration_mapper_spec.rb

+28
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@
5050
end
5151
end
5252

53+
describe "limit_self_registration" do
54+
subject { result["limit_self_registration"] }
55+
56+
context "when provided as string" do
57+
let(:configuration) { { limit_self_registration: "1" } }
58+
59+
it { is_expected.to be(true) }
60+
end
61+
62+
context "when provided as false boolean" do
63+
let(:configuration) { { limit_self_registration: false } }
64+
65+
it { is_expected.to be(false) }
66+
end
67+
68+
context "when provided as true boolean" do
69+
let(:configuration) { { limit_self_registration: true } }
70+
71+
it { is_expected.to be(true) }
72+
end
73+
74+
context "when not provided" do
75+
let(:configuration) { {} }
76+
77+
it { is_expected.to be_nil }
78+
end
79+
end
80+
5381
describe "slug" do
5482
subject { result["slug"] }
5583

0 commit comments

Comments
 (0)