36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package grpc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"github.com/letsencrypt/boulder/core"
|
|
"github.com/letsencrypt/boulder/test"
|
|
)
|
|
|
|
func TestErrors(t *testing.T) {
|
|
testcases := []struct {
|
|
err error
|
|
expectedCode codes.Code
|
|
}{
|
|
{core.MalformedRequestError("test 1"), MalformedRequestError},
|
|
{core.NotSupportedError("test 2"), NotSupportedError},
|
|
{core.UnauthorizedError("test 3"), UnauthorizedError},
|
|
{core.NotFoundError("test 4"), NotFoundError},
|
|
{core.LengthRequiredError("test 5"), LengthRequiredError},
|
|
{core.SignatureValidationError("test 6"), SignatureValidationError},
|
|
{core.RateLimitedError("test 7"), RateLimitedError},
|
|
{core.BadNonceError("test 8"), BadNonceError},
|
|
{core.NoSuchRegistrationError("test 9"), NoSuchRegistrationError},
|
|
{core.InternalServerError("test 10"), InternalServerError},
|
|
}
|
|
|
|
for _, tc := range testcases {
|
|
wrappedErr := wrapError(tc.err)
|
|
test.AssertEquals(t, grpc.Code(wrappedErr), tc.expectedCode)
|
|
test.AssertEquals(t, tc.err, unwrapError(wrappedErr))
|
|
}
|
|
}
|