mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-03-09 20:29:14 +07:00
Refactor: Rename ACMETxtPost struct into Challenge
This commit is contained in:
parent
e1f1d6af34
commit
4c863103f5
@ -12,12 +12,12 @@ import (
|
||||
type ACMETxt struct {
|
||||
Username uuid.UUID
|
||||
Password string
|
||||
ACMETxtPost
|
||||
Challenge
|
||||
AllowFrom cidrslice
|
||||
}
|
||||
|
||||
// ACMETxtPost holds the DNS part of the ACMETxt struct
|
||||
type ACMETxtPost struct {
|
||||
// Challenge holds the DNS part of the ACMETxt struct
|
||||
type Challenge struct {
|
||||
Subdomain string `json:"subdomain"`
|
||||
Value string `json:"txt"`
|
||||
}
|
||||
|
2
api.go
2
api.go
@ -91,7 +91,7 @@ func webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
|
||||
updStatus = http.StatusBadRequest
|
||||
upd = jsonError("bad_txt")
|
||||
} else if validSubdomain(a.Subdomain) && validTXT(a.Value) {
|
||||
err := DB.Update(a.ACMETxtPost)
|
||||
err := DB.Update(a.Challenge)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"error": err.Error()}).Debug("Error while trying to update record")
|
||||
updStatus = http.StatusInternalServerError
|
||||
|
2
db.go
2
db.go
@ -281,7 +281,7 @@ func (d *acmedb) GetTXTForDomain(domain string) ([]string, error) {
|
||||
return txts, nil
|
||||
}
|
||||
|
||||
func (d *acmedb) Update(a ACMETxtPost) error {
|
||||
func (d *acmedb) Update(a Challenge) error {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
var err error
|
||||
|
@ -161,7 +161,7 @@ func TestQueryExecErrors(t *testing.T) {
|
||||
t.Errorf("Expected error from exec in Register, but got none")
|
||||
}
|
||||
reg.Value = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
err = DB.Update(reg.ACMETxtPost)
|
||||
err = DB.Update(reg.Challenge)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error from exec in Update, but got none")
|
||||
}
|
||||
@ -238,10 +238,10 @@ func TestGetTXTForDomain(t *testing.T) {
|
||||
txtval2 := "___validation_token_received_YEAH_the_ca___"
|
||||
|
||||
reg.Value = txtval1
|
||||
_ = DB.Update(reg.ACMETxtPost)
|
||||
_ = DB.Update(reg.Challenge)
|
||||
|
||||
reg.Value = txtval2
|
||||
_ = DB.Update(reg.ACMETxtPost)
|
||||
_ = DB.Update(reg.Challenge)
|
||||
|
||||
regDomainSlice, err := DB.GetTXTForDomain(reg.Subdomain)
|
||||
if err != nil {
|
||||
@ -294,7 +294,7 @@ func TestUpdate(t *testing.T) {
|
||||
regUser.Password = "nevergonnagiveyouup"
|
||||
regUser.Value = validTXT
|
||||
|
||||
err = DB.Update(regUser.ACMETxtPost)
|
||||
err = DB.Update(regUser.Challenge)
|
||||
if err != nil {
|
||||
t.Errorf("DB Update failed, got error: [%v]", err)
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func TestResolveTXT(t *testing.T) {
|
||||
return
|
||||
}
|
||||
atxt.Value = validTXT
|
||||
err = DB.Update(atxt.ACMETxtPost)
|
||||
err = DB.Update(atxt.Challenge)
|
||||
if err != nil {
|
||||
t.Errorf("Could not update db record: [%v]", err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user