mirror of
https://github.com/coredns/coredns.git
synced 2025-12-25 03:25:10 -05:00
feat(clouddns): API to 0.258.0 with deprecations (#7787)
This commit is contained in:
@@ -2,6 +2,9 @@ package clouddns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/caddy"
|
||||
@@ -14,6 +17,26 @@ func TestSetupCloudDNS(t *testing.T) {
|
||||
return fakeGCPClient{}, nil
|
||||
}
|
||||
|
||||
validCreds := filepath.Join(t.TempDir(), "valid_creds.json")
|
||||
if err := os.WriteFile(validCreds, []byte(`{"type": "service_account"}`), 0644); err != nil {
|
||||
t.Fatalf("Failed to create valid creds: %v", err)
|
||||
}
|
||||
|
||||
invalidTypeCreds := filepath.Join(t.TempDir(), "invalid_type_creds.json")
|
||||
if err := os.WriteFile(invalidTypeCreds, []byte(`{"type": "bad_type"}`), 0644); err != nil {
|
||||
t.Fatalf("Failed to create invalid creds: %v", err)
|
||||
}
|
||||
|
||||
emptyCreds := filepath.Join(t.TempDir(), "empty_creds.json")
|
||||
if err := os.WriteFile(emptyCreds, []byte(`{}`), 0644); err != nil {
|
||||
t.Fatalf("Failed to create empty creds: %v", err)
|
||||
}
|
||||
|
||||
invalidJSONCreds := filepath.Join(t.TempDir(), "invalid_json_creds.json")
|
||||
if err := os.WriteFile(invalidJSONCreds, []byte(`{`), 0644); err != nil {
|
||||
t.Fatalf("Failed to create invalid JSON creds: %v", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
body string
|
||||
expectedError bool
|
||||
@@ -38,6 +61,18 @@ func TestSetupCloudDNS(t *testing.T) {
|
||||
|
||||
{`clouddns example.org {
|
||||
}`, true},
|
||||
{fmt.Sprintf(`clouddns example.org.:example-project:zone-name {
|
||||
credentials %s
|
||||
}`, validCreds), false},
|
||||
{fmt.Sprintf(`clouddns example.org.:example-project:zone-name {
|
||||
credentials %s
|
||||
}`, invalidTypeCreds), true},
|
||||
{fmt.Sprintf(`clouddns example.org.:example-project:zone-name {
|
||||
credentials %s
|
||||
}`, emptyCreds), true},
|
||||
{fmt.Sprintf(`clouddns example.org.:example-project:zone-name {
|
||||
credentials %s
|
||||
}`, invalidJSONCreds), true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user