discourse/spec/services/problem_check/maxmind_db_configuration_spec.rb
Alan Guo Xiang Tan 7079698cdf
FIX: Use MaxMind supplied permalinks to download MaxMind databases (#26847)
This commit switches `DiscourseIpInfo.mmdb_download` to use the
permalinks supplied by MaxMind to download the MaxMind databases as
specified in
https://dev.maxmind.com/geoip/updating-databases#directly-downloading-databases
which states:

```
To directly download databases, follow these steps:

1. In the "Download Links" column, click "Get Permalink(s)" for the desired database.
2. Copy the permalink(s) provided in the modal window.
3. Provide your account ID and your license key using Basic Authentication to authenticate.
```

Previously we are downloading from `https://download.maxmind.com/app/geoip_download` but this is not
documented anyway on MaxMind's docs so this URL can in theory break
in the future without warning. Therefore, we are taking a proactive
approach to download the databases from MaxMind the recommended way
instead of relying on a hidden URL. This old way of downloading the
databases with only a license key will be deprecated in 3.3 and be
removed in 3.4.
2024-05-09 15:11:56 +08:00

28 lines
880 B
Ruby

# frozen_string_literal: true
RSpec.describe ProblemCheck::MaxmindDbConfiguration do
subject(:check) { described_class.new }
context "when `maxmind_license_key` and `maxmind_account_id` global settings are not set" do
it "should not raise any warning message" do
expect(check).to be_chill_about_it
end
end
context "when `maxmind_license_key` and `maxmind_account_id` global settings are set" do
it "should not raise any warning message" do
expect(check).to be_chill_about_it
end
end
context "when `maxmind_license_key` global setting is set but not `maxmind_account_id`" do
it "should raise the right warning" do
global_setting :maxmind_license_key, "license_key"
expect(check).to have_a_problem.with_priority("low").with_message(
I18n.t("dashboard.maxmind_db_configuration_warning"),
)
end
end
end