mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
fix(issue-4448): added unittest
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
df6d68e9a6
commit
cc1f4ab148
@ -616,7 +616,6 @@ func (p *AWSProvider) GetDomainFilter() endpoint.DomainFilter {
|
||||
|
||||
// ApplyChanges applies a given set of changes in a given zone.
|
||||
func (p *AWSProvider) ApplyChanges(ctx context.Context, changes *plan.Changes) error {
|
||||
fmt.Println("586 ApplyChanges", changes)
|
||||
zones, err := p.zones(ctx)
|
||||
if err != nil {
|
||||
return provider.NewSoftError(fmt.Errorf("failed to list zones, not applying changes: %w", err))
|
||||
|
@ -143,6 +143,20 @@ func wildcardEscape(s string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// Route53 octal escapeshttps://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html
|
||||
func specialCharactersEscape(s string) string {
|
||||
var result strings.Builder
|
||||
for _, char := range s {
|
||||
if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char == '-' || char == '.' {
|
||||
result.WriteRune(char)
|
||||
} else {
|
||||
octalCode := fmt.Sprintf("\\%03o", char)
|
||||
result.WriteString(octalCode)
|
||||
}
|
||||
}
|
||||
return result.String()
|
||||
}
|
||||
|
||||
func (r *Route53APIStub) ListTagsForResourceWithContext(ctx context.Context, input *route53.ListTagsForResourceInput, opts ...request.Option) (*route53.ListTagsForResourceOutput, error) {
|
||||
if aws.StringValue(input.ResourceType) == "hostedzone" {
|
||||
tags := r.zoneTags[aws.StringValue(input.ResourceId)]
|
||||
@ -359,6 +373,12 @@ func TestAWSRecords(t *testing.T) {
|
||||
TTL: aws.Int64(recordTTL),
|
||||
ResourceRecords: []*route53.ResourceRecord{{Value: aws.String("8.8.8.8")}},
|
||||
},
|
||||
{
|
||||
Name: aws.String(specialCharactersEscape("escape-%!s(<nil>)-codes.zone-2.ext-dns-test-2.teapot.zalan.do.")),
|
||||
Type: aws.String(route53.RRTypeCname),
|
||||
TTL: aws.Int64(recordTTL),
|
||||
ResourceRecords: []*route53.ResourceRecord{{Value: aws.String("example")}},
|
||||
},
|
||||
{
|
||||
Name: aws.String("list-test-alias.zone-1.ext-dns-test-2.teapot.zalan.do."),
|
||||
Type: aws.String(route53.RRTypeA),
|
||||
@ -501,6 +521,7 @@ func TestAWSRecords(t *testing.T) {
|
||||
endpoint.NewEndpointWithTTL("list-test.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"),
|
||||
endpoint.NewEndpointWithTTL("list-test.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8"),
|
||||
endpoint.NewEndpointWithTTL("*.wildcard-test.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8"),
|
||||
endpoint.NewEndpointWithTTL("escape-%!s(<nil>)-codes.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "example").WithProviderSpecific(providerSpecificAlias, "false"),
|
||||
endpoint.NewEndpointWithTTL("list-test-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "foo.eu-central-1.elb.amazonaws.com").WithProviderSpecific(providerSpecificEvaluateTargetHealth, "false").WithProviderSpecific(providerSpecificAlias, "true"),
|
||||
endpoint.NewEndpointWithTTL("*.wildcard-test-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "foo.eu-central-1.elb.amazonaws.com").WithProviderSpecific(providerSpecificEvaluateTargetHealth, "false").WithProviderSpecific(providerSpecificAlias, "true"),
|
||||
endpoint.NewEndpointWithTTL("list-test-alias-evaluate.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "foo.eu-central-1.elb.amazonaws.com").WithProviderSpecific(providerSpecificEvaluateTargetHealth, "true").WithProviderSpecific(providerSpecificAlias, "true"),
|
||||
|
@ -323,10 +323,8 @@ func (p coreDNSProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, err
|
||||
endpoint.RecordTypeTXT,
|
||||
service.Text,
|
||||
)
|
||||
if ep != nil {
|
||||
ep.Labels[randomPrefixLabel] = prefix
|
||||
result = append(result, ep)
|
||||
}
|
||||
ep.Labels[randomPrefixLabel] = prefix
|
||||
result = append(result, ep)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
|
Loading…
Reference in New Issue
Block a user