2018-01-15 09:59:29 -08:00
|
|
|
package route53
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-03 10:19:21 +01:00
|
|
|
"context"
|
2018-01-15 09:59:29 -08:00
|
|
|
"testing"
|
|
|
|
|
|
2020-09-24 18:14:41 +02:00
|
|
|
"github.com/coredns/caddy"
|
|
|
|
|
|
2025-07-03 10:19:21 +01:00
|
|
|
"github.com/aws/aws-sdk-go-v2/config"
|
|
|
|
|
"github.com/aws/aws-sdk-go-v2/service/route53"
|
2018-01-15 09:59:29 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSetupRoute53(t *testing.T) {
|
2025-07-03 10:19:21 +01:00
|
|
|
f = func(_ context.Context, _ []func(*config.LoadOptions) error, _ []func(*route53.Options)) (route53Client, error) {
|
|
|
|
|
return fakeRoute53{}, nil
|
2018-01-15 09:59:29 -08:00
|
|
|
}
|
|
|
|
|
|
2019-02-23 22:32:58 +05:30
|
|
|
tests := []struct {
|
|
|
|
|
body string
|
|
|
|
|
expectedError bool
|
|
|
|
|
}{
|
|
|
|
|
{`route53`, false},
|
|
|
|
|
{`route53 :`, true},
|
|
|
|
|
{`route53 example.org:12345678`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
2018-01-15 09:59:29 -08:00
|
|
|
aws_access_key
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, true},
|
2019-07-02 16:23:47 +01:00
|
|
|
{`route53 example.org:12345678 { }`, false},
|
2018-11-02 22:07:50 +01:00
|
|
|
|
2019-07-02 16:23:47 +01:00
|
|
|
{`route53 example.org:12345678 { }`, false},
|
|
|
|
|
{`route53 example.org:12345678 { wat
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, true},
|
|
|
|
|
{`route53 example.org:12345678 {
|
2018-09-17 11:19:07 -07:00
|
|
|
aws_access_key ACCESS_KEY_ID SEKRIT_ACCESS_KEY
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, false},
|
2018-10-10 10:55:54 -07:00
|
|
|
|
2019-02-23 22:32:58 +05:30
|
|
|
{`route53 example.org:12345678 {
|
2018-09-25 11:41:05 -07:00
|
|
|
fallthrough
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
2018-09-25 15:57:16 -07:00
|
|
|
credentials
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, true},
|
2018-09-25 15:57:16 -07:00
|
|
|
|
2019-02-23 22:32:58 +05:30
|
|
|
{`route53 example.org:12345678 {
|
2018-09-25 15:57:16 -07:00
|
|
|
credentials default
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
2018-09-25 15:57:16 -07:00
|
|
|
credentials default credentials
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
2018-09-25 15:57:16 -07:00
|
|
|
credentials default credentials extra-arg
|
2019-02-23 22:32:58 +05:30
|
|
|
}`, true},
|
|
|
|
|
{`route53 example.org:12345678 example.org:12345678 {
|
|
|
|
|
}`, true},
|
2018-10-10 10:55:54 -07:00
|
|
|
|
2019-08-03 18:07:28 -07:00
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
refresh 90
|
|
|
|
|
}`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
refresh 5m
|
|
|
|
|
}`, false},
|
|
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
refresh
|
|
|
|
|
}`, true},
|
|
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
refresh foo
|
|
|
|
|
}`, true},
|
|
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
refresh -1m
|
|
|
|
|
}`, true},
|
|
|
|
|
|
2019-02-23 22:32:58 +05:30
|
|
|
{`route53 example.org {
|
|
|
|
|
}`, true},
|
2021-11-08 14:45:45 +00:00
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
aws_endpoint
|
|
|
|
|
}`, true},
|
|
|
|
|
{`route53 example.org:12345678 {
|
|
|
|
|
aws_endpoint https://localhost
|
|
|
|
|
}`, false},
|
2018-10-10 10:55:54 -07:00
|
|
|
}
|
2019-02-23 22:32:58 +05:30
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
c := caddy.NewTestController("dns", test.body)
|
2019-10-03 07:21:11 +01:00
|
|
|
if err := setup(c); (err == nil) == test.expectedError {
|
2019-02-23 22:32:58 +05:30
|
|
|
t.Errorf("Unexpected errors: %v", err)
|
|
|
|
|
}
|
2018-10-10 10:55:54 -07:00
|
|
|
}
|
2018-01-15 09:59:29 -08:00
|
|
|
}
|