2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe EmbedController do
|
2014-01-01 03:37:43 +08:00
|
|
|
let(:embed_url) { "http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
|
2018-01-05 02:13:17 +08:00
|
|
|
let(:embed_url_secure) { "https://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html" }
|
2016-02-25 19:16:27 +08:00
|
|
|
let(:discourse_username) { "eviltrout" }
|
2014-01-01 03:37:43 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
fab!(:topic) { Fabricate(:topic) }
|
2015-06-10 04:24:04 +08:00
|
|
|
|
2022-07-27 18:21:10 +08:00
|
|
|
describe "#info" do
|
2015-05-06 09:00:31 +08:00
|
|
|
context "without api key" do
|
|
|
|
it "fails" do
|
2017-08-31 12:06:56 +08:00
|
|
|
get "/embed/info.json"
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
expect(response.body).to match(I18n.t("embed.error"))
|
2015-05-06 09:00:31 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with api key" do
|
2019-11-05 22:10:23 +08:00
|
|
|
let(:api_key) { Fabricate(:api_key) }
|
2015-05-06 09:00:31 +08:00
|
|
|
|
|
|
|
context "with valid embed url" do
|
|
|
|
let(:topic_embed) { Fabricate(:topic_embed, embed_url: embed_url) }
|
|
|
|
|
|
|
|
it "returns information about the topic" do
|
2017-08-31 12:06:56 +08:00
|
|
|
get "/embed/info.json",
|
2020-04-07 06:55:44 +08:00
|
|
|
params: {
|
|
|
|
embed_url: topic_embed.embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
HTTP_API_KEY: api_key.key,
|
|
|
|
HTTP_API_USERNAME: "system",
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.parsed_body["topic_id"]).to eq(topic_embed.topic.id)
|
|
|
|
expect(response.parsed_body["post_id"]).to eq(topic_embed.post.id)
|
|
|
|
expect(response.parsed_body["topic_slug"]).to eq(topic_embed.topic.slug)
|
2015-05-06 09:00:31 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "without invalid embed url" do
|
|
|
|
it "returns error response" do
|
2017-08-31 12:06:56 +08:00
|
|
|
get "/embed/info.json",
|
2020-04-07 06:55:44 +08:00
|
|
|
params: {
|
|
|
|
embed_url: "http://nope.com",
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
HTTP_API_KEY: api_key.key,
|
|
|
|
HTTP_API_USERNAME: "system",
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2020-05-07 23:04:12 +08:00
|
|
|
json = response.parsed_body
|
2015-05-06 09:00:31 +08:00
|
|
|
expect(json["error_type"]).to eq("not_found")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-27 18:21:10 +08:00
|
|
|
describe "#topics" do
|
2019-08-16 01:41:06 +08:00
|
|
|
it "raises an error when not enabled" do
|
|
|
|
get "/embed/topics?embed_id=de-1234"
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-08-16 01:41:06 +08:00
|
|
|
expect(response.status).to eq(400)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when enabled" do
|
|
|
|
before { SiteSetting.embed_topics_list = true }
|
|
|
|
|
|
|
|
it "raises an error with a weird id" do
|
|
|
|
get "/embed/topics?discourse_embed_id=../asdf/-1234", headers: headers
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-08-16 01:41:06 +08:00
|
|
|
expect(response.status).to eq(400)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a list of topics" do
|
2019-09-11 00:27:07 +08:00
|
|
|
get "/embed/topics?discourse_embed_id=de-1234",
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/evil-trout",
|
|
|
|
}
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-08-16 01:41:06 +08:00
|
|
|
expect(response.status).to eq(200)
|
2021-03-23 03:00:25 +08:00
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
2019-08-16 01:41:06 +08:00
|
|
|
expect(response.body).to match("data-embed-id=\"de-1234\"")
|
|
|
|
expect(response.body).to match("data-topic-id=\"#{topic.id}\"")
|
2019-09-11 00:27:07 +08:00
|
|
|
expect(response.body).to match("data-referer=\"https://example.com/evil-trout\"")
|
2019-08-16 01:41:06 +08:00
|
|
|
end
|
2019-09-11 00:27:07 +08:00
|
|
|
|
2021-04-29 23:12:00 +08:00
|
|
|
it "returns a list of top topics" do
|
2021-04-27 05:10:04 +08:00
|
|
|
good_topic = Fabricate(:topic, like_count: 1000, posts_count: 100)
|
|
|
|
TopTopic.refresh!
|
|
|
|
|
|
|
|
get "/embed/topics?discourse_embed_id=de-1234&top_period=yearly",
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/evil-trout",
|
|
|
|
}
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).to match("data-embed-id=\"de-1234\"")
|
|
|
|
expect(response.body).to match("data-topic-id=\"#{good_topic.id}\"")
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).not_to match("data-topic-id=\"#{topic.id}\"")
|
2021-04-27 05:10:04 +08:00
|
|
|
expect(response.body).to match("data-referer=\"https://example.com/evil-trout\"")
|
|
|
|
end
|
|
|
|
|
2021-07-24 01:52:35 +08:00
|
|
|
it "returns a list of topics if the top_period is not valid" do
|
|
|
|
good_topic = Fabricate(:topic, like_count: 1000, posts_count: 100)
|
|
|
|
TopTopic.refresh!
|
|
|
|
TopicQuery.any_instance.expects(:list_top_for).never
|
|
|
|
|
|
|
|
get "/embed/topics?discourse_embed_id=de-1234&top_period=decadely",
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/evil-trout",
|
|
|
|
}
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2021-07-24 01:52:35 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).to match("data-embed-id=\"de-1234\"")
|
|
|
|
expect(response.body).to match("data-topic-id=\"#{good_topic.id}\"")
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).to match("data-topic-id=\"#{topic.id}\"")
|
2021-07-24 01:52:35 +08:00
|
|
|
expect(response.body).to match("data-referer=\"https://example.com/evil-trout\"")
|
|
|
|
end
|
|
|
|
|
2021-04-29 23:12:00 +08:00
|
|
|
it "wraps the list in a custom class" do
|
|
|
|
get "/embed/topics?discourse_embed_id=de-1234&embed_class=my-special-class",
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/evil-trout",
|
|
|
|
}
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2021-04-29 23:12:00 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).to match("class='topics-list my-special-class'")
|
|
|
|
end
|
|
|
|
|
2019-09-11 00:27:07 +08:00
|
|
|
it "returns no referer if not supplied" do
|
|
|
|
get "/embed/topics?discourse_embed_id=de-1234"
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-09-11 00:27:07 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.body).to match("data-referer=\"\"")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns * for the referer if `embed_any_origin` is set" do
|
|
|
|
SiteSetting.embed_any_origin = true
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-09-11 00:27:07 +08:00
|
|
|
get "/embed/topics?discourse_embed_id=de-1234"
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2019-09-11 00:27:07 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.body).to match("data-referer=\"\\*\"")
|
|
|
|
end
|
|
|
|
|
2022-04-20 05:24:38 +08:00
|
|
|
it "disallows indexing the embed topic list" do
|
|
|
|
get "/embed/topics?discourse_embed_id=de-1234",
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/evil-trout",
|
|
|
|
}
|
2023-02-28 20:31:59 +08:00
|
|
|
|
2022-04-20 05:24:38 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Robots-Tag"]).to match(/noindex/)
|
|
|
|
end
|
2019-08-16 01:41:06 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
describe "#comments" do
|
|
|
|
it "is 404 without an embed_url" do
|
|
|
|
get "/embed/comments"
|
2018-06-12 13:21:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).to match(I18n.t("embed.error"))
|
|
|
|
end
|
2014-01-01 03:37:43 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "raises an error with a missing host" do
|
2017-08-31 12:06:56 +08:00
|
|
|
get "/embed/comments", params: { embed_url: embed_url }
|
2014-01-01 03:37:43 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).to match(I18n.t("embed.error"))
|
|
|
|
end
|
2014-01-01 03:37:43 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
describe "by topic id" do
|
|
|
|
fab!(:embeddable_host) { Fabricate(:embeddable_host) }
|
2018-06-12 13:21:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "allows a topic to be embedded by id" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
topic_id: topic.id,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "http://eviltrout.com/some-page",
|
|
|
|
}
|
2018-05-31 15:53:49 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
end
|
2018-06-12 13:21:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
context "with a host" do
|
|
|
|
fab!(:embeddable_host) { Fabricate(:embeddable_host) }
|
2018-06-12 13:21:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
before { Jobs.run_immediately! }
|
2018-06-12 13:21:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "doesn't raise an error with no referer" do
|
|
|
|
get "/embed/comments", params: { embed_url: embed_url }
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).not_to match(I18n.t("embed.error"))
|
|
|
|
end
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "includes CSS from embedded_scss field" do
|
|
|
|
theme = Fabricate(:theme)
|
|
|
|
theme.set_default!
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
ThemeField.create!(
|
|
|
|
theme_id: theme.id,
|
|
|
|
name: "embedded_scss",
|
|
|
|
target_id: 0,
|
|
|
|
type_id: 1,
|
|
|
|
value: ".test-osama-15 { color: red }",
|
|
|
|
)
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
|
|
|
|
post = Fabricate(:post, topic: topic_embed.topic)
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
get "/embed/comments", params: { embed_url: embed_url }, headers: { "REFERER" => embed_url }
|
2023-02-07 00:10:50 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
html = Nokogiri::HTML5.fragment(response.body)
|
|
|
|
get html.at("link[data-target=embedded_theme]").attribute("href").value
|
2018-06-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.body).to include(".test-osama-15")
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "includes HTML from embedded_header field" do
|
|
|
|
theme = Fabricate(:theme)
|
|
|
|
theme.set_default!
|
|
|
|
|
|
|
|
ThemeField.create!(
|
|
|
|
theme_id: theme.id,
|
|
|
|
name: "embedded_header",
|
|
|
|
target_id: 0,
|
|
|
|
type_id: 0,
|
|
|
|
value: "<strong class='custom-text'>hey there!</strong>\n",
|
|
|
|
)
|
2017-08-31 12:06:56 +08:00
|
|
|
|
|
|
|
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
|
2023-02-28 20:31:59 +08:00
|
|
|
post = Fabricate(:post, topic: topic_embed.topic)
|
|
|
|
|
|
|
|
get "/embed/comments", params: { embed_url: embed_url }, headers: headers
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
html = Nokogiri::HTML5.fragment(response.body)
|
|
|
|
custom_header = html.at(".custom-text")
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(custom_header.name).to eq("strong")
|
|
|
|
expect(custom_header.text).to eq("hey there!")
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
context "with success" do
|
|
|
|
it "tells the topic retriever to work when no previous embed is found" do
|
|
|
|
TopicRetriever.any_instance.expects(:retrieve)
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => embed_url,
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
end
|
2021-08-30 13:07:53 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "displays the right view" do
|
|
|
|
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
|
2021-08-30 13:07:53 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url_secure,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => embed_url,
|
|
|
|
}
|
2021-08-30 13:07:53 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).to match(I18n.t("embed.start_discussion"))
|
|
|
|
end
|
2016-02-25 19:16:27 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "creates a topic view when a topic_id is found" do
|
|
|
|
topic_embed = Fabricate(:topic_embed, embed_url: embed_url)
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
post = Fabricate(:post, topic: topic_embed.topic)
|
|
|
|
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => embed_url,
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).to match(I18n.t("embed.continue"))
|
|
|
|
expect(response.body).to match(post.cooked)
|
|
|
|
expect(response.body).to match("<span class='replies'>1 reply</span>")
|
|
|
|
|
|
|
|
small_action = Fabricate(:small_action, topic: topic_embed.topic)
|
|
|
|
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => embed_url,
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
expect(response.body).not_to match("post-#{small_action.id}")
|
|
|
|
expect(response.body).to match("<span class='replies'>1 reply</span>")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "provides the topic retriever with the discourse username when provided" do
|
|
|
|
TopicRetriever.any_instance.expects(:retrieve).returns(nil)
|
|
|
|
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
discourse_username: discourse_username,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => embed_url,
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers["X-Frame-Options"]).to be_nil
|
|
|
|
end
|
2016-02-25 19:16:27 +08:00
|
|
|
end
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
context "with multiple hosts" do
|
|
|
|
fab!(:embeddable_host_1) { Fabricate(:embeddable_host) }
|
|
|
|
fab!(:embeddable_host_2) { Fabricate(:embeddable_host, host: "http://discourse.org") }
|
|
|
|
fab!(:embeddable_host_3) do
|
|
|
|
Fabricate(:embeddable_host, host: "https://example.com/1234", class_name: "example")
|
|
|
|
end
|
2015-06-10 00:19:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
context "with success" do
|
|
|
|
it "works with the first host" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "http://eviltrout.com/wat/1-2-3.html",
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
2014-01-01 03:37:43 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "works with the second host" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "http://eviltrout.com/wat/1-2-3.html",
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
2015-06-10 00:19:41 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "works with a host with a path" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/some-other-path",
|
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
2015-08-11 03:26:58 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "contains custom class name" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/some-other-path",
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.body).to match('class="example"')
|
|
|
|
end
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "contains custom class name from params" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
class_name: "param-class-name",
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "https://example.com/some-other-path",
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response.body).to match('class="param-class-name"')
|
|
|
|
end
|
2017-05-12 02:08:45 +08:00
|
|
|
end
|
2021-03-23 03:00:25 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
context "with CSP frame-ancestors enabled" do
|
|
|
|
before { SiteSetting.content_security_policy_frame_ancestors = true }
|
2021-03-23 03:00:25 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
it "includes all the hosts" do
|
|
|
|
get "/embed/comments",
|
|
|
|
params: {
|
|
|
|
embed_url: embed_url,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
"REFERER" => "http://eviltrout.com/wat/1-2-3.html",
|
|
|
|
}
|
2023-01-09 19:18:21 +08:00
|
|
|
|
2023-02-28 20:31:59 +08:00
|
|
|
expect(response.headers["Content-Security-Policy"]).to match(
|
|
|
|
%r{frame-ancestors.*https://discourse\.org},
|
|
|
|
)
|
|
|
|
expect(response.headers["Content-Security-Policy"]).to match(
|
|
|
|
%r{frame-ancestors.*https://example\.com},
|
|
|
|
)
|
|
|
|
end
|
2021-03-23 03:00:25 +08:00
|
|
|
end
|
|
|
|
end
|
2015-06-10 00:19:41 +08:00
|
|
|
end
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|