2022-01-31 15:35:12 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Onebox::DomainChecker do
|
2022-01-31 15:35:12 +08:00
|
|
|
describe '.is_blocked?' do
|
|
|
|
before do
|
|
|
|
SiteSetting.blocked_onebox_domains = "api.cat.org|kitten.cloud"
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "returns true when entirely matched" do
|
|
|
|
it { expect(described_class.is_blocked?("api.cat.org")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?("kitten.cloud")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?("api.dog.org")).to be(false) }
|
|
|
|
it { expect(described_class.is_blocked?("puppy.cloud")).to be(false) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "returns true when ends with .<domain>" do
|
|
|
|
it { expect(described_class.is_blocked?("dev.api.cat.org")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?(".api.cat.org")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?("dev.kitten.cloud")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?(".kitten.cloud")).to be(true) }
|
|
|
|
it { expect(described_class.is_blocked?("xapi.cat.org")).to be(false) }
|
|
|
|
it { expect(described_class.is_blocked?("xkitten.cloud")).to be(false) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|