mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 15:05:07 +00:00
![Matt Jankowski](/assets/img/avatar_default.png)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
64 lines
1.8 KiB
Ruby
64 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module DomainHelpers
|
|
def configure_mx(domain:, exchange:, ip_v4_addr: '2.3.4.5', ip_v6_addr: 'fd00::2')
|
|
resolver = instance_double(Resolv::DNS, :timeouts= => nil)
|
|
|
|
allow(resolver).to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::MX)
|
|
.and_return([double_mx(exchange)])
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::A)
|
|
.and_return([])
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::AAAA)
|
|
.and_return([])
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(exchange, Resolv::DNS::Resource::IN::A)
|
|
.and_return([double_resource_v4(ip_v4_addr)])
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(exchange, Resolv::DNS::Resource::IN::AAAA)
|
|
.and_return([double_resource_v6(ip_v6_addr)])
|
|
allow(Resolv::DNS)
|
|
.to receive(:open)
|
|
.and_yield(resolver)
|
|
end
|
|
|
|
def configure_dns(domain:, results:)
|
|
resolver = instance_double(Resolv::DNS, :timeouts= => nil)
|
|
|
|
allow(resolver).to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::MX)
|
|
.and_return(results)
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::A)
|
|
.and_return(results)
|
|
allow(resolver)
|
|
.to receive(:getresources)
|
|
.with(domain, Resolv::DNS::Resource::IN::AAAA)
|
|
.and_return(results)
|
|
allow(Resolv::DNS)
|
|
.to receive(:open)
|
|
.and_yield(resolver)
|
|
end
|
|
|
|
private
|
|
|
|
def double_mx(exchange)
|
|
instance_double(Resolv::DNS::Resource::MX, exchange: exchange)
|
|
end
|
|
|
|
def double_resource_v4(addr)
|
|
instance_double(Resolv::DNS::Resource::IN::A, address: addr)
|
|
end
|
|
|
|
def double_resource_v6(addr)
|
|
instance_double(Resolv::DNS::Resource::IN::AAAA, address: addr)
|
|
end
|
|
end
|