Add exclusion to AASA supported paths (#14593)

* Add exclution to AASA supported paths

* Fix specs and extract supported paths in constant
This commit is contained in:
Fernando Valverde 2021-08-26 10:17:39 -06:00 committed by GitHub
parent ff008e4702
commit 015a9c1923
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -1,4 +1,6 @@
class DeepLinksController < ApplicationController
AASA_PATHS = ["/*", "NOT /users/auth/*"].freeze
def mobile; end
# Apple Application Site Association - based on Apple docs guidelines
@ -19,7 +21,7 @@ class DeepLinksController < ApplicationController
render json: {
applinks: {
apps: [],
details: supported_apps.map { |app_id| { appID: app_id, paths: ["/*"] } }
details: supported_apps.map { |app_id| { appID: app_id, paths: AASA_PATHS } }
},
activitycontinuation: {
apps: supported_apps

View file

@ -3,6 +3,7 @@ require "rails_helper"
RSpec.describe "Universal Links (Apple)", type: :request do
let(:aasa_route) { "/.well-known/apple-app-site-association" }
let(:forem_app_id) { "R9SWHSQNV8.com.forem.app" }
let(:expected_paths) { ["/*", "NOT /users/auth/*"] }
describe "returns a valid Apple App Site Association file" do
context "with multiple ConsumerApps" do
@ -20,7 +21,7 @@ RSpec.describe "Universal Links (Apple)", type: :request do
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(both_app_ids).to include(hash["appID"])
expect(hash["paths"]).to match_array(["/*"])
expect(hash["paths"]).to match_array(expected_paths)
end
end
end
@ -34,7 +35,7 @@ RSpec.describe "Universal Links (Apple)", type: :request do
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(hash["appID"]).to eq(forem_app_id)
expect(hash["paths"]).to match_array(["/*"])
expect(hash["paths"]).to match_array(expected_paths)
end
end
end
@ -49,7 +50,7 @@ RSpec.describe "Universal Links (Apple)", type: :request do
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(hash["appID"]).to eq(forem_app_id)
expect(hash["paths"]).to match_array(["/*"])
expect(hash["paths"]).to match_array(expected_paths)
end
end
end