forked from TrueCloudLab/certificates
Merge pull request #1058 from smallstep/acme-errors
Return the internal error instead of the ACME error
This commit is contained in:
commit
fcb9d88223
4 changed files with 19 additions and 16 deletions
|
@ -77,7 +77,7 @@ func TestDB_getDBAuthz(t *testing.T) {
|
||||||
Token: "token",
|
Token: "token",
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
ExpiresAt: now.Add(5 * time.Minute),
|
ExpiresAt: now.Add(5 * time.Minute),
|
||||||
Error: acme.NewErrorISE("force"),
|
Error: acme.NewErrorISE("The server experienced an internal error"),
|
||||||
ChallengeIDs: []string{"foo", "bar"},
|
ChallengeIDs: []string{"foo", "bar"},
|
||||||
Wildcard: true,
|
Wildcard: true,
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ func TestDB_GetAuthorization(t *testing.T) {
|
||||||
Token: "token",
|
Token: "token",
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
ExpiresAt: now.Add(5 * time.Minute),
|
ExpiresAt: now.Add(5 * time.Minute),
|
||||||
Error: acme.NewErrorISE("force"),
|
Error: acme.NewErrorISE("The server experienced an internal error"),
|
||||||
ChallengeIDs: []string{"foo", "bar"},
|
ChallengeIDs: []string{"foo", "bar"},
|
||||||
Wildcard: true,
|
Wildcard: true,
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ func TestDB_UpdateAuthorization(t *testing.T) {
|
||||||
assert.Equals(t, dbNew.Wildcard, dbaz.Wildcard)
|
assert.Equals(t, dbNew.Wildcard, dbaz.Wildcard)
|
||||||
assert.Equals(t, dbNew.CreatedAt, dbaz.CreatedAt)
|
assert.Equals(t, dbNew.CreatedAt, dbaz.CreatedAt)
|
||||||
assert.Equals(t, dbNew.ExpiresAt, dbaz.ExpiresAt)
|
assert.Equals(t, dbNew.ExpiresAt, dbaz.ExpiresAt)
|
||||||
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "malformed").Error())
|
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "The request message was malformed").Error())
|
||||||
return nil, false, errors.New("force")
|
return nil, false, errors.New("force")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -582,7 +582,7 @@ func TestDB_UpdateAuthorization(t *testing.T) {
|
||||||
assert.Equals(t, dbNew.Wildcard, dbaz.Wildcard)
|
assert.Equals(t, dbNew.Wildcard, dbaz.Wildcard)
|
||||||
assert.Equals(t, dbNew.CreatedAt, dbaz.CreatedAt)
|
assert.Equals(t, dbNew.CreatedAt, dbaz.CreatedAt)
|
||||||
assert.Equals(t, dbNew.ExpiresAt, dbaz.ExpiresAt)
|
assert.Equals(t, dbNew.ExpiresAt, dbaz.ExpiresAt)
|
||||||
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "malformed").Error())
|
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "The request message was malformed").Error())
|
||||||
return nu, true, nil
|
return nu, true, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,7 +72,7 @@ func TestDB_getDBChallenge(t *testing.T) {
|
||||||
Value: "test.ca.smallstep.com",
|
Value: "test.ca.smallstep.com",
|
||||||
CreatedAt: clock.Now(),
|
CreatedAt: clock.Now(),
|
||||||
ValidatedAt: "foobar",
|
ValidatedAt: "foobar",
|
||||||
Error: acme.NewErrorISE("force"),
|
Error: acme.NewErrorISE("The server experienced an internal error"),
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(dbc)
|
b, err := json.Marshal(dbc)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
|
@ -264,7 +264,7 @@ func TestDB_GetChallenge(t *testing.T) {
|
||||||
Value: "test.ca.smallstep.com",
|
Value: "test.ca.smallstep.com",
|
||||||
CreatedAt: clock.Now(),
|
CreatedAt: clock.Now(),
|
||||||
ValidatedAt: "foobar",
|
ValidatedAt: "foobar",
|
||||||
Error: acme.NewErrorISE("force"),
|
Error: acme.NewErrorISE("The server experienced an internal error"),
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(dbc)
|
b, err := json.Marshal(dbc)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
|
@ -354,7 +354,7 @@ func TestDB_UpdateChallenge(t *testing.T) {
|
||||||
ID: chID,
|
ID: chID,
|
||||||
Status: acme.StatusValid,
|
Status: acme.StatusValid,
|
||||||
ValidatedAt: "foobar",
|
ValidatedAt: "foobar",
|
||||||
Error: acme.NewError(acme.ErrorMalformedType, "malformed"),
|
Error: acme.NewError(acme.ErrorMalformedType, "The request message was malformed"),
|
||||||
}
|
}
|
||||||
return test{
|
return test{
|
||||||
ch: updCh,
|
ch: updCh,
|
||||||
|
@ -428,7 +428,7 @@ func TestDB_UpdateChallenge(t *testing.T) {
|
||||||
assert.Equals(t, dbNew.CreatedAt, dbc.CreatedAt)
|
assert.Equals(t, dbNew.CreatedAt, dbc.CreatedAt)
|
||||||
assert.Equals(t, dbNew.Status, acme.StatusValid)
|
assert.Equals(t, dbNew.Status, acme.StatusValid)
|
||||||
assert.Equals(t, dbNew.ValidatedAt, "foobar")
|
assert.Equals(t, dbNew.ValidatedAt, "foobar")
|
||||||
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "malformed").Error())
|
assert.Equals(t, dbNew.Error.Error(), acme.NewError(acme.ErrorMalformedType, "The request message was malformed").Error())
|
||||||
return nu, true, nil
|
return nu, true, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -80,7 +80,7 @@ func TestDB_getDBOrder(t *testing.T) {
|
||||||
{Type: "dns", Value: "example.foo.com"},
|
{Type: "dns", Value: "example.foo.com"},
|
||||||
},
|
},
|
||||||
AuthorizationIDs: []string{"foo", "bar"},
|
AuthorizationIDs: []string{"foo", "bar"},
|
||||||
Error: acme.NewError(acme.ErrorMalformedType, "force"),
|
Error: acme.NewError(acme.ErrorMalformedType, "The request message was malformed"),
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(dbo)
|
b, err := json.Marshal(dbo)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
|
@ -185,7 +185,7 @@ func TestDB_GetOrder(t *testing.T) {
|
||||||
{Type: "dns", Value: "example.foo.com"},
|
{Type: "dns", Value: "example.foo.com"},
|
||||||
},
|
},
|
||||||
AuthorizationIDs: []string{"foo", "bar"},
|
AuthorizationIDs: []string{"foo", "bar"},
|
||||||
Error: acme.NewError(acme.ErrorMalformedType, "force"),
|
Error: acme.NewError(acme.ErrorMalformedType, "The request message was malformed"),
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(dbo)
|
b, err := json.Marshal(dbo)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
|
@ -284,7 +284,7 @@ func TestDB_UpdateOrder(t *testing.T) {
|
||||||
ID: orderID,
|
ID: orderID,
|
||||||
Status: acme.StatusValid,
|
Status: acme.StatusValid,
|
||||||
CertificateID: "certID",
|
CertificateID: "certID",
|
||||||
Error: acme.NewError(acme.ErrorMalformedType, "force"),
|
Error: acme.NewError(acme.ErrorMalformedType, "The request message was malformed"),
|
||||||
}
|
}
|
||||||
return test{
|
return test{
|
||||||
o: o,
|
o: o,
|
||||||
|
@ -324,7 +324,7 @@ func TestDB_UpdateOrder(t *testing.T) {
|
||||||
ID: orderID,
|
ID: orderID,
|
||||||
Status: acme.StatusValid,
|
Status: acme.StatusValid,
|
||||||
CertificateID: "certID",
|
CertificateID: "certID",
|
||||||
Error: acme.NewError(acme.ErrorMalformedType, "force"),
|
Error: acme.NewError(acme.ErrorMalformedType, "The request message was malformed"),
|
||||||
}
|
}
|
||||||
return test{
|
return test{
|
||||||
o: o,
|
o: o,
|
||||||
|
@ -372,7 +372,7 @@ func TestDB_UpdateOrder(t *testing.T) {
|
||||||
assert.Equals(t, tc.o.ID, dbo.ID)
|
assert.Equals(t, tc.o.ID, dbo.ID)
|
||||||
assert.Equals(t, tc.o.CertificateID, "certID")
|
assert.Equals(t, tc.o.CertificateID, "certID")
|
||||||
assert.Equals(t, tc.o.Status, acme.StatusValid)
|
assert.Equals(t, tc.o.Status, acme.StatusValid)
|
||||||
assert.Equals(t, tc.o.Error.Error(), acme.NewError(acme.ErrorMalformedType, "force").Error())
|
assert.Equals(t, tc.o.Error.Error(), acme.NewError(acme.ErrorMalformedType, "The request message was malformed").Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -659,7 +659,7 @@ func TestDB_updateAddOrderIDs(t *testing.T) {
|
||||||
assert.Equals(t, newdbo.ID, "foo")
|
assert.Equals(t, newdbo.ID, "foo")
|
||||||
assert.Equals(t, newdbo.Status, acme.StatusInvalid)
|
assert.Equals(t, newdbo.Status, acme.StatusInvalid)
|
||||||
assert.Equals(t, newdbo.ExpiresAt, expiry)
|
assert.Equals(t, newdbo.ExpiresAt, expiry)
|
||||||
assert.Equals(t, newdbo.Error.Error(), acme.NewError(acme.ErrorMalformedType, "order has expired").Error())
|
assert.Equals(t, newdbo.Error.Error(), acme.NewError(acme.ErrorMalformedType, "The request message was malformed").Error())
|
||||||
return nil, false, errors.New("force")
|
return nil, false, errors.New("force")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -335,9 +335,12 @@ func (e *Error) StatusCode() int {
|
||||||
return e.Status
|
return e.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error allows AError to implement the error interface.
|
// Error implements the error interface.
|
||||||
func (e *Error) Error() string {
|
func (e *Error) Error() string {
|
||||||
return e.Detail
|
if e.Err == nil {
|
||||||
|
return e.Detail
|
||||||
|
}
|
||||||
|
return e.Err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cause returns the internal error and implements the Causer interface.
|
// Cause returns the internal error and implements the Causer interface.
|
||||||
|
|
Loading…
Reference in a new issue