mirror of
				https://github.com/StackExchange/dnscontrol.git
				synced 2024-05-11 05:55:12 +00:00 
			
		
		
		
	TXT records are now handled different. 1. The raw input from dnsconfig.js is passed all the way to the provider. The provider can determine if it can or can't handle such records (auditrecords.go) and processes them internally as such. 2. The CanUseTXTMulti capability is no longer needed. * DSPs now register a table of functions * Use audits for txt record variations * unit tests pass. integration fails. * fix deepcopy problem * rename to AuditRecordSupport * Reduce use of TXTMulti * Remove CanUseTXTMulti * fix Test Skip * fix DO * fix vultr * fix NDC * msdns fixes * Fix powerdns and cloudflare * HEDNS: Fix usage of target field to resolve TXT handling (#1067) * Fix HEXONET Co-authored-by: Robert Blenkinsopp <robert@blenkinsopp.net> Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package namedotcom
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| var txtData = []struct {
 | |
| 	decoded []string
 | |
| 	encoded string
 | |
| }{
 | |
| 	{[]string{`simple`}, `simple`},
 | |
| 	{[]string{`changed`}, `changed`},
 | |
| 	{[]string{`with spaces`}, `with spaces`},
 | |
| 	{[]string{`with whitespace`}, `with whitespace`},
 | |
| 	{[]string{"one", "two"}, `"one""two"`},
 | |
| 	{[]string{"eh", "bee", "cee"}, `"eh""bee""cee"`},
 | |
| 	{[]string{"o\"ne", "tw\"o"}, `"o\"ne""tw\"o"`},
 | |
| 	{[]string{"dimple"}, `dimple`},
 | |
| 	{[]string{"fun", "two"}, `"fun""two"`},
 | |
| 	{[]string{"eh", "bzz", "cee"}, `"eh""bzz""cee"`},
 | |
| }
 | |
| 
 | |
| // func TestEncodeTxt(t *testing.T) {
 | |
| // 	// Test encoded the lists of strings into a string:
 | |
| // 	for i, test := range txtData {
 | |
| // 		enc := encodeTxt(test.decoded)
 | |
| // 		if enc != test.encoded {
 | |
| // 			t.Errorf("%v: txt\n    data: []string{%v}\nexpected: %s\n     got: %s",
 | |
| // 				i, "`"+strings.Join(test.decoded, "`, `")+"`", test.encoded, enc)
 | |
| // 		}
 | |
| // 	}
 | |
| //}
 | |
| 
 | |
| func TestDecodeTxt(t *testing.T) {
 | |
| 	// Test decoded a string into the list of strings:
 | |
| 	for i, test := range txtData {
 | |
| 		data := test.encoded
 | |
| 		got := decodeTxt(data)
 | |
| 		wanted := test.decoded
 | |
| 		if len(got) != len(wanted) {
 | |
| 			t.Errorf("%v: txt\n  decode: %v\nexpected: `%v`\n     got: `%v`\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
 | |
| 		} else {
 | |
| 			for j := range got {
 | |
| 				if got[j] != wanted[j] {
 | |
| 					t.Errorf("%v: txt\n  decode: %v\nexpected: `%v`\n     got: `%v`\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |