fix invite code error message
This commit is contained in:
parent
6fd0f03895
commit
4028928123
@ -62,7 +62,7 @@ var catalog = map[Code]Spec{
|
||||
RegionNotFound: spec(codes.NotFound, httpStatusNotFound, RegionNotFound, "not found"),
|
||||
RegionCountryConflict: spec(codes.FailedPrecondition, httpStatusConflict, RegionCountryConflict, "conflict"),
|
||||
RegionDisabled: spec(codes.FailedPrecondition, httpStatusConflict, RegionDisabled, "conflict"),
|
||||
InvalidInviteCode: spec(codes.InvalidArgument, httpStatusBadRequest, InvalidInviteCode, "invalid argument"),
|
||||
InvalidInviteCode: spec(codes.InvalidArgument, httpStatusBadRequest, InvalidInviteCode, "invalid invite code"),
|
||||
DeviceAlreadyRegistered: spec(
|
||||
codes.FailedPrecondition,
|
||||
httpStatusConflict,
|
||||
|
||||
@ -60,7 +60,7 @@ func TestCatalogMappings(t *testing.T) {
|
||||
grpcCode: codes.InvalidArgument,
|
||||
httpStatus: httpStatusBadRequest,
|
||||
publicCode: string(InvalidInviteCode),
|
||||
publicMessage: "invalid argument",
|
||||
publicMessage: "invalid invite code",
|
||||
},
|
||||
{
|
||||
name: "unavailable is exposed as upstream error",
|
||||
|
||||
@ -8013,6 +8013,22 @@ func TestCompleteOnboardingAllowsIncompleteProfileAndUsesAuthenticatedUserID(t *
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteOnboardingReturnsInvalidInviteCodeMessage(t *testing.T) {
|
||||
profileClient := &fakeUserProfileClient{
|
||||
completeErr: xerr.ToGRPCError(xerr.New(xerr.InvalidInviteCode, "invalid invite code")),
|
||||
}
|
||||
router := NewHandlerWithClients(&fakeRoomClient{}, nil, nil, profileClient).Routes(auth.NewVerifier("secret"))
|
||||
body := []byte(`{"username":"hy","avatar":"https://cdn.example/a.png","gender":"male","country":"SG","invite_code":"BADCODE"}`)
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/users/me/onboarding/complete", bytes.NewReader(body))
|
||||
request.Header.Set("Authorization", "Bearer "+signGatewayTokenWithProfile(t, "secret", 42, false))
|
||||
request.Header.Set("X-Request-ID", "req-onboarding-invalid-invite")
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
router.ServeHTTP(recorder, request)
|
||||
|
||||
assertEnvelopeMessage(t, recorder, http.StatusBadRequest, string(xerr.InvalidInviteCode), "invalid invite code", "req-onboarding-invalid-invite")
|
||||
}
|
||||
|
||||
func TestProfileMutationEndpointsRequireCompletedProfileToken(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user