Fix linter issues

This commit is contained in:
Yannik Sembritzki 2021-07-16 20:18:51 +02:00
parent 5a16ea93e9
commit 7e121f0f3c
4 changed files with 4 additions and 35 deletions

2
api.go
View File

@ -140,7 +140,7 @@ func webDeletePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(delStatus)
w.Write(del)
_, _ = w.Write(del)
}
// Endpoint used to check the readiness and/or liveness (health) of the server.

View File

@ -515,10 +515,6 @@ func TestApiManyUpdateWithCredentials(t *testing.T) {
func TestApiManyDeleteWithCredentials(t *testing.T) {
validTxtData := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
updateJSON := map[string]interface{}{
"subdomain": "",
"txt": ""}
router := setupRouter(true, false)
server := httptest.NewServer(router)
defer server.Close()
@ -560,7 +556,7 @@ func TestApiManyDeleteWithCredentials(t *testing.T) {
{newUserWithValidCIDR.Username.String(), newUserWithValidCIDR.Password, newUserWithValidCIDR.Subdomain, validTxtData, 200},
{newUser.Username.String(), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", newUser.Subdomain, validTxtData, 401},
} {
updateJSON = map[string]interface{}{
updateJSON := map[string]interface{}{
"subdomain": test.subdomain,
"txt": test.txt}
e.POST("/delete").
@ -626,11 +622,6 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) {
}
func TestApiManyDeleteWithIpCheckHeaders(t *testing.T) {
updateJSON := map[string]interface{}{
"subdomain": "",
"txt": ""}
router := setupRouter(false, false)
server := httptest.NewServer(router)
defer server.Close()
@ -667,7 +658,7 @@ func TestApiManyDeleteWithIpCheckHeaders(t *testing.T) {
{newUserWithIP6CIDR, "2002:c0a7:0ff::0", 401},
{newUserWithIP6CIDR, "2002:c0a8:d3ad:b33f:c0ff:33b4:dc0d:3b4d", 200},
} {
updateJSON = map[string]interface{}{
updateJSON := map[string]interface{}{
"subdomain": test.user.Subdomain,
"txt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
e.POST("/delete").

23
db.go
View File

@ -114,28 +114,7 @@ func (d *acmedb) handleDBUpgrades(version int) error {
func (d *acmedb) handleDBUpgradeTo1() error {
var err error
var subdomains []string
log.Info("Upgrading db to version 1")
rows, err := d.DB.Query("SELECT Subdomain FROM records")
if err != nil {
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade")
return err
}
defer rows.Close()
for rows.Next() {
var subdomain string
err = rows.Scan(&subdomain)
if err != nil {
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade while reading values")
return err
}
subdomains = append(subdomains, subdomain)
}
err = rows.Err()
if err != nil {
log.WithFields(log.Fields{"error": err.Error()}).Error("Error in DB upgrade while inserting values")
return err
}
tx, err := d.DB.Begin()
// Rollback if errored, commit if not
defer func() {
@ -312,10 +291,10 @@ func (d *acmedb) Update(a ACMETxtPost) error {
lastUsedSQL := `UPDATE records SET LastUsed = $1 WHERE Subdomain = $2`
lastUsedStmt, err := d.DB.Prepare(lastUsedSQL)
defer lastUsedStmt.Close()
if err != nil {
return err
}
defer lastUsedStmt.Close()
if err != nil {
return err
}

View File

@ -356,7 +356,6 @@ func TestResolveTXT(t *testing.T) {
t.Fatalf("Test %d: %s", seq, err)
return
}
seq++
}
func TestCaseInsensitiveResolveA(t *testing.T) {