mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 05:03:40 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
39 lines
1.4 KiB
Ruby
39 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe WildcardDomainChecker do
|
|
|
|
describe 'check_domain' do
|
|
context 'valid domain' do
|
|
it 'returns correct domain' do
|
|
result1 = WildcardDomainChecker.check_domain('*.discourse.org', 'anything.is.possible.discourse.org')
|
|
expect(result1[0]).to eq('anything.is.possible.discourse.org')
|
|
|
|
result2 = WildcardDomainChecker.check_domain('www.discourse.org', 'www.discourse.org')
|
|
expect(result2[0]).to eq('www.discourse.org')
|
|
|
|
result3 = WildcardDomainChecker.check_domain('*', 'hello.discourse.org')
|
|
expect(result3[0]).to eq('hello.discourse.org')
|
|
end
|
|
end
|
|
|
|
context 'invalid domain' do
|
|
it "doesn't return the domain" do
|
|
result1 = WildcardDomainChecker.check_domain('*.discourse.org', 'bad-domain.discourse.org.evil.com')
|
|
expect(result1).to eq(nil)
|
|
|
|
result2 = WildcardDomainChecker.check_domain('www.discourse.org', 'www.discourse.org.evil.com')
|
|
expect(result2).to eq(nil)
|
|
|
|
result3 = WildcardDomainChecker.check_domain('www.discourse.org', 'www.www.discourse.org')
|
|
expect(result3).to eq(nil)
|
|
|
|
result4 = WildcardDomainChecker.check_domain('www.*.discourse.org', 'www.www.discourse.org')
|
|
expect(result4).to eq(nil)
|
|
|
|
result5 = WildcardDomainChecker.check_domain('www.discourse.org', "www.discourse.org\nwww.discourse.org.evil.com")
|
|
expect(result5).to eq(nil)
|
|
end
|
|
end
|
|
end
|
|
end
|