2019-08-09 12:40:28 +05:30
|
|
|
package azure
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/caddyserver/caddy"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSetup(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
body string
|
|
|
|
|
expectedError bool
|
|
|
|
|
}{
|
|
|
|
|
{`azure`, false},
|
|
|
|
|
{`azure :`, true},
|
|
|
|
|
{`azure resource_set:zone`, false},
|
|
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
tenant
|
|
|
|
|
}`, true},
|
|
|
|
|
{`azure resource_set:zone {
|
2020-03-11 00:52:23 +05:30
|
|
|
tenant abc
|
|
|
|
|
}`, false},
|
2019-08-09 12:40:28 +05:30
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
client
|
|
|
|
|
}`, true},
|
|
|
|
|
{`azure resource_set:zone {
|
2020-03-11 00:52:23 +05:30
|
|
|
client abc
|
|
|
|
|
}`, false},
|
2019-08-09 12:40:28 +05:30
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
subscription
|
|
|
|
|
}`, true},
|
|
|
|
|
{`azure resource_set:zone {
|
2020-03-11 00:52:23 +05:30
|
|
|
subscription abc
|
|
|
|
|
}`, false},
|
2019-08-09 12:40:28 +05:30
|
|
|
{`azure resource_set:zone {
|
2020-03-11 00:52:23 +05:30
|
|
|
foo
|
2019-08-09 12:40:28 +05:30
|
|
|
}`, true},
|
|
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
tenant tenant_id
|
|
|
|
|
client client_id
|
|
|
|
|
secret client_secret
|
|
|
|
|
subscription subscription_id
|
2020-03-11 00:52:23 +05:30
|
|
|
access public
|
2019-08-09 12:40:28 +05:30
|
|
|
}`, false},
|
|
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
fallthrough
|
|
|
|
|
}`, false},
|
|
|
|
|
{`azure resource_set:zone {
|
|
|
|
|
environment AZUREPUBLICCLOUD
|
|
|
|
|
}`, false},
|
|
|
|
|
{`azure resource_set:zone resource_set:zone {
|
|
|
|
|
fallthrough
|
|
|
|
|
}`, true},
|
|
|
|
|
{`azure resource_set:zone,zone2 {
|
2020-03-11 00:52:23 +05:30
|
|
|
access private
|
2019-08-09 12:40:28 +05:30
|
|
|
}`, false},
|
2020-03-11 00:52:23 +05:30
|
|
|
{`azure resource-set:zone {
|
|
|
|
|
access public
|
|
|
|
|
}`, false},
|
|
|
|
|
{`azure resource-set:zone {
|
|
|
|
|
access foo
|
2019-08-09 12:40:28 +05:30
|
|
|
}`, true},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for i, test := range tests {
|
|
|
|
|
c := caddy.NewTestController("dns", test.body)
|
2020-03-11 00:52:23 +05:30
|
|
|
if _, _, _, _, err := parse(c); (err == nil) == test.expectedError {
|
2019-08-09 12:40:28 +05:30
|
|
|
t.Fatalf("Unexpected errors: %v in test: %d\n\t%s", err, i, test.body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|