Remove some debug logging and clean up the test code a bit

This commit is contained in:
Melon 2023-06-29 02:45:21 +01:00
parent fdfdc6c716
commit 796b739aa1
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 1 additions and 30 deletions

View File

@ -124,7 +124,6 @@ func setupPebbleTest(t *testing.T, serverTls *certgen.CertGen) *Service {
assert.NoError(t, err) assert.NoError(t, err)
certRaw, err := io.ReadAll(res.Body) certRaw, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
fmt.Println("Cert:", string(certRaw))
certDir, err := os.MkdirTemp("", "orchid-certs") certDir, err := os.MkdirTemp("", "orchid-certs")
keyDir, err := os.MkdirTemp("", "orchid-keys") keyDir, err := os.MkdirTemp("", "orchid-keys")
@ -185,18 +184,13 @@ func TestPebbleRenewal(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
} }
fmt.Println("Database rows")
fmt.Println("=============")
query, err := service.db.Query("SELECT cert_id, domain from certificate_domains") query, err := service.db.Query("SELECT cert_id, domain from certificate_domains")
assert.NoError(t, err) assert.NoError(t, err)
for query.Next() { for query.Next() {
var a uint64 var a uint64
var b string var b string
assert.NoError(t, query.Scan(&a, &b)) assert.NoError(t, query.Scan(&a, &b))
fmt.Println(a, b)
} }
fmt.Println("=============")
assert.NoError(t, service.renewalCheck()) assert.NoError(t, service.renewalCheck())
certFilePath := filepath.Join(service.certDir, "1.cert.pem") certFilePath := filepath.Join(service.certDir, "1.cert.pem")

View File

@ -56,40 +56,17 @@ func (f *fakeDnsProv) CleanUp(domain, _, keyAuth string) error {
log.Printf("fakeDnsProv.CleanUp(%s TXT %s)\n", info.EffectiveFQDN, info.Value) log.Printf("fakeDnsProv.CleanUp(%s TXT %s)\n", info.EffectiveFQDN, info.Value)
return nil return nil
} }
func (f *fakeDnsProv) GetDnsAddrs() []string { func (f *fakeDnsProv) GetDnsAddrs() []string { return []string{f.Addr} }
fmt.Printf("Get dns addrs: %v\n", f.Addr)
return []string{f.Addr}
}
func (f *fakeDnsProv) parseQuery(m *dns.Msg) { func (f *fakeDnsProv) parseQuery(m *dns.Msg) {
for _, q := range m.Question { for _, q := range m.Question {
switch q.Qtype { switch q.Qtype {
case dns.TypeSOA:
log.Printf("Looking up %s SOA record\n", q.Name)
n := q.Name
for strings.Count(n, ".") > 3 {
// find next subdomain separator and trim the fqdn
ni := strings.IndexByte(n, '.')
if ni <= 0 {
break
}
n = n[ni+1:]
}
// find an answer if possible
if strings.Count(q.Name, ".") == 3 {
rr, err := dns.NewRR(fmt.Sprintf("%s 32600 IN SOA %s %s 1687993787 86400 7200 4000000 11200", n, "ns.example.com.", "hostmaster.example.com."))
if err == nil {
m.Answer = append(m.Answer, rr)
}
}
case dns.TypeTXT: case dns.TypeTXT:
log.Printf("Looking up %s TXT record\n", q.Name) log.Printf("Looking up %s TXT record\n", q.Name)
txt := f.mTxt[q.Name] txt := f.mTxt[q.Name]
if txt != "" { if txt != "" {
rr, err := dns.NewRR(fmt.Sprintf("%s 32600 IN TXT \"%s\"", q.Name, txt)) rr, err := dns.NewRR(fmt.Sprintf("%s 32600 IN TXT \"%s\"", q.Name, txt))
if err == nil { if err == nil {
fmt.Println("response:", rr.String())
m.Answer = append(m.Answer, rr) m.Answer = append(m.Answer, rr)
} }
} }