• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

joohoi / acme-dns / 21714519299

05 Feb 2026 02:04PM UTC coverage: 77.229% (+4.0%) from 73.276%
21714519299

push

github

web-flow
Refactoring (#325)

* Refactor core

* Re-added tests

* Small fixes

* Add tests for acmetxt cidrslice and util funcs

* Remove the last dangling reference to old logging package

* Refactoring (#327)

* chore: enable more linters and fix linter issues

* ci: enable linter checks on all branches and disable recurring checks

recurring linter checks don't make that much sense. The code & linter checks should not change on their own over night ;)

* chore: update packages

* Revert "chore: update packages"

This reverts commit 30250bf28.

* chore: manually upgrade some packages

* Updated dependencies, wrote changelog entry and fixed namespace for release

* Refactoring - improving coverage (#371)

* Increase code coverage in acmedns

* More testing of ReadConfig() and its fallback mechanism

* Found that if someone put a '"' double quote into the filename that we configure zap to log to, it would cause the the JSON created to be invalid. I have replaced the JSON string with proper config

* Better handling of config options for api.TLS - we now error on an invalid value instead of silently failing.

added a basic test for api.setupTLS() (to increase test coverage)

* testing nameserver isOwnChallenge and isAuthoritative methods

* add a unit test for nameserver answerOwnChallenge

* fix linting errors

* bump go and golangci-lint versions in github actions

* Update golangci-lint.yml

Bumping github-actions workflow versions to accommodate some changes in upstream golanci-lint

* Bump Golang version to 1.23 (currently the oldest supported version)

Bump golanglint-ci to 2.0.2 and migrate the config file.

This should resolve the math/rand/v2 issue

* bump golanglint-ci action version

* Fixing up new golanglint-ci warnings and errors

---------

Co-authored-by: Joona Hoikkala <5235109+joohoi@users.noreply.github.com>

* Minor refactoring, error returns and e2e testing suite

* Add a few tests

* Fix linter an... (continued)

582 of 764 new or added lines in 20 files covered. (76.18%)

3 existing lines in 1 file now uncovered.

797 of 1032 relevant lines covered (77.23%)

7.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.5
/pkg/api/update.go
1
package api
2

3
import (
4
        "net/http"
5

6
        "github.com/joohoi/acme-dns/pkg/acmedns"
7

8
        "github.com/julienschmidt/httprouter"
9
)
10

11
func (a *AcmednsAPI) webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
12✔
12
        var updStatus int
12✔
13
        var upd []byte
12✔
14
        // Get user
12✔
15
        atxt, ok := r.Context().Value(ACMETxtKey).(acmedns.ACMETxt)
12✔
16
        if !ok {
12✔
NEW
17
                a.Logger.Errorw("Context error",
×
NEW
18
                        "error", "context")
×
NEW
19
        }
×
20
        // NOTE: An invalid subdomain should not happen - the auth handler should
21
        // reject POSTs with an invalid subdomain before this handler. Reject any
22
        // invalid subdomains anyway as a matter of caution.
23
        if !validSubdomain(atxt.Subdomain) {
12✔
NEW
24
                a.Logger.Errorw("Bad update data",
×
NEW
25
                        "error", "subdomain",
×
NEW
26
                        "subdomain", atxt.Subdomain,
×
NEW
27
                        "txt", atxt.Value)
×
NEW
28
                updStatus = http.StatusBadRequest
×
NEW
29
                upd = jsonError("bad_subdomain")
×
30
        } else if !validTXT(atxt.Value) {
15✔
31
                a.Logger.Errorw("Bad update data",
3✔
32
                        "error", "txt",
3✔
33
                        "subdomain", atxt.Subdomain,
3✔
34
                        "txt", atxt.Value)
3✔
35
                updStatus = http.StatusBadRequest
3✔
36
                upd = jsonError("bad_txt")
3✔
37
        } else if validSubdomain(atxt.Subdomain) && validTXT(atxt.Value) {
21✔
38
                err := a.DB.Update(atxt.ACMETxtPost)
9✔
39
                if err != nil {
10✔
40
                        a.Logger.Errorw("Error while trying to update record",
1✔
41
                                "error", err.Error())
1✔
42
                        updStatus = http.StatusInternalServerError
1✔
43
                        upd = jsonError("db_error")
1✔
44
                } else {
9✔
45
                        a.Logger.Debugw("TXT record updated",
8✔
46
                                "subdomain", atxt.Subdomain,
8✔
47
                                "txt", atxt.Value)
8✔
48
                        updStatus = http.StatusOK
8✔
49
                        upd = []byte("{\"txt\": \"" + atxt.Value + "\"}")
8✔
50
                }
8✔
51
        }
52
        w.Header().Set("Content-Type", "application/json")
12✔
53
        w.WriteHeader(updStatus)
12✔
54
        _, _ = w.Write(upd)
12✔
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc