|
10 | 10 | expect(response).to render_template(:new) |
11 | 11 | expect(Capybara.string(response.body)).to have_css("[data-controller='ui--forms--email'] input#user_email") |
12 | 12 | end |
| 13 | + |
| 14 | + context "sso organization domain" do |
| 15 | + let!(:organization) do |
| 16 | + FactoryBot.create(:organization_with_organization_features, |
| 17 | + enabled_feature_slugs: ["saml_sso"], user_email_domain: "sso.edu") |
| 18 | + end |
| 19 | + let!(:saml_configuration) { FactoryBot.create(:organization_saml_configuration, :enabled, organization:) } |
| 20 | + |
| 21 | + it "hands the prefilled email off to the IdP rather than the signup form" do |
| 22 | + get "#{base_url}/new", params: {email: "student@sso.edu"} |
| 23 | + expect(response).to redirect_to(saml_init_path(org_slug: organization.to_param)) |
| 24 | + end |
| 25 | + |
| 26 | + it "renders for an email the org doesn't claim" do |
| 27 | + get "#{base_url}/new", params: {email: "student@example.edu"} |
| 28 | + expect(response).to render_template(:new) |
| 29 | + end |
| 30 | + end |
13 | 31 | end |
14 | 32 |
|
15 | 33 | describe "create" do |
|
49 | 67 | expect(response).to redirect_to "https://parkit.bikehub.com/account?reauthenticate_bike_index=true" |
50 | 68 | end |
51 | 69 | end |
| 70 | + |
| 71 | + context "sso organization domain" do |
| 72 | + let(:email) { "student@sso.edu" } |
| 73 | + let!(:organization) do |
| 74 | + FactoryBot.create(:organization_with_organization_features, |
| 75 | + enabled_feature_slugs: ["saml_sso"], user_email_domain: "sso.edu") |
| 76 | + end |
| 77 | + let!(:saml_configuration) { FactoryBot.create(:organization_saml_configuration, :enabled, organization:) } |
| 78 | + |
| 79 | + it "forces SSO instead of creating an account the IdP doesn't know about" do |
| 80 | + expect { |
| 81 | + post base_url, params: {user: {email:, name: "Test name", terms_of_service: "1"}} |
| 82 | + }.to_not change(User, :count) |
| 83 | + expect(response).to redirect_to(saml_init_path(org_slug: organization.to_param)) |
| 84 | + end |
| 85 | + |
| 86 | + context "SAML config not yet live" do |
| 87 | + let(:saml_configuration) { FactoryBot.create(:organization_saml_configuration, organization:) } |
| 88 | + |
| 89 | + it "signs up normally rather than redirecting into an unconfigured IdP" do |
| 90 | + expect { |
| 91 | + post base_url, params: {user: {email:, name: "Test name", terms_of_service: "1"}} |
| 92 | + }.to change(User, :count).by(1) |
| 93 | + end |
| 94 | + end |
| 95 | + end |
52 | 96 | end |
53 | 97 |
|
54 | 98 | describe "create with a null origin" do |
|
0 commit comments