diff --git a/README.md b/README.md
index 646b064e9..ad675ba60 100644
--- a/README.md
+++ b/README.md
@@ -66,182 +66,182 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
Autodns |
Azure (deprecated) |
Azure DNS |
- Bindman |
+ Baidu Cloud |
+ | Bindman |
Bluecat |
BookMyName |
Brandit (deprecated) |
- Bunny |
+ | Bunny |
Checkdomain |
Civo |
Cloud.ru |
- CloudDNS |
+ | CloudDNS |
Cloudflare |
ClouDNS |
CloudXNS (Deprecated) |
- ConoHa |
+ | ConoHa |
Constellix |
Core-Networks |
CPanel/WHM |
- Derak Cloud |
+ | Derak Cloud |
deSEC.io |
Designate DNSaaS for Openstack |
Digital Ocean |
- DirectAdmin |
+ | DirectAdmin |
DNS Made Easy |
dnsHome.de |
DNSimple |
- DNSPod (deprecated) |
+ | DNSPod (deprecated) |
Domain Offensive (do.de) |
Domeneshop |
DreamHost |
- Duck DNS |
+ | Duck DNS |
Dyn |
Dynu |
EasyDNS |
- Efficient IP |
+ | Efficient IP |
Epik |
Exoscale |
External program |
- F5 XC |
+ | F5 XC |
freemyip.com |
G-Core |
Gandi |
- Gandi Live DNS (v5) |
+ | Gandi Live DNS (v5) |
Glesys |
Go Daddy |
Google Cloud |
- Google Domains |
+ | Google Domains |
Hetzner |
Hosting.de |
Hosttech |
- HTTP request |
+ | HTTP request |
http.net |
Huawei Cloud |
Hurricane Electric DNS |
- HyperOne |
+ | HyperOne |
IBM Cloud (SoftLayer) |
IIJ DNS Platform Service |
Infoblox |
- Infomaniak |
+ | Infomaniak |
Internet Initiative Japan |
Internet.bs |
INWX |
- Ionos |
+ | Ionos |
IPv64 |
iwantmyname |
Joker |
- Joohoi's ACME-DNS |
+ | Joohoi's ACME-DNS |
Liara |
Lima-City |
Linode (v4) |
- Liquid Web |
+ | Liquid Web |
Loopia |
LuaDNS |
Mail-in-a-Box |
- ManageEngine CloudDNS |
+ | ManageEngine CloudDNS |
Manual |
Metaname |
Metaregistrar |
- mijn.host |
+ | mijn.host |
Mittwald |
myaddr.{tools,dev,io} |
MyDNS.jp |
- MythicBeasts |
+ | MythicBeasts |
Name.com |
Namecheap |
Namesilo |
- NearlyFreeSpeech.NET |
+ | NearlyFreeSpeech.NET |
Netcup |
Netlify |
Nicmanager |
- NIFCloud |
+ | NIFCloud |
Njalla |
Nodion |
NS1 |
- Open Telekom Cloud |
+ | Open Telekom Cloud |
Oracle Cloud |
OVH |
plesk.com |
- Porkbun |
+ | Porkbun |
PowerDNS |
Rackspace |
Rain Yun/雨云 |
- RcodeZero |
+ | RcodeZero |
reg.ru |
Regfish |
RFC2136 |
- RimuHosting |
+ | RimuHosting |
Sakura Cloud |
Scaleway |
Selectel |
- Selectel v2 |
+ | Selectel v2 |
SelfHost.(de|eu) |
Servercow |
Shellrent |
- Simply.com |
+ | Simply.com |
Sonic |
Spaceship |
Stackpath |
- Technitium |
+ | Technitium |
Tencent Cloud DNS |
Timeweb Cloud |
TransIP |
- UKFast SafeDNS |
+ | UKFast SafeDNS |
Ultradns |
Variomedia |
VegaDNS |
- Vercel |
+ | Vercel |
Versio.[nl|eu|uk] |
VinylDNS |
VK Cloud |
- Volcano Engine/火山引擎 |
+ | Volcano Engine/火山引擎 |
Vscale |
Vultr |
Webnames |
- Websupport |
+ | Websupport |
WEDOS |
West.cn/西部数码 |
Yandex 360 |
- Yandex Cloud |
+ | Yandex Cloud |
Yandex PDD |
Zone.ee |
Zonomi |
- |
diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go
index 1ce9e8f9c..671334e57 100644
--- a/cmd/zz_gen_cmd_dnshelp.go
+++ b/cmd/zz_gen_cmd_dnshelp.go
@@ -22,6 +22,7 @@ func allDNSCodes() string {
"autodns",
"azure",
"azuredns",
+ "baiducloud",
"bindman",
"bluecat",
"bookmyname",
@@ -378,6 +379,26 @@ func displayDNSHelp(w io.Writer, name string) error {
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/azuredns`)
+ case "baiducloud":
+ // generated from: providers/dns/baiducloud/baiducloud.toml
+ ew.writeln(`Configuration for Baidu Cloud.`)
+ ew.writeln(`Code: 'baiducloud'`)
+ ew.writeln(`Since: 'v4.23.0'`)
+ ew.writeln()
+
+ ew.writeln(`Credentials:`)
+ ew.writeln(` - "BAIDUCLOUD_ACCESS_KEY_ID": Access key`)
+ ew.writeln(` - "BAIDUCLOUD_SECRET_ACCESS_KEY": Secret access key`)
+ ew.writeln()
+
+ ew.writeln(`Additional Configuration:`)
+ ew.writeln(` - "BAIDUCLOUD_POLLING_INTERVAL": Time between DNS propagation check in seconds (Default: 2)`)
+ ew.writeln(` - "BAIDUCLOUD_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation in seconds (Default: 60)`)
+ ew.writeln(` - "BAIDUCLOUD_TTL": The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)`)
+
+ ew.writeln()
+ ew.writeln(`More information: https://go-acme.github.io/lego/dns/baiducloud`)
+
case "bindman":
// generated from: providers/dns/bindman/bindman.toml
ew.writeln(`Configuration for Bindman.`)
diff --git a/docs/content/dns/zz_gen_baiducloud.md b/docs/content/dns/zz_gen_baiducloud.md
new file mode 100644
index 000000000..11a71c1ab
--- /dev/null
+++ b/docs/content/dns/zz_gen_baiducloud.md
@@ -0,0 +1,69 @@
+---
+title: "Baidu Cloud"
+date: 2019-03-03T16:39:46+01:00
+draft: false
+slug: baiducloud
+dnsprovider:
+ since: "v4.23.0"
+ code: "baiducloud"
+ url: "https://cloud.baidu.com"
+---
+
+
+
+
+
+
+Configuration for [Baidu Cloud](https://cloud.baidu.com).
+
+
+
+
+- Code: `baiducloud`
+- Since: v4.23.0
+
+
+Here is an example bash command using the Baidu Cloud provider:
+
+```bash
+BAIDUCLOUD_ACCESS_KEY_ID="xxx" \
+BAIDUCLOUD_SECRET_ACCESS_KEY="yyy" \
+lego --email you@example.com --dns baiducloud -d '*.example.com' -d example.com run
+```
+
+
+
+
+## Credentials
+
+| Environment Variable Name | Description |
+|-----------------------|-------------|
+| `BAIDUCLOUD_ACCESS_KEY_ID` | Access key |
+| `BAIDUCLOUD_SECRET_ACCESS_KEY` | Secret access key |
+
+The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
+More information [here]({{% ref "dns#configuration-and-credentials" %}}).
+
+
+## Additional Configuration
+
+| Environment Variable Name | Description |
+|--------------------------------|-------------|
+| `BAIDUCLOUD_POLLING_INTERVAL` | Time between DNS propagation check in seconds (Default: 2) |
+| `BAIDUCLOUD_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation in seconds (Default: 60) |
+| `BAIDUCLOUD_TTL` | The TTL of the TXT record used for the DNS challenge in seconds (Default: 120) |
+
+The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
+More information [here]({{% ref "dns#configuration-and-credentials" %}}).
+
+
+
+
+## More information
+
+- [API documentation](https://cloud.baidu.com/doc/DNS/s/El4s7lssr)
+- [Go client](https://github.com/baidubce/bce-sdk-go)
+
+
+
+
diff --git a/docs/data/zz_cli_help.toml b/docs/data/zz_cli_help.toml
index 9b3dd1d02..fe878a546 100644
--- a/docs/data/zz_cli_help.toml
+++ b/docs/data/zz_cli_help.toml
@@ -150,7 +150,7 @@ To display the documentation for a specific DNS provider, run:
$ lego dnshelp -c code
Supported DNS providers:
- acme-dns, active24, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rainyun, rcodezero, regfish, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, spaceship, stackpath, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneee, zonomi
+ acme-dns, active24, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, baiducloud, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rainyun, rcodezero, regfish, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, spaceship, stackpath, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneee, zonomi
More information: https://go-acme.github.io/lego/dns
"""
diff --git a/go.mod b/go.mod
index f93e7d2d6..740641193 100644
--- a/go.mod
+++ b/go.mod
@@ -24,6 +24,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/route53 v1.50.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17
+ github.com/baidubce/bce-sdk-go v0.9.223
github.com/cenkalti/backoff/v4 v4.3.0
github.com/civo/civogo v0.3.11
github.com/cloudflare/cloudflare-go v0.115.0
diff --git a/go.sum b/go.sum
index 007d094b5..707d92038 100644
--- a/go.sum
+++ b/go.sum
@@ -166,6 +166,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjK
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ=
github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
+github.com/baidubce/bce-sdk-go v0.9.223 h1:vvDeIemf7ePPP59nLHCntQ/vS++ok2HKbRPgmz1VZKU=
+github.com/baidubce/bce-sdk-go v0.9.223/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
diff --git a/providers/dns/baiducloud/baiducloud.go b/providers/dns/baiducloud/baiducloud.go
new file mode 100644
index 000000000..fc317904a
--- /dev/null
+++ b/providers/dns/baiducloud/baiducloud.go
@@ -0,0 +1,159 @@
+// Package baiducloud implements a DNS provider for solving the DNS-01 challenge using Baidu Cloud.
+package baiducloud
+
+import (
+ "errors"
+ "fmt"
+ "time"
+
+ baidudns "github.com/baidubce/bce-sdk-go/services/dns"
+ "github.com/go-acme/lego/v4/challenge/dns01"
+ "github.com/go-acme/lego/v4/platform/config/env"
+ "github.com/go-acme/lego/v4/providers/dns/internal/ptr"
+)
+
+// Environment variables names.
+const (
+ envNamespace = "BAIDUCLOUD_"
+
+ EnvAccessKeyID = envNamespace + "ACCESS_KEY_ID"
+ EnvSecretAccessKey = envNamespace + "SECRET_ACCESS_KEY"
+
+ EnvTTL = envNamespace + "TTL"
+ EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
+ EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
+)
+
+// Config is used to configure the creation of the DNSProvider.
+type Config struct {
+ AccessKeyID string
+ SecretAccessKey string
+
+ PropagationTimeout time.Duration
+ PollingInterval time.Duration
+ TTL int
+}
+
+// NewDefaultConfig returns a default configuration for the DNSProvider.
+func NewDefaultConfig() *Config {
+ return &Config{
+ TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
+ PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
+ PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
+ }
+}
+
+// DNSProvider implements the challenge.Provider interface.
+type DNSProvider struct {
+ config *Config
+ client *baidudns.Client
+}
+
+// NewDNSProvider returns a DNSProvider instance configured for Baidu Cloud.
+func NewDNSProvider() (*DNSProvider, error) {
+ values, err := env.Get(EnvAccessKeyID, EnvSecretAccessKey)
+ if err != nil {
+ return nil, fmt.Errorf("baiducloud: %w", err)
+ }
+
+ config := NewDefaultConfig()
+ config.AccessKeyID = values[EnvAccessKeyID]
+ config.SecretAccessKey = values[EnvSecretAccessKey]
+
+ return NewDNSProviderConfig(config)
+}
+
+// NewDNSProviderConfig return a DNSProvider instance configured for Baidu Cloud.
+func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
+ if config == nil {
+ return nil, errors.New("baiducloud: the configuration of the DNS provider is nil")
+ }
+
+ if config.AccessKeyID == "" && config.SecretAccessKey == "" {
+ return nil, errors.New("baiducloud: credentials missing")
+ }
+
+ client, err := baidudns.NewClient(config.AccessKeyID, config.SecretAccessKey, "")
+ if err != nil {
+ return nil, fmt.Errorf("baiducloud: %w", err)
+ }
+
+ return &DNSProvider{
+ config: config,
+ client: client,
+ }, nil
+}
+
+// Present creates a TXT record using the specified parameters.
+func (d *DNSProvider) Present(domain, token, keyAuth string) error {
+ info := dns01.GetChallengeInfo(domain, keyAuth)
+
+ authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
+ if err != nil {
+ return fmt.Errorf("baiducloud: could not find zone for domain %q: %w", domain, err)
+ }
+
+ subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
+ if err != nil {
+ return fmt.Errorf("baiducloud: %w", err)
+ }
+
+ crr := &baidudns.CreateRecordRequest{
+ Description: ptr.Pointer("lego"),
+ Rr: subDomain,
+ Type: "TXT",
+ Value: info.Value,
+ }
+
+ err = d.client.CreateRecord(dns01.UnFqdn(authZone), crr, "")
+ if err != nil {
+ return fmt.Errorf("baiducloud: create record: %w", err)
+ }
+
+ return nil
+}
+
+// CleanUp removes the TXT record matching the specified parameters.
+func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
+ info := dns01.GetChallengeInfo(domain, keyAuth)
+
+ authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
+ if err != nil {
+ return fmt.Errorf("baiducloud: could not find zone for domain %q: %w", domain, err)
+ }
+
+ lrr := &baidudns.ListRecordRequest{}
+
+ recordResponse, err := d.client.ListRecord(dns01.UnFqdn(authZone), lrr)
+ if err != nil {
+ return fmt.Errorf("baiducloud: list record: %w", err)
+ }
+
+ recordID, err := findRecordID(recordResponse, info)
+ if err != nil {
+ return fmt.Errorf("baiducloud: find record: %w", err)
+ }
+
+ err = d.client.DeleteRecord(dns01.UnFqdn(authZone), recordID, "")
+ if err != nil {
+ return fmt.Errorf("baiducloud: delete record: %w", err)
+ }
+
+ return nil
+}
+
+func findRecordID(recordResponse *baidudns.ListRecordResponse, info dns01.ChallengeInfo) (string, error) {
+ for _, record := range recordResponse.Records {
+ if record.Type == "TXT" && record.Value == info.Value {
+ return record.Id, nil
+ }
+ }
+
+ return "", errors.New("record not found")
+}
+
+// Timeout returns the timeout and interval to use when checking for DNS propagation.
+// Adjusting here to cope with spikes in propagation times.
+func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
+ return d.config.PropagationTimeout, d.config.PollingInterval
+}
diff --git a/providers/dns/baiducloud/baiducloud.toml b/providers/dns/baiducloud/baiducloud.toml
new file mode 100644
index 000000000..941d90b2c
--- /dev/null
+++ b/providers/dns/baiducloud/baiducloud.toml
@@ -0,0 +1,24 @@
+Name = "Baidu Cloud"
+Description = ''''''
+URL = "https://cloud.baidu.com"
+Code = "baiducloud"
+Since = "v4.23.0"
+
+Example = '''
+BAIDUCLOUD_ACCESS_KEY_ID="xxx" \
+BAIDUCLOUD_SECRET_ACCESS_KEY="yyy" \
+lego --email you@example.com --dns baiducloud -d '*.example.com' -d example.com run
+'''
+
+[Configuration]
+ [Configuration.Credentials]
+ BAIDUCLOUD_ACCESS_KEY_ID = "Access key"
+ BAIDUCLOUD_SECRET_ACCESS_KEY = "Secret access key"
+ [Configuration.Additional]
+ BAIDUCLOUD_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 2)"
+ BAIDUCLOUD_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 60)"
+ BAIDUCLOUD_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)"
+
+[Links]
+ API = "https://cloud.baidu.com/doc/DNS/s/El4s7lssr"
+ GoClient = "https://github.com/baidubce/bce-sdk-go"
diff --git a/providers/dns/baiducloud/baiducloud_test.go b/providers/dns/baiducloud/baiducloud_test.go
new file mode 100644
index 000000000..3cc411323
--- /dev/null
+++ b/providers/dns/baiducloud/baiducloud_test.go
@@ -0,0 +1,143 @@
+package baiducloud
+
+import (
+ "testing"
+
+ "github.com/go-acme/lego/v4/platform/tester"
+ "github.com/stretchr/testify/require"
+)
+
+const envDomain = envNamespace + "DOMAIN"
+
+var envTest = tester.NewEnvTest(EnvAccessKeyID, EnvSecretAccessKey).WithDomain(envDomain)
+
+func TestNewDNSProvider(t *testing.T) {
+ testCases := []struct {
+ desc string
+ envVars map[string]string
+ expected string
+ }{
+ {
+ desc: "success",
+ envVars: map[string]string{
+ EnvAccessKeyID: "key",
+ EnvSecretAccessKey: "secret",
+ },
+ },
+ {
+ desc: "missing access key ID",
+ envVars: map[string]string{
+ EnvAccessKeyID: "key",
+ },
+ expected: "baiducloud: some credentials information are missing: BAIDUCLOUD_SECRET_ACCESS_KEY",
+ },
+ {
+ desc: "missing secret access key",
+ envVars: map[string]string{
+ EnvSecretAccessKey: "secret",
+ },
+ expected: "baiducloud: some credentials information are missing: BAIDUCLOUD_ACCESS_KEY_ID",
+ },
+ {
+ desc: "missing credentials",
+ envVars: map[string]string{},
+ expected: "baiducloud: some credentials information are missing: BAIDUCLOUD_ACCESS_KEY_ID,BAIDUCLOUD_SECRET_ACCESS_KEY",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.desc, func(t *testing.T) {
+ defer envTest.RestoreEnv()
+ envTest.ClearEnv()
+
+ envTest.Apply(test.envVars)
+
+ p, err := NewDNSProvider()
+
+ if test.expected == "" {
+ require.NoError(t, err)
+ require.NotNil(t, p)
+ require.NotNil(t, p.config)
+ require.NotNil(t, p.client)
+ } else {
+ require.EqualError(t, err, test.expected)
+ }
+ })
+ }
+}
+
+func TestNewDNSProviderConfig(t *testing.T) {
+ testCases := []struct {
+ desc string
+ accessKeyID string
+ secretAccessKey string
+ expected string
+ }{
+ {
+ desc: "success",
+ accessKeyID: "key",
+ secretAccessKey: "secret",
+ },
+ {
+ desc: "missing access key ID",
+ accessKeyID: "",
+ secretAccessKey: "secret",
+ expected: "baiducloud: accessKeyId should not be empty",
+ },
+ {
+ desc: "missing secret access key",
+ accessKeyID: "key",
+ secretAccessKey: "",
+ expected: "baiducloud: secretKey should not be empty",
+ },
+ {
+ desc: "missing credentials",
+ expected: "baiducloud: credentials missing",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.desc, func(t *testing.T) {
+ config := NewDefaultConfig()
+ config.AccessKeyID = test.accessKeyID
+ config.SecretAccessKey = test.secretAccessKey
+
+ p, err := NewDNSProviderConfig(config)
+
+ if test.expected == "" {
+ require.NoError(t, err)
+ require.NotNil(t, p)
+ require.NotNil(t, p.config)
+ require.NotNil(t, p.client)
+ } else {
+ require.EqualError(t, err, test.expected)
+ }
+ })
+ }
+}
+
+func TestLivePresent(t *testing.T) {
+ if !envTest.IsLiveTest() {
+ t.Skip("skipping live test")
+ }
+
+ envTest.RestoreEnv()
+ provider, err := NewDNSProvider()
+ require.NoError(t, err)
+
+ err = provider.Present(envTest.GetDomain(), "", "123d==")
+ require.NoError(t, err)
+}
+
+func TestLiveCleanUp(t *testing.T) {
+ if !envTest.IsLiveTest() {
+ t.Skip("skipping live test")
+ }
+
+ envTest.RestoreEnv()
+ provider, err := NewDNSProvider()
+ require.NoError(t, err)
+
+ err = provider.CleanUp(envTest.GetDomain(), "", "123d==")
+ require.NoError(t, err)
+}
diff --git a/providers/dns/zz_gen_dns_providers.go b/providers/dns/zz_gen_dns_providers.go
index 9b3f70771..c3c10e379 100644
--- a/providers/dns/zz_gen_dns_providers.go
+++ b/providers/dns/zz_gen_dns_providers.go
@@ -16,6 +16,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/autodns"
"github.com/go-acme/lego/v4/providers/dns/azure"
"github.com/go-acme/lego/v4/providers/dns/azuredns"
+ "github.com/go-acme/lego/v4/providers/dns/baiducloud"
"github.com/go-acme/lego/v4/providers/dns/bindman"
"github.com/go-acme/lego/v4/providers/dns/bluecat"
"github.com/go-acme/lego/v4/providers/dns/bookmyname"
@@ -182,6 +183,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return azure.NewDNSProvider()
case "azuredns":
return azuredns.NewDNSProvider()
+ case "baiducloud":
+ return baiducloud.NewDNSProvider()
case "bindman":
return bindman.NewDNSProvider()
case "bluecat":