Fix small nbf->naf bug in db.CreateOrder

- still needs unit test
This commit is contained in:
max furman 2021-03-25 16:45:26 -07:00
parent a785131d09
commit fd447c5b54
3 changed files with 19 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package nosql
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"sync" "sync"
"time" "time"
@ -91,9 +92,10 @@ func (db *DB) CreateOrder(ctx context.Context, o *acme.Order) error {
ExpiresAt: o.ExpiresAt, ExpiresAt: o.ExpiresAt,
Identifiers: o.Identifiers, Identifiers: o.Identifiers,
NotBefore: o.NotBefore, NotBefore: o.NotBefore,
NotAfter: o.NotBefore, NotAfter: o.NotAfter,
AuthorizationIDs: o.AuthorizationIDs, AuthorizationIDs: o.AuthorizationIDs,
} }
fmt.Printf("dbo = %+v\n", dbo)
if err := db.save(ctx, o.ID, dbo, nil, "order", orderTable); err != nil { if err := db.save(ctx, o.ID, dbo, nil, "order", orderTable); err != nil {
return err return err
} }

View file

@ -1,6 +1,7 @@
package acme package acme
import ( import (
"encoding/json"
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -337,3 +338,12 @@ func (e *Error) Cause() error {
} }
return e.Err return e.Err
} }
// ToLog implements the EnableLogger interface.
func (e *Error) ToLog() (interface{}, error) {
b, err := json.Marshal(e)
if err != nil {
return nil, WrapErrorISE(err, "error marshaling acme.Error for logging")
}
return string(b), nil
}

View file

@ -33,11 +33,15 @@ func WriteError(w http.ResponseWriter, err error) {
// Write errors in the response writer // Write errors in the response writer
if rl, ok := w.(logging.ResponseLogger); ok { if rl, ok := w.(logging.ResponseLogger); ok {
logErr := err
if u, ok := err.(*acme.Error); ok {
logErr = u.Err
}
rl.WithFields(map[string]interface{}{ rl.WithFields(map[string]interface{}{
"error": err, "error": logErr,
}) })
if os.Getenv("STEPDEBUG") == "1" { if os.Getenv("STEPDEBUG") == "1" {
if e, ok := err.(errs.StackTracer); ok { if e, ok := logErr.(errs.StackTracer); ok {
rl.WithFields(map[string]interface{}{ rl.WithFields(map[string]interface{}{
"stack-trace": fmt.Sprintf("%+v", e), "stack-trace": fmt.Sprintf("%+v", e),
}) })