From 13bfb3bc4d431edb5cadb2bedce37d83ef283808 Mon Sep 17 00:00:00 2001 From: Ryan Wold <64987852+ryanwoldatwork@users.noreply.github.com> Date: Thu, 8 Jun 2023 13:30:15 -0700 Subject: [PATCH] Support 10 whitelist urls * update conditional options on Service form --- app/controllers/admin/forms_controller.rb | 9 + app/controllers/submissions_controller.rb | 13 +- app/serializers/form_serializer.rb | 9 + app/serializers/full_form_serializer.rb | 9 + app/views/admin/services/_form.html.erb | 14 +- .../components/_whitelist_options.html.erb | 45 ++ .../20230608193911_add_form_whitelist_urls.rb | 13 + db/schema.rb | 11 +- public/api/v0/openapi.yml | 18 + public/api/v1/openapi.yml | 483 +++++++++--------- spec/features/admin/forms_spec.rb | 13 + spec/fixtures/form.json | 9 + spec/fixtures/forms.json | 9 + 13 files changed, 412 insertions(+), 243 deletions(-) create mode 100644 db/migrate/20230608193911_add_form_whitelist_urls.rb diff --git a/app/controllers/admin/forms_controller.rb b/app/controllers/admin/forms_controller.rb index 0b9c6b4bc..79afc7dd5 100644 --- a/app/controllers/admin/forms_controller.rb +++ b/app/controllers/admin/forms_controller.rb @@ -437,6 +437,15 @@ def form_params :display_header_logo, :display_header_square_logo, :whitelist_url, + :whitelist_url_1, + :whitelist_url_2, + :whitelist_url_3, + :whitelist_url_4, + :whitelist_url_5, + :whitelist_url_6, + :whitelist_url_7, + :whitelist_url_8, + :whitelist_url_9, :whitelist_test_url, :disclaimer_text, :success_text, diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index dcbef51b7..eb44f3ef4 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -30,11 +30,20 @@ def create head :ok and return end - # Prevent the Submission if this is a published Form and if: + # Prevent the Submission if this is a published Form and if the form: if @form && request.referer && - # is not from the Form's whitelist URL + # is not from the Form's whitelist URLs (@form.whitelist_url.present? ? !request.referer.start_with?(@form.whitelist_url) : true) && + (@form.whitelist_url_1.present? ? !request.referer.start_with?(@form.whitelist_url_1) : true) && + (@form.whitelist_url_2.present? ? !request.referer.start_with?(@form.whitelist_url_2) : true) && + (@form.whitelist_url_3.present? ? !request.referer.start_with?(@form.whitelist_url_3) : true) && + (@form.whitelist_url_4.present? ? !request.referer.start_with?(@form.whitelist_url_4) : true) && + (@form.whitelist_url_5.present? ? !request.referer.start_with?(@form.whitelist_url_5) : true) && + (@form.whitelist_url_6.present? ? !request.referer.start_with?(@form.whitelist_url_6) : true) && + (@form.whitelist_url_7.present? ? !request.referer.start_with?(@form.whitelist_url_7) : true) && + (@form.whitelist_url_8.present? ? !request.referer.start_with?(@form.whitelist_url_8) : true) && + (@form.whitelist_url_9.present? ? !request.referer.start_with?(@form.whitelist_url_9) : true) && # is not from the Form's test whitelist URL (@form.whitelist_test_url.present? ? !request.referer.start_with?(@form.whitelist_test_url) : true) && # is not from the Touchpoints app diff --git a/app/serializers/form_serializer.rb b/app/serializers/form_serializer.rb index eb6f3b880..54f8bc095 100644 --- a/app/serializers/form_serializer.rb +++ b/app/serializers/form_serializer.rb @@ -12,6 +12,15 @@ class FormSerializer < ActiveModel::Serializer :created_at, :updated_at, :whitelist_url, + :whitelist_url_1, + :whitelist_url_2, + :whitelist_url_3, + :whitelist_url_4, + :whitelist_url_5, + :whitelist_url_6, + :whitelist_url_7, + :whitelist_url_8, + :whitelist_url_9, :whitelist_test_url, :display_header_logo, :success_text_heading, diff --git a/app/serializers/full_form_serializer.rb b/app/serializers/full_form_serializer.rb index d7ac83cc5..d41a5c89a 100644 --- a/app/serializers/full_form_serializer.rb +++ b/app/serializers/full_form_serializer.rb @@ -34,6 +34,15 @@ def links :created_at, :updated_at, :whitelist_url, + :whitelist_url_1, + :whitelist_url_2, + :whitelist_url_3, + :whitelist_url_4, + :whitelist_url_5, + :whitelist_url_6, + :whitelist_url_7, + :whitelist_url_8, + :whitelist_url_9, :whitelist_test_url, :display_header_logo, :success_text_heading, diff --git a/app/views/admin/services/_form.html.erb b/app/views/admin/services/_form.html.erb index 54170a126..c555ab059 100644 --- a/app/views/admin/services/_form.html.erb +++ b/app/views/admin/services/_form.html.erb @@ -19,7 +19,7 @@
This is the official National Park Service app for the National Mall and Memorial Parks. On your next visit to Washington, D.C., use it to explore many of the most cherished cultural and historical sites in the United States—from the Lincoln Memorial to the White House. The app includes a total of 70 sites.
Features:
Map – Official National Park Service map of the central tourist area in Washington, D.C. Easy to use while outdoors, the map features large font sizes, walkways that are easily distinguishable from roads, and three zoom levels. By tapping the “Locate me” icon you will always know where you are.
Park Lens – Find out what is around you with augmented reality. Just hold up your device and look through the camera. Labels will appear identifying all sites on the National Mall.
Walking directions – Get from one place to another by following a line on the map or a list of directions. Estimated walking times are given.
Sites – Learn more about points of interest with lively text, professional photographs, and engaging podcasts under the “Album” button. The “Info” button includes the site’s location, hours of operation, nearest Metro station, and other essential information.
Tours – Follow a recommended tour depending on how much time you have or your special interest—from memorials to presidents to military monuments to destinations off the beaten path. You can even create personal tours with the “My Tour” feature—just tap the “+” at the bottom right of a site page. The app maps the route for you.
Events and News – Get up-to-date information from the National Park Service about what is happening at the National Mall and Memorial Parks.
Postcard – Send a digital postcard to friends and family from the National Mall with the tap of a button.
Accessibility – Audio described images combined with the built-in iOS accessibility features will let all people enjoy the National Mall and Memorial Parks.
Park Partner – The Trust for the National Mall strives to make the National Mall the best park in the world. Learn more about the essential assistance this organization provides.
Small size – Weighing in at 13.7MB, the app will download relatively quickly via a 3G cellular connection or the free Wi-Fi available on the east end the National Mall.
" - tags: + tags: type: "array" - items: + items: $ref: '#/components/schemas/Tag' example: [] - links: - required: + links: + required: - "first" - "last" - properties: - first: + properties: + first: type: "string" example: "https://touchpoints.app.cloud.gov/api/v1/digital_products.json?API_KEY=1234&page=1" - last: + last: type: "string" example: "https://touchpoints.app.cloud.gov/api/v1/digital_products.json?API_KEY=1234&page=9" type: "object" - meta: - required: + meta: + required: - "size" - "page" - "totalPages" - properties: - size: + properties: + size: type: "number" example: 100 - page: + page: type: "number" example: 0 - totalPages: + totalPages: type: "number" example: 1 type: "object" @@ -830,30 +839,30 @@ $ref: '#/components/schemas/DigitalProduct' DigitalServiceAccount: type: object - properties: - name: + properties: + name: type: "string" - account: + account: type: "string" - status: + status: type: "string" agencies: type: array items: $ref: '#/components/schemas/Organization' - contacts: + contacts: type: "array" items: $ref: '#/components/schemas/PublicUser' - service_url: + service_url: type: "string" - short_description: + short_description: type: "string" - long_description: + long_description: type: "string" - tags: + tags: type: "array" - items: + items: type: "string" DigitalServiceAccounts: type: object @@ -863,16 +872,16 @@ items: $ref: '#/components/schemas/DigitalServiceAccount' Error: - required: + required: - "error" - properties: - error: - required: + properties: + error: + required: - "code" - "message" - properties: - code: + properties: + code: type: "string" - message: + message: type: "string" type: "object" diff --git a/spec/features/admin/forms_spec.rb b/spec/features/admin/forms_spec.rb index 4e82e8c72..0503a9971 100644 --- a/spec/features/admin/forms_spec.rb +++ b/spec/features/admin/forms_spec.rb @@ -493,6 +493,19 @@ end end + describe 'editing the whitelist url 3' do + before do + fill_in 'form_whitelist_url_3', with: 'https://example.com' + click_on 'Update Form' + end + + it 'can edit existing Form' do + expect(page).to have_content('Form was successfully updated.') + expect(page.current_path).to eq(delivery_admin_form_path(form)) + expect(find('#form_whitelist_url_3').value).to eq('https://example.com') + end + end + describe 'editing the delivery method' do before do find('label', text: 'Custom button & modal').click diff --git a/spec/fixtures/form.json b/spec/fixtures/form.json index 68c6a0f44..723dfee9d 100644 --- a/spec/fixtures/form.json +++ b/spec/fixtures/form.json @@ -13,6 +13,15 @@ "created_at": "2021-01-28T21:33:59.490Z", "updated_at": "2021-01-28T21:34:01.194Z", "whitelist_url": "", + "whitelist_url_1": "", + "whitelist_url_2": "", + "whitelist_url_3": "", + "whitelist_url_4": "", + "whitelist_url_5": "", + "whitelist_url_6": "", + "whitelist_url_7": "", + "whitelist_url_8": "", + "whitelist_url_9": "", "whitelist_test_url": "", "display_header_logo": false, "success_text": null, diff --git a/spec/fixtures/forms.json b/spec/fixtures/forms.json index e7a23a5f3..2c16d3a5c 100644 --- a/spec/fixtures/forms.json +++ b/spec/fixtures/forms.json @@ -13,6 +13,15 @@ "created_at": "2021-01-28T21:33:59.490Z", "updated_at": "2021-01-28T21:34:01.194Z", "whitelist_url": "", + "whitelist_url_1": "", + "whitelist_url_2": "", + "whitelist_url_3": "", + "whitelist_url_4": "", + "whitelist_url_5": "", + "whitelist_url_6": "", + "whitelist_url_7": "", + "whitelist_url_8": "", + "whitelist_url_9": "", "whitelist_test_url": "", "display_header_logo": false, "success_text": null,